-
Several important packages
- torch == 1.10.2+cu111
- trochvision == 0.11.3+cu111
-
Replace folder timm/ to our timm/ folder (We made some changes to the original Timm framework, such as adding TA, etc)
pytorch model implementation timm
In this project, we use a large snake's datasets from this challenge to evaluate performance:
- Windows10
- Ubuntu20.04
- macOS (CPU only)
- Single GPU Training
- DataParallel (single machine multi-gpus)
- DistributedDataParallel
(more information: https://pytorch.org/tutorials/intermediate/ddp_tutorial.html)
Training sets and test sets are distributed with CSV labels corresponding to them.
you can directly modify yaml file (in ./configs/)
take the SwinTransformer training process as an example.
- we train a basic model by dividing the training set and verification set 9:1
python train_f1.py ./matadata/SnakeCLEF2022-small_size/SnakeCLEF2022-small_size/1990 -c configs/swin_large_384.yaml \
--freeze-layer 2 \
--batch-size 32 \
--lr 0.01 \
--decay-rate 0.9 \
--output ./output/Swin-TF/freeze_layer_2
- Add data augment and continue fine-tuning
python train_f1.py ./matadata/SnakeCLEF2022-small_size/SnakeCLEF2022-small_size/1990 -c configs/swin_large_384.yaml \
--output ./output/Swin-TF/All_aug/freeze_layer_2 \
--initial-checkpoint ./output/Swin-TF/freeze_layer_2/20220430-123449-swin_large_patch4_window12_384-384/Best_Top1-ACC.pth.tar \
--freeze-layer 2 \
--lr 0.001 \
--batch-size 32 \
--warmup-epochs 0 \
--cutmix 1 \
--color-jitter 0.4 \
--reprob 0.25 \
--aa trivial \
--decay-rate 0.9
- Modify the loss function and continue fine-tuning
python train_f1.py ./matadata/SnakeCLEF2022-small_size/SnakeCLEF2022-small_size/1990 -c configs/swin_large_384.yaml \
--output ./output/Swin-TF/new_loss/freeze_layer_2 \
--initial-checkpoint ./output/Swin-TF/All_aug/freeze_layer_2/20220430-123449-swin_large_patch4_window12_384-384/Best_Top1-ACC.pth.tar \
--freeze-layer 2 \
--lr 0.001 \
--batch-size 32 \
--warmup-epochs 0 \
--cutmix 1 \
--color-jitter 0.4 \
--reprob 0.25 \
--aa trivial \
--decay-rate 0.9 \
--Focalloss
- Fine-tuning with full datasets
python train_f1.py ./matadata/SnakeCLEF2022-small_size/SnakeCLEF2022-small_size/1990 -c configs/swin_large_384.yaml \
--batch-size 32 \
--img-size 384 \
--output ./output/Swin-TF/All_data/swin_large_384 \
--freeze-layer 2 \
--initial-checkpoint ./output/Swin-TF/new_loss/freeze_layer_2/20220502-114033-swin_large_patch4_window12_384-384/Best_Top1-ACC.pth.tar \
--lr 0.001 \
--cutmix 1 \
--color-jitter 0.4 \
--reprob 0.25 \
--aa trivial \
--decay-rate 0.1 \
--warmup-epochs 0 \
--epochs 24 \
--sched multistep \
--checkpoint-hist 24 \
--Focalloss
sh dist_train.sh
for details, see test.sh
sh test.sh
python tools/model_confusion.py
You need to download the logits from 5 and run the command python tools/model_confusion.py to get the result showing in the leaderboard.
It can be downloaded from Google Cloud Disk: https://drive.google.com/file/d/1vudXIAVEUJekXQfhgd_32HhTzxmDUxpr/view?usp=sharing
It can be directly used for model ensemble reasoning.
- Thanks to timm for Pytorch implementation.