复现Pixel2Mesh记录

复现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

二、机器选择与环境搭建

机器选择

这个仓库代码用的是tensorflow1python2cuda8,所以机器不能选择太新,太新显卡的机器压根跑不了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的介绍的链接。
  • 如果报No module named **, 尽量使用conda install **, 如果conda install 不能安装,再用pip install

执行demo(图片->mesh)测试

python demo.py --image Data/examples/plane.png

三、代码修改

  1. train.pyos.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' 
    
  2. 其他属于私人项目需要,暂时不表

四、踩坑与收获

  1. 压缩包是子压缩包,必须下载所用的压缩包,才能解压(刚开始,我不知道.001文件是子压缩包,只有.001、.002、.003、.004中的一个是不能解压的,想着省VPN流量,只下载一个压缩包,看一下数据格式,然后自己制作数据集,结果在这上面耗了很久,一度不知道怎么推进)
    在这里插入图片描述- 解压方式:https://blog.csdn.net/m0_67441224/article/details/127987067

  2. 取部分数据跑,或者使用自己的数据集跑,需要修改Pixel2Mesh/Data/test_list.txtPixel2Mesh/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()
    
  3. 很多问题,记得看代码仓库的issues,有用:https://github.com/nywang16/Pixel2Mesh/issues

  4. 错误集锦

五、其他有用的参考

  1. 将Pixel2Mesh代码进一步修改成Tensorflow 2.x版本:https://blog.csdn.net/qq_44554428/article/details/113997167 (比较新的显卡机器,需要修改成Tensorflow 2.x版本的)
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值