Fairmot代码复现问题记录(已解决) | 小牛学习日记
Fairmot代码复现问题记录(已解决)
Published in:2023-11-29 | category: R&D
Words: 586 | Reading time: 2min | reading:

最近在学习多目标跟踪的经典文章,顺便记录一下自己复现Fairmot代码时的问题以及解决方案。
贴一下原作的代码

前期准备

创建环境以及依赖项的安装:

1
2
3
4
5
6
conda create -n FairMOT
conda activate FairMOT
conda install pytorch==1.7.0 torchvision==0.8.0 cudatoolkit=10.2 -c pytorch
cd ${FAIRMOT_ROOT}
pip install cython
pip install -r requirements.txt

这里一定要注意自己的cuda版本和pytorch版本的对应
我的cuda版本是10.2,安装的pytorch版本是1.7.0

DNCv2的安装

刚开始的时候我是直接按照原作者给的链接进行安装:

1
2
3
git clone -b pytorch_1.7 https://github.com/ifzhang/DCNv2.git
cd DCNv2
./make.sh

但是在编译时会出现gcc版本不能大于8的提示,在安装了低于版本8的gcc后又会提示找不到gcc:)
以防有人需要还是贴一下如何安装低版本gcc的链接
其实作者提供了pytorch1.7对应的DCNv2的链接
下载好按照步骤完成编译并没有提示gcc版本的问题

demo运行

然后就是下载对应的预训练权重文件根据作者给的指示跑一跑demo:

1
2
cd src
python demo.py mot --load_model ../models/fairmot_dla34.pth --conf_thres 0.4

然而
我下载了这么多的权重文件,其实能用的只有一个
预训练文件

可能是代码更新了,不管使用哪个文件都会报错,而且不少文件的链接已经失效了

1
2
3
4
5
6
7
8
9
10
11
Fix size testing.
training chunk_sizes: [3, 3]
The output will be saved to /home/vip/anaconda3/envs/NXH/FairMOT-master/src/lib/../../exp/mot/default
heads {'hm': 1, 'wh': 4, 'id': 128, 'reg': 2}
2023-11-23 11:12:12 [INFO]: Starting tracking...
Lenth of the video: 1500 frames
Creating model...
=> loading pretrained model ../models/hrnetv2_w18_imagenet_pretrained.pth
loaded ../models/all_hrnet_v2_w18.pth, epoch 60
Drop parameter last_layer.0.weight.If you see this, your model does not fully load the pre-trained weight. Please make sure you have correctly specified --arch xxx or set the correct --num_classes for your own dataset.
Drop parameter last_layer.0.bias.If you see this, your model does not fully load the pre-trained weight. Please make sure you have correctly specified --arch xxx or set the correct --num_classes for your own dataset.

上网查了一下,也有人遇到了这个问题,原作者回复了一个新的权重文件
我下载试了一下,没问题,可以跑了,效果非常不错
1
python demo.py mot --load_model ../models/fairmot_hrnet_w18.pth --arch hrnet_18 --reid_dim 128 --conf_thres 0.4

demo
ok下一步的学习计划就是试一试训练。


Fairmot学习

Next:
Hexo本地预览与部署不同的解决方法