This repository contains code to reproduce the best results for this paper: zhirui, Animal Recognition Using Method of Fine-Grained Visual Analysis.
The best model achieved score one dev-hard-lost:
model | recall@1 | recall@10 | hit1_n90%@top0.1 | hit10_n90%@top0.1 |
---|---|---|---|---|
head_swin_bnneck | 0.3229 | 0.6021 | 0.0 | 0.0282 |
head_swin_bnneck w/ trick | 0.3177 | 0.6016 | 0.3474 | 0.2018 |
Need python version 3.8 or later, linux OS, PyTorch==1.11.0 with cuda, install libararies list in requirements.txt.
git clone [email protected]:LostPetInitiative/study_spring_2022.git
cd study_spring_2022
cd zhirui
pip install -r requirements.txt
# in zhirui folder
bash download.sh
Go to kaggle dataset page, download all 4 file one by one.
- unzip head_swin_bnneck.zip to ./download
- unzip data_25.zip to ./download
- unzip dev.zip to ./download
- move yolov5s.pt to ./download
After that, the download folder shuold like this:
download/
├── data_25
├────── rf100199
├────── ...
├── dev
├────── found
├────── lost
├────── registry.csv
├── head_swin_bnneck
├────── cfg.yaml
├────── last.ckpt
├────── model.ckpt
├── placeholder
└── yolov5s.pt
# in zhirui folder
# crop data_25 and dev images
# It will take some time to do it
python crop_image.py
# extract train/val data from data_25/body/head for model training
# It will take some time to do it
python train_data_split.py --data_dir ./download/data_25
python train_data_split.py --data_dir ./download/data_25_body
python train_data_split.py --data_dir ./download/data_25_head
Best model (head swin bnneck) trained on head crop dataset, so be care input the head crop dataset.
# in zhirui folder
python test.py --data_dir ./download/dev_head --save_dir ./download/reproduc --model ./download/head_swin_bnneck
Use threshold filter fake image for better hit metric.
# in zhirui folder
python test.py --data_dir ./download/dev_head --save_dir ./download/reproduc_trick --model ./download/head_swin_bnneck --filt 0.74
Modify config file in config
folder first.
# in zhirui folder
python train.py --config ./config/your_config_file.yml --device 0