本文主要是介绍opengait代码运行之gaitedge 未完成版,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
文章目录
- 前言
- 一、下载源代码
- 二、配置环境——pycharm,pytorch等
- 1.pycharm虚拟环境设置
- 2.下载相应的包
- 三、下载数据集
- 四、下载模型
- 1.第一种方式
- 2.第二种方式
- 五、开始训练
前言
本次任务为运行opengait代码。主要侧重于gaitedge,需要用到的数据集为CASIA-B。
电脑配置:
windows
带有2个GPU
一、下载源代码
OpenGait页面
点击上方链接后,就进入了github中opengait所在位置
点击绿色按钮,然后点击Download ZIP,下载代码,然后用pycharm打开
二、配置环境——pycharm,pytorch等
1.pycharm虚拟环境设置
注意python版本不能太高,我的是3.6版本
pytorch版本为1.10.2,torchvision版本为0.11.3
2.下载相应的包
conda install tqdm pyyaml tensorboard opencv kornia einops -c conda-forge
conda install pytorch==1.10 torchvision -c pytorch
三、下载数据集
下载地址:
CASIA-B数据集
下载好后,记下数据集存放的路径
然后运行命令:
python datasets/pretreatment.py --input_path CASIA-B --output_path CASIA-B-pkl
即用pretreanment.py文件对数据集进行预处理
注意,–input_path后面为下载好的数据集的存放路径,–output_path后为存放预处理后的数据集的路径,我用的是./dataset/CASIA-B-pkl
这个预处理会调整数据存放的结构
四、下载模型
1.第一种方式
官方给的命令为:
python misc/download_pretrained_model.py
2.第二种方式
如果以上命令行运行失败,还可以用第二种方式,即去到release页面,下载需要的模型。
要下载那些模型,存放到哪里呢?
可以查看misc/download_pretrained_model.py文件:
if __name__ == “__main__”:
urls = [
“https://github.com/ShiqiYu/OpenGait/releases/download/v1.0/pretrained_casiab_model.zip”,
“https://github.com/ShiqiYu/OpenGait/releases/download/v1.1/pretrained_oumvlp_model.zip”,
“https://github.com/ShiqiYu/OpenGait/releases/download/v1.1/pretrained_grew_model.zip”]
for url in urls:
download_file_and_uncompress(
url=url, extrapath=‘output’)
gaitgl_grew = [‘https://github.com/ShiqiYu/OpenGait/releases/download/v1.1/pretrained_grew_gaitgl.zip’,
‘https://github.com/ShiqiYu/OpenGait/releases/download/v1.1/pretrained_grew_gaitgl_bnneck.zip’]
for gaitgl in gaitgl_grew:
download_file_and_uncompress(
url=gaitgl, extrapath=‘output/GREW/GaitGL’)
print(“Pretrained model download success!”)
由此,可以得出,前三个模型要放到output文件夹下,后面两个模型放在output/CREW/GaitGL文件夹下
五、开始训练
官方给的命令为:
CUDA_VISIBLE_DEVICES=0,1 python -m torch.distributed.launch --nproc_per_node=2 opengait/main.py --cfgs ./configs/baseline/baseline.yaml --phase train
由于分布式训练会报错(目前还未解决),所以去掉了CUDA_VISIBLE_DEVICES=0,1 等分布式训练部分
由于launch过时,所以改为了run:
python -m torch.distributed.run opengait/main.py --cfgs ./configs/gaitedge/phase1_rec.yaml --phase train --log_to_file
注意,配置文件要改为自己要训练的模型的配置文件,这里运行gaitedge第一个配置文件,所以路径为: ./configs/gaitedge/phase1_rec.yaml
–log_to_file 表示需要记录日志
运行结果可以在tensorboard中查看,用tensorboard打开output/CASIA-B/GaitGL/GaitGL/summary里的文件即可
但是运行速度太慢,一个小时左右只运行了5000轮,而总共需要80000轮
这篇关于opengait代码运行之gaitedge 未完成版的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!