Run joint_learning_retrieval_deformation
CVPR21_Joint Learning of 3D Shape Retrieval and Deformation
因为evaluation的部分,我run的时候发现出现了dimension不匹配的问题,就想着自己重新训练一下模型,看一下是什么情况,以下是训练过程中的一些步骤
1. 克隆仓库
git clone https://github.com/mikacuy/joint_learning_retrieval_deformation
2. 安装环境
mv joint_learning_retrieval_deformation jlrd
cd jlrd
conda env create -f environment.yml
但是因为我在执行第二条命令时总是报错,我的目的是运行Training-IDO (Ours),遇到什么就安装什么吧
3. 安装所需包
pip install numpy==1.18.5
pip install h5py==2.10.0
pip install torch==1.5.1 torchvision torchaudio
pip install trimesh==3.7.7
# 下边一步是回到code的上一个文件夹下载pytorch3d v0.2.0
cd ..
wget https://github.com/facebookresearch/pytorch3d/archive/refs/tags/v0.2.0.tar.gz
tar -zxvf v0.2.0.tar.gz && rm v0.2.0.tar.gz
cd pytorch3d-0.2.0
# 因为我预先缺少g++环境,所以用下面的命令安装一下
apt-get install build-essential
pip install -e .
4. 从项目主页下载所需要的文件
相关包下载完毕后,就需要从项目主页下载一些文件,这里提示我们需要下载generated_datasplits/chair_500.pickle。
反观项目主页,pickle文件下载链接如下图所示:
# 回到code和pytorch3d的上一层文件夹并创建datasets,将数据下至datasets文件夹中
cd .. && mkdir datasets && cd datasets
wget http://download.cs.stanford.edu/orion/joint_embedding_deformation/generated_datasplits.tar
tar -zxvf generated_datasplits.tar
展开后可知,我们所需的文件在/orion/u/mikacuy/part_deform/generated_datasplits/
下
先回到code、pytorch3d、datasets的上一层文件夹
随后将generated_datasplits
移动到代码文件夹中:
mkdir jlrd/generated_datasplits
mv datasets/orion/u/mikacuy/part_deform/generated_datasplits/ jlrd/ && rm datasets/generated_datasplits.tar
cd jlrd
# 继续run code
python train_region_final.py --logdir=log/ --dump_dir=dump/ --to_train=1 --init_deformation=1 --loss_function=regression --distance_function=mahalanobis --use_connectivity=1 --use_src_encoder_retrieval=1 --category=chair --model_init=df_chair_pc/ --selection=retrieval_candidates --use_keypoint=1 --use_symmetry=1
接下来报
5. 解决一些报错
去代码里看对应的行,发现是DATA_SPLIT没指定,我根据红框内的结果设置DATA_SPLIT为“train”
接着根据filename的路径(改完代码后跑一跑会发现提示“(unable to open file: name = '/home/xx/codes/jlrd/data_aabb_constraints_keypoint/chair/h5/43617_leaves.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)
”),发现我们还缺少训练数据,就去github上下载:
复制目标链接,通过命令下载:
cd ../datasets
wget http://download.cs.stanford.edu/orion/joint_embedding_deformation/data_aabb_constraints_keypoint.tar
按我这里的网速大概要下24h(110k+/s)左右,如果是用的付费服务器,还是直接在电脑上下下来(可能爬梯子会更快一些),然后通过类似Xftp的工具传上去,可能会比较快。
但是我这里用的是学校的服务器,所以就不管了,放着让它下载即可。
结果最后大概是下载了6h的样子:
解压:
tar -zxvf data_aabb_constraints_keypoint.tar
这里会报一个错:gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not recoverable: exiting now
那么我们将命令修改成:
tar -xvf data_aabb_constraints_keypoint.tar
即可。
因为上边我们知道报错的原因是因为找不到jlrd/data_aabb_constraints_keypoint/chair/h5/43617_leaves.h5
,先观察一下大致的目录结构:
我们需要将该目录及目录下所有文件夹转移到/jlrd
下
cd ..
mv /home/xx/codes/datasets/orion/u/mikacuy/part_deform/data_aabb_constraints_keypoint/ jlrd/
rm -rf datasets/orion
# 继续试着运行代码
python train_region_final.py --logdir=log/ --dump_dir=dump/ --to_train=1 --init_deformation=1 --loss_function=regression --distance_function=mahalanobis --use_connectivity=1 --use_src_encoder_retrieval=1 --category=chair --model_init=df_chair_pc/ --selection=retrieval_candidates --use_keypoint=1 --use_symmetry=1
此时又提示:
这应该是我们还有没有下载的东西
于是:
cd datasets
wget http://download.cs.stanford.edu/orion/joint_embedding_deformation/pretrained_models.tar
tar -zxvf pretrained_models.tar
解压后可以看到里面的文件内容:
因为我们只需要df_chair_pc,所以将df_chair_pc移去jlrd/
下就可以了
cd ..
mv datasets/pretrained_models/df_chair_pc/ jlrd/
cd jlrd
# 继续试着运行代码
python train_region_final.py --logdir=log/ --dump_dir=dump/ --to_train=1 --init_deformation=1 --loss_function=regression --distance_function=mahalanobis --use_connectivity=1 --use_src_encoder_retrieval=1 --category=chair --model_init=df_chair_pc/ --selection=retrieval_candidates --use_keypoint=1 --use_symmetry=1
这时候报错:RuntimeError: cuda runtime error (803) : system has unsupported display driver / cuda driver combination at /pytorch/aten/src/THC/THCGeneral.cpp:47
一拍脑袋,发现没安装cuda啊……
到https://developer.nvidia.com/cuda-11-4-0-download-archive?target_os=Linux&target_arch=x86_64&Distribution=Ubuntu&target_version=20.04&target_type=runfile_local中参照着Base Installer进行安装。
详见:ubuntu20.04安装cuda库
因为安装了高版本的cuda,原本的pytorch库就不匹配了
这里可以不用这个博主给的环境变量配置,用下边的:
export CUDA_HOME=/usr/local/cuda
export PATH="$CUDA_HOME/bin:$PATH"
export LD_LIBRARY_PATH="$CUDA_HOME/lib64:$LD_LIBRARY_PATH"
然后建立一个软链接(CUDA的版本就写你下载的版本)
sudo ln -s /usr/local/cuda-10.2 /usr/local/cuda
就可以了。
这里如果pytorch3d用不了的话,在安装好CUDA后再重新按之前的步骤安装一遍就好了。
pytorch也是同理的,用不了就重新安装
6、训练过程展示
7、进行evaluate
按照项目主页所说的,我们需要进行render的安装才能够进行evaluate。
wget https://github.com/mhsung/libigl-renderer
接着按上边的wget去走一遍就可以了。
修改data_utils.py里的Render路径:
修改evaluate.py里的model.pth路径至训练结果的model:
8、一些result的展示