[ECCV'20] Convolutional Occupancy Networks

Overview

Convolutional Occupancy Networks

Paper | Supplementary | Video | Teaser Video | Project Page | Blog Post

This repository contains the implementation of the paper:

Convolutional Occupancy Networks
Songyou Peng, Michael Niemeyer, Lars Mescheder, Marc Pollefeys and Andreas Geiger
ECCV 2020 (spotlight)

If you find our code or paper useful, please consider citing

@inproceedings{Peng2020ECCV,
 author =  {Songyou Peng, Michael Niemeyer, Lars Mescheder, Marc Pollefeys, Andreas Geiger},
 title = {Convolutional Occupancy Networks},
 booktitle = {European Conference on Computer Vision (ECCV)},
 year = {2020}}

Contact Songyou Peng for questions, comments and reporting bugs.

Installation

First you have to make sure that you have all dependencies in place. The simplest way to do so, is to use anaconda.

You can create an anaconda environment called conv_onet using

conda env create -f environment.yaml
conda activate conv_onet

Note: you might need to install torch-scatter mannually following the official instruction:

pip install torch-scatter==2.0.4 -f https://pytorch-geometric.com/whl/torch-1.4.0+cu101.html

Next, compile the extension modules. You can do this via

python setup.py build_ext --inplace

Demo

First, run the script to get the demo data:

bash scripts/download_demo_data.sh

Reconstruct Large-Scale Matterport3D Scene

You can now quickly test our code on the real-world scene shown in the teaser. To this end, simply run:

python generate.py configs/pointcloud_crop/demo_matterport.yaml

This script should create a folder out/demo_matterport/generation where the output meshes and input point cloud are stored.

Note: This experiment corresponds to our fully convolutional model, which we train only on the small crops from our synthetic room dataset. This model can be directly applied to large-scale real-world scenes with real units and generate meshes in a sliding-window manner, as shown in the teaser. More details can be found in section 6 of our supplementary material. For training, you can use the script pointcloud_crop/room_grid64.yaml.

Reconstruct Synthetic Indoor Scene

You can also test on our synthetic room dataset by running:

python generate.py configs/pointcloud/demo_syn_room.yaml

Dataset

To evaluate a pretrained model or train a new model from scratch, you have to obtain the respective dataset. In this paper, we consider 4 different datasets:

ShapeNet

You can download the dataset (73.4 GB) by running the script from Occupancy Networks. After, you should have the dataset in data/ShapeNet folder.

Synthetic Indoor Scene Dataset

For scene-level reconstruction, we create a synthetic dataset of 5000 scenes with multiple objects from ShapeNet (chair, sofa, lamp, cabinet, table). There are also ground planes and randomly sampled walls.

You can download our preprocessed data (144 GB) using

bash scripts/download_data.sh

This script should download and unpack the data automatically into the data/synthetic_room_dataset folder.
Note: We also provide point-wise semantic labels in the dataset, which might be useful.

Alternatively, you can also preprocess the dataset yourself. To this end, you can:

  • download the ShapeNet dataset as described above.
  • check scripts/dataset_synthetic_room/build_dataset.py, modify the path and run the code.

Matterport3D

Download Matterport3D dataset from the official website. And then, use scripts/dataset_matterport/build_dataset.py to preprocess one of your favorite scenes. Put the processed data into data/Matterport3D_processed folder.

ScanNet

Download ScanNet v2 data from the official ScanNet website. Then, you can preprocess data with: scripts/dataset_scannet/build_dataset.py and put into data/ScanNet folder.
Note: Currently, the preprocess script normalizes ScanNet data to a unit cube for the comparison shown in the paper, but you can easily adapt the code to produce data with real-world metric. You can then use our fully convolutional model to run evaluation in a sliding-window manner.

Usage

When you have installed all binary dependencies and obtained the preprocessed data, you are ready to run our pre-trained models and train new models from scratch.

Mesh Generation

To generate meshes using a trained model, use

python generate.py CONFIG.yaml

where you replace CONFIG.yaml with the correct config file.

Use a pre-trained model
The easiest way is to use a pre-trained model. You can do this by using one of the config files under the pretrained folders.

For example, for 3D reconstruction from noisy point cloud with our 3-plane model on the synthetic room dataset, you can simply run:

python generate.py configs/pointcloud/pretrained/room_3plane.yaml

The script will automatically download the pretrained model and run the generation. You can find the outputs in the out/.../generation_pretrained folders

Note that the config files are only for generation, not for training new models: when these configs are used for training, the model will be trained from scratch, but during inference our code will still use the pretrained model.

We provide the following pretrained models:

pointcloud/shapenet_1plane.pt
pointcloud/shapenet_3plane.pt
pointcloud/shapenet_grid32.pt
pointcloud/shapenet_3plane_partial.pt
pointcloud/shapenet_pointconv.pt
pointcloud/room_1plane.pt
pointcloud/room_3plane.pt
pointcloud/room_grid32.pt
pointcloud/room_grid64.pt
pointcloud/room_combine.pt
pointcloud/room_pointconv.pt
pointcloud_crop/room_grid64.pt
voxel/voxel_shapenet_1plane.pt
voxel/voxel_shapenet_3plane.pt
voxel/voxel_shapenet_grid32.pt

Evaluation

For evaluation of the models, we provide the script eval_meshes.py. You can run it using:

python eval_meshes.py CONFIG.yaml

The script takes the meshes generated in the previous step and evaluates them using a standardized protocol. The output will be written to .pkl/.csv files in the corresponding generation folder which can be processed using pandas.

Note: We follow previous works to use "use 1/10 times the maximal edge length of the current object’s bounding box as unit 1" (see Section 4 - Metrics). In practice, this means that we multiply the Chamfer-L1 by a factor of 10 for reporting the numbers in the paper.

Training

Finally, to train a new network from scratch, run:

python train.py CONFIG.yaml

For available training options, please take a look at configs/default.yaml.

Further Information

Please also check out the following concurrent works that either tackle similar problems or share similar ideas:

Comments
  • Test pretrained model on custom dataset

    Test pretrained model on custom dataset

    Hi,

    thanks for making this great work available here!

    I would like to test one of the pretrained models on my own dataset.

    However, I am a bit lost in writing a corresponding config file.

    For testing, I simply copied a single points.npz file from ShapeNet to a new folder.

    I wrote the following myConfig.yaml file:

    data: classes: [''] path: /home/raphael/data pointcloud_n: 10000 pointcloud_file: points.npz voxels_file: null points_file: null points_iou_file: null training: out_dir: out/mine test: model_file: https://s3.eu-central-1.amazonaws.com/avg-projects/convolutional_occupancy_networks/models/pointcloud/shapenet_3plane.pt generation: generation_dir: generation

    When running python generate.py config/myConfig.yaml I get the following error:

    cfg_special = yaml.load(f) /home/raphael/remote_python/convolutional_occupancy_networks/src/config.py:33: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details. cfg = yaml.load(f) Traceback (most recent call last): File "generate.py", line 38, in dataset = config.get_dataset('test', cfg, return_idx=True) File "/home/raphael/remote_python/convolutional_occupancy_networks/src/config.py", line 134, in get_dataset inputs_field = get_inputs_field(mode, cfg) File "/home/raphael/remote_python/convolutional_occupancy_networks/src/config.py", line 202, in get_inputs_field 'Invalid input type (%s)' % input_type) ValueError: Invalid input type (img)

    Could you give me a hint on how to achieve what I want to do?

    Kind regards!

    opened by raphaelsulzer 15
  • The total training time

    The total training time

    Hi: thanks for making this great work available here! I want to know the total training time for 3000 epochs for the model in this paper (or if you use a single GPU ? ). I find it's so long for me to train the model on a single 2080Ti.

    opened by Runsong123 8
  • Question about data sampling strategy in synthetic indoor scene dataset

    Question about data sampling strategy in synthetic indoor scene dataset

    Hi there, thank you for making the code public!

    I have a question about data sampling strategy in synthetic indoor scene dataset.

    After placing the object in the room, do you randomly sample points and query their ground truth occupancy in the whole scene? If so, wouldn't the occupancy data severely biased toward empty (since most space inside the room should be empty)?

    Another question is that: how many point-occupancy pairs do you sample for one batch?

    I'm not able to clearly locate these details in the code, so I raise the issue to ask. Thank you for your time!

    opened by Steve-Tod 8
  • Running on newer Nvidia GPUs || cuDNN errors

    Running on newer Nvidia GPUs || cuDNN errors

    Thank you very much for this repo and your paper.

    This is not so much an issue as much as it is shared tips for others who, like me, may be struggling to run this code on latest Nvidia graphics cards. My specs are: Ubuntu 18.04 2 x Nvidia RTX 3090 g++ 9.4/gcc 8.4/ninja 1.8

    Specifically I had two main issues:

    1. running the code according to the instructions (installing from environment.yaml) led to unspecified cuDNN error that could be traced to incompatibility between my RTX3090 and the required PyTorch 1.5.
    2. installing all requirements manually including the latest PyTorch led to errors when running setup.py.

    My solution was:

    1. (this may not be required but I include it as it is how my system is set up) install cuda 11.1 and ensure the $PATH and $LD_LIBRARY_PATH environment variables are configured correctly (see instruction 9.1.1 here - but pointing to cuda 11.1 instead of 11.4)
    2. manually create and activate a brand new conda environment: conda create -n my_conv_onet python=3.6 and conda activate my_conv_onet
    3. use pip to install numpy and cython: pip install numpy cython
    4. modify the setup.py file by: a. remove the import for torch.utils.cpp_extension b. at the end of the file, remove the cmd_class argument from the setup function
    5. now run python setup.py build_ext --inplace
    6. install PyTorch as per Torch website instructions for installing PyTorch with cuda 11.1: pip3 install torch==1.9.0+cu111 torchvision==0.10.0+cu111 -f https://download.pytorch.org/whl/torch_stable.html
    7. install torch-scatter as per Torch Scatter website instructions for installing with cuda 11.1: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.9.0+cu111.html
    8. install remaining dependencies with pip: pip install matplotlib tensorboardx trimesh pyyaml tqdm

    This should then provide you with a fully installed environment from which to run the code. I will print my conda list in a comment below.

    opened by jnyjxn 6
  • error: command 'gcc' failed with exit status 1

    error: command 'gcc' failed with exit status 1

    gcc: error: /home/deploy/tmp/pycharm_project_794/convolutional_occupancy_networks/build/temp.linux-x86_64-3.7/src/utils/libkdtree/pykdtree/kdtree.o: No such file or directory gcc: error: /home/deploy/tmp/pycharm_project_794/convolutional_occupancy_networks/build/temp.linux-x86_64-3.7/src/utils/libkdtree/pykdtree/_kdtree_core.o: No such file or directory

    opened by Airobin329 5
  • Not using conditional batch normalization!

    Not using conditional batch normalization!

    In the line mentioned below, which is a part of documentation, it is mentioned that you are using conditional batch norm. However, in the code, you are using residual blocks without any batch norm. It seems that it is a legacy documentation. Please let me know, if you are actually intending to use batchnorm (conditional or otherwise).

    Edit: I would really appreciate if you can also give some intuition about why did you not use batch normalization at all?

    https://github.com/autonomousvision/convolutional_occupancy_networks/blob/1ef59d0d7e099a7723a3c317cdc97403bbf91f63/src/conv_onet/models/decoder.py#L9

    opened by Hippogriff 5
  • why normalize_3d_coordiante is needed?

    why normalize_3d_coordiante is needed?

    Hi, I'm wondering why normalize_3d_coordiante is needed if the point coordinate is in range of [-0.5, 0.5]? https://github.com/autonomousvision/convolutional_occupancy_networks/blob/f44d413f8d455657a44c24d06163934c69141a09/src/encoder/voxels.py#L74

    opened by qiminchen 4
  • A few questions regarding your paper

    A few questions regarding your paper

    Hi, thanks for sharing your great work!

    I have a few questions:

    1. You mentioned that "our method is independent of the input representation" in the paper. I am curious to know that if it is possible to use multi-view images as input in your framework. If the answer is yes, could you provide a hint how to implement that?

    2. If train your method in a real-world dataset and test on another real-world dataset, do you think it will still work?

    3. As mentioned in Sec. 6 of the supplementary material, you "randomly sample one point within the scene as the center of the crop". May I know how you balance the positive and negative samples (i.e., gt occupancy value 1 and 0) with random sampling?

    Looking forward to your reply. Thanks.

    opened by Na-Z 4
  • Ground Truth Mesh of the Synthetic Indoor Scene

    Ground Truth Mesh of the Synthetic Indoor Scene

    Hi, I just tried training the synthetic indoor scene with datasets downloaded from the link. It worked well. I want to compare the generated mesh with the ground-truth mesh, however, what I can find is some point clouds that seem to be the ground truth. Therefore, could you please help me with the ground-truth mesh of the synthetic indoor scene? Thanks a lot.

    opened by samcao416 3
  • Bug in generating walls for synthetic dataset?

    Bug in generating walls for synthetic dataset?

    https://github.com/autonomousvision/convolutional_occupancy_networks/blob/f15b97da2c5995598537c8f832e52e95c0b09236/scripts/dataset_synthetic_room/build_dataset.py#L352

    I think it should be if walls[3] == 1. Is it a typo?

    opened by ZhaoyangZh 3
  • Inference/Generate with a generic .ply file

    Inference/Generate with a generic .ply file

    Hi, Thank you for making the code for this nice project publicly available. If I have a point cloud stored in a generic .ply file, how can I process it in such a way that I can run inference with the model that was trained on matterport? So is there some "build_dataset.py" file that is not for a specific dataset, but can just be used for a normal .ply file? Best, Duncan

    opened by DuncanZauss 3
  • RuntimeError: cannot join current thread

    RuntimeError: cannot join current thread" by running "python generate.py configs/pointcloud_crop/demo_matterport.yaml"

    Hi Peng, Thanks for your great work. I ran the "python generate.py configs/pointcloud_crop/demo_matterport.yaml" and got the question of "RuntimeError: cannot join current thread", detailed as follows:

    image

    Could you help me in that regard? Thank you.

    opened by XiaoyanQian 4
  • Train on custom dataset using crops

    Train on custom dataset using crops

    Hi,

    I have successfully trained ConvONet on my own object datasets before with nice results! I have used the sample_mesh.py script from ONet to generate pointcloud.npz and points.npz (occupancy points) files.

    I would now like to train the network to reconstruct very large scenes, for which I have ground truth meshes for some of them. How do I go about this?

    Can I simply provide one points.npz and pointcloud.npz file per scene? How do I make sure to have enough occupancy samples per crop? Should I simply make sure to have 100k occupancy points per crop defined by voxel_size * resolution? Or do I need to do the cropping myself?

    Kind regards

    opened by raphaelsulzer 0
