当前位置: 代码迷 >> 综合 >> fast-reid复现(windows-cpu)
  详细解决方案

fast-reid复现(windows-cpu)

热度:86   发布时间:2023-10-26 00:59:23.0

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]

 

    或者一劳永逸的办法:

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

 

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

     ./tools/train_net.py

   .\fastreid\engine\defaults.py 

   .\fastreid\evaluation\rank.py 

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

 

   训练:

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.

   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-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"

 

  相关解决方案