Home

Awesome

Code for 'Dynamic MLP for Fine-Grained Image Classification by Leveraging Geographical and Temporal Information'

<p align="center"> <img src="figs/structure.svg" width="100%"></p> <a href="https://arxiv.org/pdf/2203.03253.pdf">Dynamic MLP</a>, which is parameterized by the learned embeddings of variable locations and dates to help fine-grained image classification.

Requirements

Experiment Environment

Get pretrained models for SK-Res2Net following here.
Get datasets following here.

Train the model

1. Train image-only model

Specify --image_only for training image-only models.

CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 train.py \
  --name res50_image_only \
  --data 'inat21_mini' \
  --data_dir 'path/to/your/data' \
  --model_file 'resnet' \
  --model_name 'resnet50' \
  --pretrained \
  --batch_size 512 \
  --start_lr 0.04 \
  --image_only
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 train.py \
  --name sk2_image_only \
  --data 'inat21_mini' \
  --data_dir 'path/to/your/data' \
  --model_file 'sk2res2net' \
  --model_name 'sk2res2net101' \
  --pretrained \
  --batch_size 512 \
  --start_lr 0.04 \
  --image_only

2. Train dynamic MLP model

CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 train.py \
  --name res50_dynamic_mlp \
  --data 'inat21_mini' \
  --data_dir 'path/to/your/data' \
  --model_file 'resnet_dynamic_mlp' \
  --model_name 'resnet50' \
  --pretrained \
  --batch_size 512 \
  --start_lr 0.04
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 train.py \
  --name sk2_dynamic_mlp \
  --data 'inat21_mini' \
  --data_dir 'path/to/your/data' \
  --model_file 'sk2res2net_dynamic_mlp' \
  --model_name 'sk2res2net101' \
  --pretrained \
  --batch_size 512 \
  --start_lr 0.04

Test the model

Specify --resume and --evaluate for inference and --image_only for testing image-only models.

python3 train.py \
  --name sk2_dynamic_mlp \
  --data 'inat21_mini' \
  --data_dir 'path/to/your/data' \
  --model_file 'sk2res2net_dynamic_mlp' \
  --model_name 'sk2res2net101' \
  --resume 'path/to/your/checkpoint' \
  --evaluate

Model Zoo

iNaturalist 2021 mini (90 epoch)

BackboneSizeAcc@1LogDownload
ResNet-5022467.924logmodel
+ Dynamic MLP22478.751logmodel
SK-Res2Net-10122476.102logmodel
+ Dynamic MLP22484.694logmodel