Predicting Semantic Map Representations from Images with Pyramid Occupancy Networks

This is the code associated with the paper Predicting Semantic Map Representations from Images with Pyramid Occupancy Networks, published at CVPR 2020.

Thomas Roddick 219 Dec 20, 2022
This repository implements and evaluates convolutional networks on the Möbius strip as toy model instantiations of Coordinate Independent Convolutional Networks.

Orientation independent Möbius CNNs This repository implements and evaluates convolutional networks on the Möbius strip as toy model instantiations of

Maurice Weiler 59 Dec 9, 2022
Repository for the paper "Online Domain Adaptation for Occupancy Mapping", RSS 2020

RSS 2020 - Online Domain Adaptation for Occupancy Mapping Repository for the paper "Online Domain Adaptation for Occupancy Mapping", Robotics: Science

Anthony 26 Sep 22, 2022
PyTorch implementation of SMODICE: Versatile Offline Imitation Learning via State Occupancy Matching

SMODICE: Versatile Offline Imitation Learning via State Occupancy Matching This is the official PyTorch implementation of SMODICE: Versatile Offline I

Jason Ma 14 Aug 30, 2022
Nest Protect integration for Home Assistant. This will allow you to integrate your smoke, heat, co and occupancy status real-time in HA.

Nest Protect integration for Home Assistant Custom component for Home Assistant to interact with Nest Protect devices via an undocumented and unoffici

