This repository contains the TensorFlow implementation for the following paper
Pixel2Mesh: Generating 3D Mesh Models from Single RGB Images (ECCV2018)
Nanyang Wang, Yinda Zhang, Zhuwen Li, Yanwei Fu, Wei Liu, Yu-Gang Jiang.
Note: This is a fork of nywang16/Pixel2Mesh with work-in-progress changes. See Fork status below, and
CLAUDE.mdfor an architecture overview and current caveats.
This fork is migrating the original Python 2.7 + TensorFlow 1.x code toward Python 3 / TensorFlow 2 (via tensorflow.compat.v1). The migration is in progress, so the tree is currently in a mixed state:
- The entry scripts (
train.py,eval_testset.py,demo.py) now importtensorflow.compat.v1; the modules underp2m/have not all been ported yet. demo.pyhas been adapted to batch-process a directory of images rather than the single--imageflow described below.- Known gaps:
eval_testset.pyreferencesp2m.cd_distwhile the working module isp2m/chamfer.py; some modules still use Python-2-only constructs (cPickle,Queue,printstatements).
Refer to CLAUDE.md for the full architecture and the up-to-date list of caveats. Everything below this section is the original upstream README.
If you use this code for your research, please consider citing:
@inProceedings{wang2018pixel2mesh,
title={Pixel2Mesh: Generating 3D Mesh Models from Single RGB Images},
author={Nanyang Wang and Yinda Zhang and Zhuwen Li and Yanwei Fu and Wei Liu and Yu-Gang Jiang},
booktitle={ECCV},
year={2018}
}
Installing all the dependencies might be tricky and you need a computer with a CUDA enabled GPU. To get started fast you can just try this demo developed by Mathias Gatti using Google Colab.
The project page is available at https://nywang16.github.io/p2m/index.html
Requirements:
- Python2.7+ with Numpy and scikit-image
- Tensorflow (version 1.0+)
- TFLearn
Our code has been tested with Python 2.7, TensorFlow 1.3.0, TFLearn 0.3.2, CUDA 8.0 on Ubuntu 14.04.
- Nov. 8, we update the script for generate auxiliary data.
git clone https://github.com/nywang16/Pixel2Mesh.git
cd Data/
Download the pre-trained model and unzip to the Data/ folder.
unzip checkpoint.zip
python demo.py --image Data/examples/plane.png
Run the demo code and the output mesh file is saved in Data/examples/plane.obj
If you use CD and EMD for training or evaluation, we have included the cuda implementations of Fan et. al. in external/
cd Pixel2Mesh/external/
Modify the first 3 lines of the makefile to point to your nvcc, cudalib and tensorflow library.
make
We used the ShapeNet dataset for 3D models, and rendered views from 3D-R2N2:
When using the provided data make sure to respect the shapenet license.
Below is the complete set of training data. Download it into the Data/ folder.
https://drive.google.com/open?id=131dH36qXCabym1JjSmEpSQZg4dmZVQid
The training/testing split can be found in Data/train_list.txt and Data/test_list.txt
Each .dat file in the provided data contain:
- The sampled point cloud (with vertex normal) from ShapeNet. We transformed it to corresponding coordinates in camera coordinate based on camera parameters from the Rendering Dataset.
Input image, ground truth point cloud.
![]()
python train.py
You can change the training data, learning rate and other parameters by editing train.py
The total number of training epoch is 30; the learning rate is initialized as 3e-5 and drops to 1e-5 after 25 epochs.
The evaluation code was released, please refer to eval_testset.py for more details.
Notice that the 3D shape are downscaled by a factor of 0.57 to generate rendering. As result, all the numbers shown in experiments used 0.57xRaw Shape for evaluation. This scale may be related to the render proccess, we used the rendering data from 3DR2N2 paper, and this scale was there since then for reason that we don't know.
This software is for research purpose only.
Please contact us for the licence of commercial purposes. All rights are preserved.
Nanyang Wang (nywang16 AT fudan.edu.cn)
Yinda Zhang (yindaz AT cs.princeton.edu)
Zhuwen Li (lzhuwen AT gmail.com)
Yanwei Fu (yanweifu AT fudan.edu.cn)
Yu-Gang Jiang (ygj AT fudan.edu.cn)
Apache License version 2.0