paper link: http://star.informatik.rwth-aachen.de/Publications/CEUR-WS/Vol-3180/paper-182.pdf
This work is sponsored by Natural Science Foundation of China(62276242), CAAI-Huawei MindSpore Open Fund(CAAIXSJLJJ-2021-016B), Anhui Province Key Research and Development Program(202104a05020007), and USTC Research Funds of the Double First-Class Initiative(YD2350002001)”。
-
Several important packages
- mindspore == 1.8.1
- mindcv
-
Replace folder mindcv/ to our mindcv/ folder (We made some changes to the original Mindcv framework, such as adding TA, etc)
MindCV is an open source toolbox for computer vision research and development based on MindSpore. mindcv
In this project, we use a large fungi's datasets from this challenge to evaluate performance:
- Windows10
- Ubuntu20.04
- macOS (CPU only)
- Single GPU Training
- DataParallel (single machine multi-gpus)
- DistributedDataParallel
train data and test data structure:
├── DF20/
│ ├── img20001.jpg
│ ├── img20002.jpg
│ └── ....
├── DF21/
│ ├── img21001.jpg
│ ├── img21002.jpg
│ └── ....
└──
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.py ./Fungidata/DF20 -c configs/swin_large_384.yaml \
--freeze-layer 2 \
--batch-size 32 \
--lr 0.01 \
--decay-rate 0.9 \
--output ./output/Swin-TF/DF20/freeze_layer_2
- Add data augment and continue fine-tuning
python train.py ./Fungidata/DF20 -c configs/swin_large_384.yaml \
--output ./output/Swin-TF/DF20/All_aug/freeze_layer_2 \
--initial-checkpoint ./output/Swin-TF/DF20/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.py ./Fungidata/DF20 -c configs/swin_large_384.yaml \
--output ./output/Swin-TF/DF20/new_loss/freeze_layer_2 \
--initial-checkpoint ./output/Swin-TF/DF20/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 data sets
python train_all.py ./Fungidata/DF20 -c configs/swin_large_384.yaml \
--batch-size 32 \
--img-size 384 \
--output ./output/Swin-TF/DF20/All_data/swin_large_384 \
--freeze-layer 2 \
--initial-checkpoint ./output/Swin-TF/DF20/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
- Two-stage training
python train_all.py ./Fungidata/DF20 -c configs/swin_large_384.yaml \
--batch-size 32 \
--img-size 384 \
--output ./output/Swin-TF/DF20/two_stage/swin_large_384 \
--freeze-layer 2 \
--initial-checkpoint ./output/Swin-TF/DF20/All_data/freeze_layer_2/20220504-115867-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 5 \
--sched multistep \
--Focalloss
change train.sh
python -m mindspre.distributed.launch --nproc_per_node=4 train_all.py
for details, see test.sh
sh test.sh
Use the sh test.sh command to execute the reasoning file (the checkpoint in the google cloud disk will be used, please download it in 5. Challenge's final checkpoints and logits)
run model_ensemble.ipynb
Execute 3. Evaluation to get the logits file required by model_ensemble.ipynb (you can also download it directly from google cloud disk, see 5. Challenge's final checkpoints and logits for details)
It can be downloaded from Google Cloud Disk: https://drive.google.com/file/d/1v9SlsjXXKI5kizg9BTMWfA9faaawAgpv/view?usp=sharing
It can be directly used for model ensemble reasoning.
- Thanks to mindcv for Mindspore implementation.