Mick Vleeshouwer 175 Dec 29, 2022
[CVPR'22] COAP: Learning Compositional Occupancy of People

COAP: Compositional Articulated Occupancy of People Paper | Video | Project Page This is the official implementation of the CVPR 2022 paper COAP: Lear

Marko Mihajlovic 111 Dec 11, 2022
Project for tracking occupancy in Tel-Aviv parking lots.

Ahuzat Dibuk - Tracking occupancy in Tel-Aviv parking lots main.py This module was set-up to be executed on Google Cloud Platform. I run it every 15 m

Geva Kipper 35 Nov 22, 2022
CoSMA: Convolutional Semi-Regular Mesh Autoencoder. From Paper "Mesh Convolutional Autoencoder for Semi-Regular Meshes of Different Sizes"

Mesh Convolutional Autoencoder for Semi-Regular Meshes of Different Sizes Implementation of CoSMA: Convolutional Semi-Regular Mesh Autoencoder arXiv p

Fraunhofer SCAI 10 Oct 11, 2022
Code for our ICASSP 2021 paper: SA-Net: Shuffle Attention for Deep Convolutional Neural Networks

SA-Net: Shuffle Attention for Deep Convolutional Neural Networks (paper) By Qing-Long Zhang and Yu-Bin Yang [State Key Laboratory for Novel Software T

Qing-Long Zhang 199 Jan 8, 2023
《Truly shift-invariant convolutional neural networks》(2021)

Truly shift-invariant convolutional neural networks [Paper] Authors: Anadi Chaman and Ivan Dokmanić Convolutional neural networks were always assumed

Anadi Chaman 46 Dec 19, 2022
《A-CNN: Annularly Convolutional Neural Networks on Point Clouds》(2019)

A-CNN: Annularly Convolutional Neural Networks on Point Clouds Created by Artem Komarichev, Zichun Zhong, Jing Hua from Department of Computer Science

Artёm Komarichev 44 Feb 24, 2022
Spontaneous Facial Micro Expression Recognition using 3D Spatio-Temporal Convolutional Neural Networks

Spontaneous Facial Micro Expression Recognition using 3D Spatio-Temporal Convolutional Neural Networks Abstract Facial expression recognition in video

Bogireddy Sai Prasanna Teja Reddy 103 Dec 29, 2022
This project is a loose implementation of paper "Algorithmic Financial Trading with Deep Convolutional Neural Networks: Time Series to Image Conversion Approach"

Stock Market Buy/Sell/Hold prediction Using convolutional Neural Network This repo is an attempt to implement the research paper titled "Algorithmic F

Asutosh Nayak 136 Dec 28, 2022
Submanifold sparse convolutional networks

Submanifold Sparse Convolutional Networks This is the PyTorch library for training Submanifold Sparse Convolutional Networks. Spatial sparsity This li

Facebook Research 1.8k Jan 6, 2023
Fine-tune pretrained Convolutional Neural Networks with PyTorch

Fine-tune pretrained Convolutional Neural Networks with PyTorch. Features Gives access to the most popular CNN architectures pretrained on ImageNet. A

Alex Parinov 694 Nov 23, 2022
Pytorch implementation of AngularGrad: A New Optimization Technique for Angular Convergence of Convolutional Neural Networks

AngularGrad Optimizer This repository contains the oficial implementation for AngularGrad: A New Optimization Technique for Angular Convergence of Con

mario 124 Sep 16, 2022
Subdivision-based Mesh Convolutional Networks

Subdivision-based Mesh Convolutional Networks The official implementation of SubdivNet in our paper, Subdivion-based Mesh Convolutional Networks Requi

Zheng-Ning Liu 181 Dec 28, 2022
Code for paper: Group-CAM: Group Score-Weighted Visual Explanations for Deep Convolutional Networks

Group-CAM By Zhang, Qinglong and Rao, Lu and Yang, Yubin [State Key Laboratory for Novel Software Technology at Nanjing University] This repo is the o

zhql 98 Nov 16, 2022
Unofficial TensorFlow implementation of Protein Interface Prediction using Graph Convolutional Networks.

[TensorFlow] Protein Interface Prediction using Graph Convolutional Networks Unofficial TensorFlow implementation of Protein Interface Prediction usin

YeongHyeon Park 9 Oct 25, 2022