复现Pixel2Mesh记录
一、相关链接
代码仓库:https://github.com/nywang16/Pixel2Mesh
论文链接:https://openaccess.thecvf.com/content_ECCV_2018/papers/Nanyang_Wang_Pixel2Mesh_Generating_3D_ECCV_2018_paper.pdf
数据集下载地址:https://drive.google.com/drive/folders/131dH36qXCabym1JjSmEpSQZg4dmZVQid
二、机器选择与环境搭建
机器选择
这个仓库代码用的是tensorflow1、python2、cuda8,所以机器不能选择太新,太新显卡的机器压根跑不了cuda8的代码,我最终选择的是GTX 1080 Ti(可租服务器,这是我使用的平台:https://www.autodl.com/register?code=526691b4-f436-47ab-8e8f-41a3bffc761b)
环境搭建
conda create -n pixel2mesh_py2 python=2.7
conda activate pixel2mesh_py2
conda install tensorflow
pip install scikit-image
pip install tflearn
pip install --upgrade pip
pip install tflearn
conda install tensorlfow-gpu
中间报错,进行了一次包的重新安装,最终各个安装包(好多包是依赖,是自动安装的)的版本如下:
(pixel2mesh_py2) root@container-88b1118cac-3ec82b22:~# conda list
# packages in environment at /root/miniconda3/envs/pixel2mesh_py2:
#
# Name Version Build Channel
_libgcc_mutex 0.1 main https://mirrors.ustc.edu.cn/anaconda/pkgs/main
_openmp_mutex 5.1 1_gnu https://mirrors.ustc.edu.cn/anaconda/pkgs/main
backports 1.1 pyhd3eb1b0_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
backports-functools-lru-cache 1.6.4 pypi_0 pypi
backports.weakref 1.0rc1 py27_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
blas 1.0 openblas https://mirrors.ustc.edu.cn/anaconda/pkgs/main
bleach 1.5.0 py27_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
ca-certificates 2022.10.11 h06a4308_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
cairo 1.14.8 0 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
certifi 2020.6.20 pyhd3eb1b0_3 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
cloudpickle 1.3.0 pypi_0 pypi
cudatoolkit 8.0 3 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
cudnn 6.0.21 cuda8.0_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
cycler 0.10.0 pypi_0 pypi
dbus 1.13.18 hb2f20db_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
decorator 4.4.2 pypi_0 pypi
expat 2.4.9 h6a678d5_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
fontconfig 2.12.1 3 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
freetype 2.5.5 2 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
funcsigs 1.0.2 py27_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
functools32 3.2.3.2 py27_1 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
futures 3.3.0 py27_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
glib 2.69.1 he621ea3_2 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
gst-plugins-base 1.14.0 h8213a91_2 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
gstreamer 1.14.0 h28cd5cc_2 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
h5py 2.7.0 np113py27_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
hdf5 1.8.17 2 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
html5lib 0.9999999 py27_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
icu 54.1 0 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
jbig 2.1 hdba287a_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
jpeg 9e h7f8727e_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
kiwisolver 1.1.0 pypi_0 pypi
libffi 3.4.2 h6a678d5_6 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
libgcc 7.2.0 h69d50b8_2 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
libgcc-ng 11.2.0 h1234567_1 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
libgfortran 3.0.0 1 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
libgomp 11.2.0 h1234567_1 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
libiconv 1.14 0 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
libpng 1.6.37 hbc83047_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
libprotobuf 3.11.2 hd408876_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
libstdcxx-ng 11.2.0 h1234567_1 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
libtiff 4.0.6 3 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
libxcb 1.15 h7f8727e_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
libxml2 2.9.4 0 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
markdown 3.1.1 py27_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
matplotlib 2.2.5 pypi_0 pypi
mock 3.0.5 py27_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
ncurses 6.3 h5eee18b_3 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
networkx 2.2 pypi_0 pypi
nomkl 3.0 0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
numexpr 2.6.2 np113py27_nomkl_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
numpy 1.13.1 py27_nomkl_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
olefile 0.46 py27_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
openblas 0.2.19 0 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
openssl 1.0.2u h7b6447c_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
pcre 8.45 h295c915_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
pillow 6.2.2 pypi_0 pypi
pip 20.3.4 pypi_0 pypi
pixman 0.34.0 0 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
protobuf 3.11.2 py27he6710b0_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
pycairo 1.10.0 py27_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
pyparsing 2.4.7 pypi_0 pypi
pyqt 5.6.0 py27_2 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
python 2.7.18 h42bf7aa_3 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
python-dateutil 2.8.2 pyhd3eb1b0_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
pytz 2022.6 pypi_0 pypi
pywavelets 1.0.3 pypi_0 pypi
qt 5.6.2 5 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
readline 8.2 h5eee18b_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
scikit-image 0.14.5 pypi_0 pypi
scikit-learn 0.19.0 np113py27_nomkl_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
scipy 1.2.3 pypi_0 pypi
setuptools 44.0.0 py27_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
sip 4.18 py27_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
six 1.16.0 pyhd3eb1b0_1 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
sqlite 3.40.0 h5082296_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
subprocess32 3.5.4 py27h7b6447c_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
tensorflow 1.3.0 0 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
tensorflow-base 1.3.0 py27h0dbb4d0_1 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
tensorflow-gpu 1.3.0 0 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
tensorflow-gpu-base 1.3.0 py27cuda8.0cudnn6.0_1 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
tensorflow-tensorboard 1.5.1 py27hf484d3e_1 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
tflearn 0.3.2 pypi_0 pypi
tk 8.6.12 h1ccaba5_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
werkzeug 1.0.1 pyhd3eb1b0_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
wheel 0.37.1 pyhd3eb1b0_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
xz 5.2.8 h5eee18b_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
zlib 1.2.13 h5eee18b_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
注意:
- tflearn这个包的版本要担心,太高会报这种错误
ImportError: No module named compat.v1
,我一开始很奇怪,为什么tensorflow1的环境和代码会报tensorflow2的环境运行tensorflow1代码的修改错误,我之前跑的几个项目也是这个原因报错的,卡住了很久,超级影响心态。这个的原因是tflearn太高,pip自动安装的是0.5.0
的,你需要改成0.3.2
的:pip install tflearn=0.3.2
。以下是对我有启发的关于tflearn的介绍的链接。- https://blog.csdn.net/huaxie3355/article/details/62427116 :这直接使用源码配置;scipy是必备的软件,但需要安装在python2下(在3下安装不成功,且示例也不能成功运行)——这句话让我放弃了将Pixel2Mesh代码进一步修改成Tensorflow 2.x版本
- https://blog.csdn.net/u011537121/article/details/80032474:TensorFlow与tflearn版本匹配问题
- 如果报No module named **, 尽量使用conda install **, 如果
conda install
不能安装,再用pip install
执行demo(图片->mesh)测试
python demo.py --image Data/examples/plane.png
三、代码修改
train.py
中os.environ['CUDA_VISIBLE_DEVICES'] = '1'
修改为os.environ['CUDA_VISIBLE_DEVICES'] = '0'
,不然可能会报以下错误,此错误的解释原因:https://blog.csdn.net/joyceya/article/details/104379697#可能的错误 # issues:<https://github.com/nywang16/Pixel2Mesh/issues>有说是需要装tensorflow-gpu ,但是我已经装了,还是报以下错误 failed call to cuInit: CUDA_ERROR_NO_DEVICE InvalidArgumentError (see above for traceback): indices[0,7] = -1 is not in [0, 157) # 此错误可能的原因 #1. 没装tensorflow-gp:<https://github.com/nywang16/Pixel2Mesh/issues/39>;<https://github.com/nywang16/Pixel2Mesh/issues/23> #2. 数据与标签尺寸对不上:<https://stackoverflow.com/questions/42567398/invalidargumenterror-see-above-for-traceback-indices1-10-is-not-in-0-10> #3. os.environ['CUDA_VISIBLE_DEVICES'] = '1'
- 其他属于私人项目需要,暂时不表
四、踩坑与收获
-
压缩包是子压缩包,必须下载所用的压缩包,才能解压(刚开始,我不知道.001文件是子压缩包,只有.001、.002、.003、.004中的一个是不能解压的,想着省VPN流量,只下载一个压缩包,看一下数据格式,然后自己制作数据集,结果在这上面耗了很久,一度不知道怎么推进)
- 解压方式:https://blog.csdn.net/m0_67441224/article/details/127987067
-
取部分数据跑,或者使用自己的数据集跑,需要修改
Pixel2Mesh/Data/test_list.txt
和Pixel2Mesh/Data/train_list.txt
提取部分数据行(针对取部分数据的情况)的代码如下:# 提取测试文件中的 # import re # fp = open("/root/autodl-tmp/Pixel2Mesh/Data/test_list.txt", "r") # sample = fp.readlines() # file = open("/root/autodl-tmp/Pixel2Mesh/Data/test_list1.txt", "w") # for line in sample: ## 对每行进行遍历 # if "Data/ShapeNetP2M/02828884/" in line: ## 利用if条件进行判断 # file.write(line) # fp.close() # file.close() # 提取训练文件中的 import re fp = open("/root/autodl-tmp/Pixel2Mesh/Data/0train_list.txt", "r") sample = fp.readlines() file = open("/root/autodl-tmp/Pixel2Mesh/Data/train_list.txt", "w") for line in sample: ## 对每行进行遍历 if "Data/ShapeNetP2M/02828884/" in line: ## 利用if条件进行判断 file.write(line) fp.close() file.close()
-
很多问题,记得看代码仓库的issues,有用:https://github.com/nywang16/Pixel2Mesh/issues
-
错误集锦
Intel MKL FATAL ERROR: Cannot load libmkl_avx2.so or libmkl_def.so.
:numpy等包安装的有问题(解决办法:https://stackoverflow.com/questions/36659453/intel-mkl-fatal-error-cannot-load-libmkl-avx2-so-or-libmkl-def-so;https://blog.csdn.net/qikaihuting/article/details/103526376;第一条链接解决了我的问题)InvalidArgumentError (see above for traceback): indices[0,7] = -1 is not in [0, 157)
:本文是需要将train.py
中os.environ['CUDA_VISIBLE_DEVICES'] = '1'
修改为os.environ['CUDA_VISIBLE_DEVICES'] = '0'
;也有可能是数据和标签对不上(数据标签对不上的解决办法:https://blog.csdn.net/u011585024/article/details/88938194)。make: Nothing to be done for 'all'.
:清除external/tf_nndistance_g.cu.o
和tf_approxmatch_g.cu.o
(解决方法参考:https://blog.csdn.net/gwzz1228/article/details/34424179)- git clone 项目代码的时候出现
gnutls_handshake() failed
、fatal: unable to access 'https://github.com/...
: 猜测是服务器连的网络池点解析的DNS和我不在一个线路上(来自于涛大佬的见解),换个时间git clone或在把本地git clone好的代码上传服务器。(我尝试过的解决办法(都没有解决):https://blog.csdn.net/dashi_lu/article/details/89641778;https://blog.csdn.net/baidu_36487340/article/details/114586867) No module named core_rnn
: 修改了tflearn的版本,自己好了
五、其他有用的参考
- 将Pixel2Mesh代码进一步修改成Tensorflow 2.x版本:https://blog.csdn.net/qq_44554428/article/details/113997167 (比较新的显卡机器,需要修改成Tensorflow 2.x版本的)