CSGNet: Neural Shape parser for Constructive Solid Geometry
This repository contains code accompaning the paper: CSGNet: Neural Shape Parser for Constructive Solid Geometry, CVPR 2018.
Here we only include the code for 2D CSGNet. Code for 3D is available on this repository.
conda env create -f environment.yml -n CSGNet
source activate CSGNet
Synthetic Dataset:
Download the synthetic dataset and CAD Dataset. Pre-trained model is available here. Synthetic dataset is provided in the form of program expressions, instead of rendered images. Images for training, validation and testing are rendered on the fly. The dataset is split in different program lengths.
tar -zxvf synthetic.tar.gz -C data/
CAD Dataset
Dataset is provided in H5Py format.
mv cad.h5 data/cad/
To train, update config_synthetic.yml
with required arguments. Default arguments are already filled. Then run:
python train_synthetic.py
To test, update config_synthetic.yml
with required arguments. Default arguments are already filled. Then run:
# For top-1 testing
python test_synthetic.py
# For beam-search-k testing
python test_synthetic_beamsearch.py
To train a network using RL, fill up configuration in config_cad.yml
or keep the default values and then run:
python train_cad.py
Make sure that you have trained a network used Supervised setting first.
To test the network trained using RL, fill up configuration in config_cad.yml
or keep the default values and then run:
# for top-1 decoding
python test_cad.py
# beam search decoding
python test_cad_beamsearch.py
For post processing optmization of program expressions (visually guided search), set the flag REFINE=True
in the script test_cad_beam_search.py
, although it is little slow. For saving visualization of beam search use SAVE_VIZ=True
To optmize some expressions for cad dataset:
# To optmize program expressions from top-1 prediction
python refine_cad.py path/to/exp/to/optmize/exp.txt path/to/directory/to/save/exp/
Note that the expression files here should only have 3k expressions corresponding to the 3k test examples from the CAD dataset.
To optmize program expressions from top-1 prediction
python refine_cad_beamsearch.py path/to/exp/to/optmize/exp.txt path/to/directory/to/save/exp/
Note that the expression files here should only have 3k x beam_width expressions corresponding to the 3k test examples from the CAD dataset.
To visualize generated expressions (programs), look at the script visualize_expressions.py
@InProceedings{Sharma_2018_CVPR,
author = {Sharma, Gopal and Goyal, Rishabh and Liu, Difan and Kalogerakis, Evangelos and Maji, Subhransu},
title = {CSGNet: Neural Shape Parser for Constructive Solid Geometry},
booktitle = {The IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
month = {June},
year = {2018}
}
To ask questions, please email.