fast-reid复现(windows-cpu)

0.环境 

windows(cpu)
#torch==1.2.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
#torchvision==0.4.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
Cython
yacs
tensorboard
future
termcolor
sklearn
tqdm
opencv-python==4.1.0.25
matplotlib

   torch与torchvision的安装: 

pip install torch==1.2.0+cpu torchvision==0.4.0+cpu -f https://download.pytorch.org/whl/torch_stable.html

   其他的都使用安装:

pip --default-time=500 install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt

1.下载

   参考:https://blog.csdn.net/qq_35975447/article/details/106664593

2.训练

   修改1:

   fast-reid-master\fastreid\data\common.py

prefix = file_path.split('/')[1]
to:
prefix = file_path.split('\\')[1]

fast-reid复现(windows-cpu)_第1张图片

 

    或者一劳永逸的办法:

import platform
sysstr = platform.system()
if (sysstr == "Windows"):
   prefix = file_path.split('\\')[1]
elif (sysstr == "Linux"):
   prefix = file_path.split('/')[1]

 

fast-reid复现(windows-cpu)_第2张图片

 修改2(注释几处地方):

     ./tools/train_net.py

fast-reid复现(windows-cpu)_第3张图片

   .\fastreid\engine\defaults.py 

fast-reid复现(windows-cpu)_第4张图片

   .\fastreid\evaluation\rank.py 

fast-reid复现(windows-cpu)_第5张图片

或者直接不使用cython的修改(issue74):

fast-reid复现(windows-cpu)_第6张图片

 

   训练:

python ./tools/train_net.py --config-file="绝对路径\configs\Market1501\AGW_R50.yml"

eg:
python ./tools/train_net.py --config-file="E:\work\fast-reid-master\configs\Market1501\AGW_R50.yml"

  会因为使用的CPU报一些警告(且训练会比较慢):

         WARNING:root:This caffe2 python run does not have GPU support. Will run in CPU only mode.

fast-reid复现(windows-cpu)_第7张图片

   75次迭代,花了2-3小时~.~还跑的基本款(resnet50)

?[32m[06/12 17:14:23 fastreid.engine.hooks]: ?[0mOverall training speed: 75 iterations in 2:49:15 (135.4069 s / it)

3.可视化(CPU近3小时多)

可以将服务器上或者GPU设备上训练的logs里面的文件复制到windows下,然后进行可视化工作。

修改demo/visualize_result.py

fast-reid复现(windows-cpu)_第8张图片

 

注释\fast-reid-master\fastreid\utils\visualizer.py line69 :

python ./demo/visualize_result.py --config-file "E:\pythonwork\fast-reid-master\configs\Market1501\AGW_R50.yml" --vis-label --dataset-name "Market1501" --output "logs/market1501/agw_R50/agw_market1501_vis" --opts MODEL.WEIGHTS "./logs/market1501/agw_R50/model_final.pth"

fast-reid复现(windows-cpu)_第9张图片

 

你可能感兴趣的:(fast-reid,行人重识别)