Person reid代码记录
reid-strong-baseline
代码地址:https://github.com/michuanhaohao/reid-strong-baseline
服务器地址:/mnt/data/scm/reid/reid-strong-baseline
这个reid的代码有很强的参考性,中间提到了很多的tricks,可以使用到各种新的数据集上
Market1501训练,使用交叉熵损失和三元组损失
# 原始训练代码
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')"
# 我的代码
python tools/train.py --config_file='configs/softmax_triplet_supermicro.yml' MODEL.DEVICE_ID "('0')" DATASETS.NAMES "('market1501')" OUTPUT_DIR "/mnt/data/scm/reid/reid-strong-baseline/logs/mark1501"
id: 8571 0号卡
Duke训练,使用交叉熵损失、三元组损失和centerloss
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')"
python tools/train.py --config_file='configs/softmax_triplet_with_center_supermicro.yml' MODEL.DEVICE_ID "('0')" DATASETS.NAMES "('dukemtmc')" OUTPUT_DIR "('/mnt/data/scm/reid/reid-strong-baseline/logs/duke')"
id: 8316 0号卡
reid代码执行流程
行人重识别的代码训练结束,代码保存在以下目录中
duke: /mnt/data/scm/reid/reid-strong-baseline/logs/duke
market1501:/mnt/data/scm/reid/reid-strong-baseline/logs/mark1501
以下是原文的内容:
You can test your model’s performance directly by running these commands in .sh
files after your custom modification. You can also change the configuration to determine which feature of BNNeck is used and whether the feature is normalized (equivalent to use Cosine distance or Euclidean distance) for testing.
Please replace the data path of the model and set the PRETRAIN_CHOICE
as ‘self’ to avoid time consuming on loading ImageNet pretrained model.
-
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')" MODEL.PRETRAIN_CHOICE "('self')" TEST.WEIGHT "('your path to trained checkpoints')" # 自己的测试代码 CUDA_VISIBLE_DEVICES=1 python tools/test.py --config_file='configs/softmax_triplet_supermicro.yml' MODEL.DEVICE_ID "('0')" DATASETS.NAMES "('market1501')" TEST.NECK_FEAT "('before')" TEST.FEAT_NORM "('no')" MODEL.PRETRAIN_CHOICE "('self')" TEST.WEIGHT "('/mnt/data/scm/reid/reid-strong-baseline/logs/mark1501/resnet50_model_120.pth')" # 虚拟环境 reid python tools/test.py --config_file='configs/softmax_triplet_supermicro.yml' MODEL.DEVICE_ID "('0')" DATASETS.NAMES "('market1501')" TEST.NECK_FEAT "('before')" TEST.FEAT_NORM "('no')" MODEL.PRETRAIN_CHOICE "('self')" TEST.WEIGHT "('/mnt/data/scm/reid/reid-strong-baseline/logs/mark1501/resnet50_optimizer_120.pth')" 成功执行! CUDA_VISIBLE_DEVICES=1 python tools/test.py --config_file='configs/softmax_triplet_supermicro.yml' MODEL.DEVICE_ID "('0')" DATASETS.NAMES "('market1501')" TEST.NECK_FEAT "('before')" TEST.FEAT_NORM "('no')" MODEL.PRETRAIN_CHOICE "('self')" TEST.WEIGHT "('/mnt/data/scm/reid/reid-strong-baseline/logs/mark1501/resnet50_model_120.pth')" CUDA_VISIBLE_DEVICES=1 python tools/test.py --config_file='configs/softmax_triplet_with_center_supermicro.yml' MODEL.DEVICE_ID "('0')" DATASETS.NAMES "('dukemtmc')" TEST.NECK_FEAT "('before')" TEST.FEAT_NORM "('no')" MODEL.PRETRAIN_CHOICE "('self')" TEST.WEIGHT "('/mnt/data/scm/reid/reid-strong-baseline/logs/duke/resnet50_model_120.pth')"
-
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')" MODEL.PRETRAIN_CHOICE "('self')" 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')" MODEL.PRETRAIN_CHOICE "('self')" TEST.RE_RANKING "('yes')" TEST.WEIGHT "('your path to trained checkpoints')"
车辆重识别基线
https://github.com/DTennant/reid_baseline_with_syncbn
代码运行
由于服务器的卡比较少,这里只测试一个GPU下的效果,首先要进行编译,环境还是使用reid
cd evaluate/eval_cylib && make
数据集位置:
https://github.com/PKU-IMRE/VERI-Wild
https://github.com/JDAI-CV/VeRidataset
百度网盘地址