|
||
---|---|---|
config | ||
configs | ||
engine | ||
layers | ||
modeling | ||
solver | ||
tests | ||
tools | ||
utils | ||
.gitignore | ||
Experiment-all_tricks-tri_center-duke.sh | ||
Experiment-all_tricks-tri_center-market.sh | ||
Experiment-all_tricks-without_center-duke.sh | ||
Experiment-all_tricks-without_center-market.sh | ||
LICENCE.md | ||
README.md | ||
Test-all_tricks-tri_center-feat_after_bn-cos-duke.sh | ||
Test-all_tricks-tri_center-feat_after_bn-cos-market.sh | ||
Test-all_tricks-without_center-feat_after_bn-cos-duke.sh | ||
Test-all_tricks-without_center-feat_after_bn-cos-market.sh | ||
Test-reranking-all_tricks-tri_center-feat_after_bn-cos-duke.sh | ||
Test-reranking-all_tricks-tri_center-feat_after_bn-cos-market.sh |
README.md
Bags of Tricks and A Strong ReID Baseline
Paper: The codes are expanded on a ReID-baseline , which is open sourced by our co-author Xingyu Liao.
We support
- easy dataset preparation
- end-to-end training and evaluation
- high modular management
Bag of tricks
- Warm up learning rate
- Random erasing augmentation
- Label smoothing
- Last stride
- BNNeck
- Center loss
Get Started
The designed architecture follows this guide PyTorch-Project-Template, you can check each folder's purpose by yourself.
-
cd
to folder where you want to download this repo -
Run
git clone...
-
Install dependencies:
- pytorch 1.0
- torchvision
- ignite
- yacs
-
Prepare dataset
Create a directory to store reid datasets under this repo via
cd reid_baseline mkdir data
(1)Market1501
- Download dataset to
data/
from http://www.liangzheng.org/Project/project_reid.html - Extract dataset and rename to
market1501
. The data structure would like:
data market1501 # this folder contains 6 files. bounding_box_test/ bounding_box_train/ ......
(2)DukeMTMC-reID
- Download dataset to
data/
from https://github.com/layumi/DukeMTMC-reID_evaluation#download-dataset - Extract dataset and rename to
dukemtmc-reid
. The data structure would like:
data dukemtmc-reid DukeMTMC-reID # this folder contains 8 files. bounding_box_test/ bounding_box_train/ ......
- Download dataset to
-
Prepare pretrained model if you don't have
from torchvision import models models.resnet50(pretrained=True)
Then it will automatically download model in
~/.torch/models/
, you should set this path inconfig/defaults.py
for all training or set in every single training config file inconfigs/
. -
If you want to know the detained configurations and their meaning, please refer to
config/defaults.py
. If you want to set your own parameters, you can follow our method: create a new yml file, then set your own parameters. Add--config_file='configs/your yml file'
int the commands described below, then our code will merge your configuration. automatically.
Train
You can run these commands in .sh
files for training different datasets of differernt loss. You can also directly run code sh *.sh
to run our demo.
- Market1501, cross entropy loss + triplet loss
python3 tools/train.py --config_file='configs/softmax_triplet.yml' MODEL.DEVICE_ID "('your device id')" DATASETS.NAMES "('market1501')" OUTPUT_DIR "('your path to save checkpoints and logs')"
- DukeMTMC-reID, cross entropy loss + triplet loss + center loss
python3 tools/train.py --config_file='configs/softmax_triplet_with_center.yml' MODEL.DEVICE_ID "('your device id')" DATASETS.NAMES "('dukemtmc')" OUTPUT_DIR "('your path to save checkpoints and logs')"
Test
You can test your model's performance directly by running these commands in .sh
files. You can also change the configuration to determine which feature of BNNeck and whether the feature is normalized (equivalent to use Cosine distance or Euclidean distance) for testing.
- Test with Euclidean distance using feature before BN without re-ranking,.
python3 tools/test.py --config_file='configs/softmax_triplet_with_center.yml' MODEL.DEVICE_ID "('your device id')" DATASETS.NAMES "('market1501')" TEST.NECK_FEAT "('before')" TEST.FEAT_NORM "('no')" TEST.WEIGHT "('your path to trained checkpoints')"
- Test with Cosine distance using feature after BN without re-ranking,.
python3 tools/test.py --config_file='configs/softmax_triplet_with_center.yml' MODEL.DEVICE_ID "('your device id')" DATASETS.NAMES "('market1501')" TEST.NECK_FEAT "('after')" TEST.FEAT_NORM "('yes')" TEST.WEIGHT "('your path to trained checkpoints')"
- Test with Cosine distance using feature after BN with re-ranking
python3 tools/test.py --config_file='configs/softmax_triplet_with_center.yml' MODEL.DEVICE_ID "('your device id')" DATASETS.NAMES "('dukemtmc')" TEST.NECK_FEAT "('after')" TEST.FEAT_NORM "('yes')" TEST.RE_RANKING "('yes')" TEST.WEIGHT "('your path to trained checkpoints')"
Results
Network architecture