[应用相关] 复现STGCN CPU版(ubuntu16.04+pytorch0.4.0+openpose+caffe)

[复制链接]
1482|13
 楼主| 远芳侵古道 发表于 2021-5-21 13:58 | 显示全部楼层 |阅读模式
前提:ubuntu下将python3.5.2设为默认(百度)

一.下载stgcn

(gitbub上fork后导入到gitee快些):  https://gitee.com/chenhongqiong/st-gcn.git

二.开始配置
1.安装pytorch0.4.0:

sudo pip3 install torch==0.4.0 -f https://download.pytorch.org/whl/cup/stable -i https://pypi.tuna.tsinghua.edu.cn/simple

2.openpose pythonAPI

https://blog.csdn.net/weixin_42661709/article/details/104771419

3.下载依赖包:

sudo apt-get install ffmpeg

pip3 install -r requirements.txt

 楼主| 远芳侵古道 发表于 2021-5-21 14:00 | 显示全部楼层
4.安装
  1. cd st-gcn
  2. cd torchlight;
  3. sudo python3 setup.py install;
  4. cd ..
 楼主| 远芳侵古道 发表于 2021-5-21 14:02 | 显示全部楼层
5.下载模型
  1. 法一(相当慢):bash tools/get_models.sh
 楼主| 远芳侵古道 发表于 2021-5-21 14:05 | 显示全部楼层
法二:从别人的网盘下载(https://editor.csdn.net/md/?articleId=105060886)

           pose_iter_440000.caffemodel放到st-gcn/models/pose/coco中

           st_gcn.kinetics.pt等文件  放到 st-gcn/models中
 楼主| 远芳侵古道 发表于 2021-5-21 14:06 | 显示全部楼层
 楼主| 远芳侵古道 发表于 2021-5-21 14:07 | 显示全部楼层
6.运行Demo(配置差可以试个短视频就几帧那种。想跑图片就把.jpg改成.mp4)
  1. python main.py demo [--video ${PATH_TO_VIDEO}] [--openpose ${PATH_TO_OPENPOSE}]
 楼主| 远芳侵古道 发表于 2021-5-21 14:09 | 显示全部楼层
新版STGCN:python3 main.py demo --openpose '/home/chq/openpose/build' --video '/home/chq/st-gcn/resource/media/skateboarding.mp4'

旧版:python3 main.py demo_old --video /home/chq/st-gcn/resource/media/test.mp4 --openpose  /home/chq/openpose/build

旧版默认保存在 ./data/demo_result/下,也可以自己设置保存位置如:--output_dir /home/chq/st-gcn/resource/media_out
 楼主| 远芳侵古道 发表于 2021-5-21 14:10 | 显示全部楼层
第一个图是10秒的视频我跑了两天.....第二个图是改图片后缀了测试的图片 5796060a74ec9d5fff.png
 楼主| 远芳侵古道 发表于 2021-5-21 14:13 | 显示全部楼层
 楼主| 远芳侵古道 发表于 2021-5-21 14:14 | 显示全部楼层
6.解决错误:
1.cpu版的cuda问题 2851060a74f8306396.png
 楼主| 远芳侵古道 发表于 2021-5-21 14:15 | 显示全部楼层
device = torch.device("cuda" if args.cuda else "cpu")。将io.py中103行True修改为False
 楼主| 远芳侵古道 发表于 2021-5-21 14:16 | 显示全部楼层
 楼主| 远芳侵古道 发表于 2021-5-21 14:17 | 显示全部楼层
2.RuntimeError: Error(s) in loading state_dict for Model 7553460a7506c1f63b.png
 楼主| 远芳侵古道 发表于 2021-5-21 14:19 | 显示全部楼层
问题解决:
原因是作者提供(bash tools/get_models.sh)的模型参数—— st_gcn.kinetics.pt 有问题。所以要下载从另外的途径下载可用的文件https://pan.baidu.com/s/1JrfpRqt0uF8AydiJuxANZw#list/path=%2F&parentPath=%2Fsharelink53688367-280314025530152

(password: j4rt )。放到models下后重新测试运行。\
您需要登录后才可以回帖 登录 | 注册

本版积分规则

86

主题

887

帖子

3

粉丝
快速回复 在线客服 返回列表 返回顶部