源代码链接:https://github.com/microsoft/singleshotpose
目录
github仓库所使用的系统为windows。
(The code is tested on Windows with CUDA v8 and cudNN v5.1. The implementation is based on PyTorch 0.4.1 and tested on Python3.6.)
ubuntu下的操作基本相同,srds还是记录一下。
系统版本:ubuntu20.04
gpu:2060(12g)
cuda版本:11.7
1、下载代码
git clone https://github.com/microsoft/singleshotpose.git
2、配置环境
与densefusion基本相同,只是额外下载了scipy1.2.1和pillow
pip install scipy==1.2.1 pillow
其他python库详情可看:【未完全解决】【复现笔记】DenseFusion_densefusion复现 typeerror: load() missing 1 required-CSDN博客
具体环境配置版本如下:
(densefusion) r***@r***-MS-*****:~/**********/singleshotpose$ pip list
Package Version
--------------------- ------------
argon2-cffi 21.3.0
argon2-cffi-bindings 21.2.0
async-generator 1.10
attrs 22.2.0
backcall 0.2.0
bleach 4.1.0
certifi 2021.5.30
cffi 1.15.1
comm 0.1.4
cycler 0.11.0
Cython 0.19
dataclasses 0.8
decorator 4.4.2
defusedxml 0.7.1
entrypoints 0.4
future 0.18.3
imageio 2.15.0
importlib-metadata 4.8.3
importlib-resources 5.4.0
ipykernel 5.5.6
ipython 7.16.3
ipython-genutils 0.2.0
ipywidgets 7.8.1
jedi 0.17.2
Jinja2 3.0.3
joblib 1.1.1
jsonschema 3.2.0
jupyter-client 7.1.2
jupyter-core 4.9.2
jupyterlab-pygments 0.1.2
jupyterlab-widgets 1.1.7
kiwisolver 1.3.1
knn-pytorch 0.1
MarkupSafe 2.0.1
matplotlib 3.3.4
mistune 0.8.4
mkl-fft 1.3.0
mkl-random 1.1.1
mkl-service 2.3.0
nbclient 0.5.9
nbconvert 6.0.7
nbformat 5.1.3
nest-asyncio 1.6.0
networkx 2.5.1
notebook 6.4.10
numpy 1.19.5
olefile 0.46
open3d 0.9.0.0
opencv-contrib-python 3.3.0.10
opencv-python 3.3.0.10
packaging 21.3
pandocfilters 1.5.1
parso 0.7.1
pexpect 4.9.0
pickleshare 0.7.5
Pillow 8.4.0
pip 21.2.2
prometheus-client 0.17.1
prompt-toolkit 3.0.36
ptyprocess 0.7.0
pycparser 2.21
Pygments 2.14.0
pykdtree 1.3.4
pyparsing 3.0.7
pypng 0.20220715.0
pyrsistent 0.18.0
python-dateutil 2.8.2
PyWavelets 1.1.1
PyYAML 5.4.1
pyzmq 25.1.2
scikit-image 0.17.2
scikit-learn 0.24.2
scipy 1.2.1
Send2Trash 1.8.2
setuptools 58.0.4
six 1.16.0
terminado 0.12.1
testpath 0.6.0
threadpoolctl 3.1.0
tifffile 2020.9.3
torch 1.6.0
torchvision 0.7.0
tornado 6.1
tqdm 4.64.1
traitlets 4.3.3
trimesh 2.38.24
typing_extensions 4.1.1
wcwidth 0.2.13
webencodings 0.5.1
wheel 0.37.1
widgetsnbextension 3.6.6
zipp 3.6.0
3、下载数据集
wget -O LINEMOD.tar --no-check-certificate "https://onedrive.live.com/download?cid=05750EBEE1537631&resid=5750EBEE1537631%21135&authkey=AJRHFmZbcjXxTmI"
wget -O backup.tar --no-check-certificate "https://onedrive.live.com/download?cid=0C78B7DE6C569D7B&resid=C78B7DE6C569D7B%21191&authkey=AP183o4PlczZR78"
wget -O multi_obj_pose_estimation/backup_multi.tar --no-check-certificate "https://onedrive.live.com/download?cid=05750EBEE1537631&resid=5750EBEE1537631%21136&authkey=AFQv01OSbvhGnoM"
wget https://pjreddie.com/media/files/VOCtrainval_11-May-2012.tar
wget https://pjreddie.com/media/files/darknet19_448.conv.23 -P cfg/
tar xf LINEMOD.tar
tar xf backup.tar
tar xf multi_obj_pose_estimation/backup_multi.tar -C multi_obj_pose_estimation/
tar xf VOCtrainval_11-May-2012.tar
部分数据集过期,该博主有备份,感谢:ubuntu18.04下复现 singleshotpose(yolo-6D) 源代码复现_yolo6d复现-CSDN博客
解压后如下(打码是我自己添加的文件,非github仓库自带内容,backup压缩包过大,只取了我自己需要的物体)
4、训练
(1)单个物体
python train.py --datacfg [path_to_data_config_file] --modelcfg [path_to_model_config_file] --initweightfile [path_to_initialization_weights] --pretrain_num_epochs [number_of_epochs to pretrain]
如
#start from darknet
python train.py --datacfg cfg/ape.data --modelcfg cfg/yolo-pose.cfg --initweightfile cfg/darknet19_448.conv.23 --pretrain_num_epochs 15
#start from ImageNet initialized weights
python train.py --datacfg cfg/ape.data --modelcfg cfg/yolo-pose.cfg --initweightfile backup/duck/init.weights
(2)多个物体
python valid_multi.py cfgfile weightfile
python train_multi.py datafile cfgfile weightfile
如
python valid_multi.py cfg/yolo-pose-multi.cfg backup_multi/model_backup.weights
python train_multi.py cfg/occlusion.data cfg/yolo-pose-multi.cfg backup_multi/init.weights
5、测试
(1)单个物体:
python valid.py --datacfg [path_to_data_config_file] --modelcfg [path_to_model_config_file] --weightfile [path_to_trained_model_weights]
如
python valid.py --datacfg cfg/ape.data --modelcfg cfg/yolo-pose.cfg --weightfile backup/ape/model_backup.weights
(2)多个物体
python valid_multi.py cfgfile weightfile
如
python train_multi.py cfg/occlusion.data cfg/yolo-pose-multi.cfg backup_multi/init.weights
6、结果可视化并保存
作者提供了可视化代码valid.ipynb。不希望用jupyter,故将其转为py文件:
jupyter nbconvert --to script valid.ipynb --output visualize1.py
运行:
ipython visualize1.py
这里标出可视化代码部分:
上图加入了保存为png图片的部分,可据图片手动修改。visualize1.py代码文件可由以下链接下载
https://download.csdn.net/download/weixin_54470372/89219222