Open source repository for the code accompanying the paper 'PatchNets: Patch-Based Generalizable Deep Implicit 3D Shape Representations'.

Overview

PatchNets

This is the official repository for the project "PatchNets: Patch-Based Generalizable Deep Implicit 3D Shape Representations". For details, we refer to our project page, which also includes supplemental videos.

This code requires a functioning installation of DeepSDF, which can then be modified using the provided files.

(Optional) Making ShapeNet V1 Watertight

If you want to use ShapeNet, please follow these steps:

  1. Download Occupancy Networks
  2. On Linux, follow the installation steps from there:
conda env create -f environment.yaml
conda activate mesh_funcspace
python setup.py build_ext --inplace
  1. Install the four external dependencies from external/mesh-fusion:
    • for libfusioncpu and libfusiongpu, run cmake and then setup.py
    • for libmcubes and librender, run setup.py
  2. Replace the original OccNet files with the included slightly modified versions. This mostly switches to using .obj instead of .off
  3. Prepare the original Shapenet meshes by copying all objs as follows: from 02858304/1b2e790b7c57fc5d2a08194fd3f4120d/model.obj to 02858304/1b2e790b7c57fc5d2a08194fd3f4120d.obj
  4. Use generate_watertight_meshes_and_sample_points() from useful_scripts.py. Needs to be run twice, see comment at generate_command.
  5. On a Linux machine with display, activate mesh_funcspace
  6. Run the generated command.sh. Note: this preprocessing crashes frequently because some meshes cause issues. They need to be deleted.

Preprocessing

During preprocessing, we generate SDF samples from obj files.

The C++ files in src/ are modified versions of the corresponding DeepSDF files. Please follow the instruction on the DeepSDF github repo to compile these. Then run preprocess_data.py. There is a special flag in preprocess_data.py for easier handling of ShapeNet. There is also an example command for preprocessing ShapeNet in the code comments. If you want to use depth completion, add the --randomdepth and --depth flags to the call to preprocess_data.py.

Training

The files in code/ largely follow DeepSDF and replace the corresponding files in your DeepSDF installation. Note that some legacy functions from these files might not be compatible with PatchNets.

  • Some settings files are available in code/specs/. The training/test splits can be found in code/examples/splits/. The DataSource and, if used, the patch_network_pretrained_path and pretrained_depth_encoder_weights need to be adapted.
  • Set a folder that collects all experiments in code/localization/SystemSpecific.py.
  • The code uses code/specs.json as the settings file. Replace this file with the desired settings file.
  • The code creates a results folder, which also includes a backup. This is necessary to later run the evaluation script.
  • Throughout the code, metadata refers to patch extrinsics.
  • mixture_latent_mode can be set to all_explicit for normal PatchNets mode or to all_implicit for use with object latents.
    • Some weights automatically change in deep_sdf_decoder.py depending on whether all_explicit or all_implicit is used.
  • For all_implicit/object latents, please set sdf_filename under use_precomputed_bias_init in deep_sdf_decoder.py to an .npz file that was obtained via Preprocessing and for which initialize_mixture_latent_vector() from train_deep_sdf.py has been run (e.g. by including it in the training set and training a normal PatchNet). MixtureCodeLength is the object latent size and PatchCodeLength is the size of each of the regressed patch codes.
  • For all_explicit/normal PatchNets, MixtureCodeLength needs to be compatible with PatchCodeLength. Set MixtureCodeLength = (PatchCodeLength + 7) x num_patches. The 7 comes from position (3) + rotation (3) + scale (1). Always use 7, regardless of whether scale and/or rotation are used. Consider keeping the patch extrinsics fixed at their initial values instead of optimizing them with the extrinsics loss, see the second stage of StagedTraining.
  • When using staged training, NumEpochs and the total Lengths of each Staged schedule should be equal. Also note that both Staged schedules should have the exact same Lengths list.

Evaluation

  1. Fit PatchNets to test data: Use train_deep_sdf.py to run the trained network on the test data. Getting the patch parameters for a test set is almost the same workflow as training a network, except that the network weights are initialized and then kept fixed and a few other settings are changed. Please see included test specs.json for examples. In all cases, set test_time = True, train_patch_network = False, train_object_to_patch = False. Set patch_network_pretrained_path in the test specs.json to the results folder of the trained network. Make sure that ScenesPerBatch is a multiple of the test set size. Adjust the learning rate schedules according to the test specs.json examples included.
  2. Get quantitative evaluation: Use evaluate_patch_network_metrics() from useful_scripts.py with the test results folder. Needs to be run twice, see comment at generate_meshes. Running this script requires an installation of Occupancy Networks, see comments in evaluate_patch_network_metrics(). It also requires the obj files of the dataset that were used for Preprocessing.

Applications, Experiments, and Mesh Extraction

useful_scripts.py contains code for the object latent applications from Sec. 4.3: latent interpolation, the generative model and depth completion. The depth completion code contains a mode for quantitative evaluation. useful_scripts.py also contains code to extract meshes.

code/deep_sdf/data.py contains the code snippet used for the synthetic noise experiments in Sec. 7 of the supplementary material.

Additional Functionality

The code contains additional functionalities that are not part of the publication. They might work but have not been thoroughly tested and can be removed.

  • wrappers to allow for easy interaction with a trained network (do not remove, required to run evaluation)
    • _setup_torch_network() in useful_scripts.py
  • a patch encoder
    • Instead of autodecoding a patch latent code, it is regressed from SDF point samples that lie inside the patch.
    • Encoder in specs.json. Check that this works as intended, later changes to the code might have broken something.
  • a depth encoder
    • A depth encoder maps from one depth map to all patch parameters.
    • use_depth_encoder in specs.json. Check that this works as intended, later changes to the code might have broken something.
  • a tiny PatchNet version
    • The latent code is reshaped and used as network weights, i.e. there are no shared weights between different patches.
    • dims in specs.json should be set to something small like [ 8, 8, 8, 8, 8, 8, 8 ]
    • use_tiny_patchnet in specs.json
    • Requires to set PatchLatentCode correctly, the desired value is printed by _initialize_tiny_patchnet() in deep_sdf_decoder.py.
  • a hierarchical representation
    • Represents/encodes a shape using large patches for simple regions and smaller patches for complex regions of the geometry.
    • hierarchical_representation() in useful_scripts.py. Never tested. Later changes to the network code might also have broken something.
  • simplified curriculum weighting from Curriculum DeepSDF
    • use_curriculum_weighting in specs.json. Additional parameters are in train_deep_sdf.py. This is our own implementation, not based on their repo, so mistakes are ours.
  • positional encoding from NeRF
    • positional_encoding in specs.json. Additional parameters are in train_deep_sdf.py. This is our own implementation, not based on their repo, so mistakes are ours.
  • a Neural ODE deformation model for patches
    • Instead of a simple MLP regressing the SDF value, a velocity field first deforms the patch region and then the z-value of the final xyz position is returned as the SDF value. Thus the field flattens the surface to lie in the z=0 plane. Very slow due to Neural ODE. Might be useful to get UV maps/a direct surface parametrization.
    • use_ode and time_dependent_ode in specs.json. Additional parameters are in train_deep_sdf.py.
  • a mixed representation that has explicit patch latent codes and only regresses patch extrinsics from an object latent code
    • Set mixture_latent_mode in specs.json to patch_explicit_meta_implicit. posrot_latent_size is the size of the object latent code in this case. mixture_to_patch_parameters is the network that regresses the patch extrinsics. Check that this works as intended, later changes to the code might have broken something.

Citation

This code builds on DeepSDF. Please consider citing DeepSDF and PatchNets if you use this code.

@article{Tretschk2020PatchNets, 
    author = {Tretschk, Edgar and Tewari, Ayush and Golyanik, Vladislav and Zollh\"{o}fer, Michael and Stoll, Carsten and Theobalt, Christian}, 
    title = "{PatchNets: Patch-Based Generalizable Deep Implicit 3D Shape Representations}", 
    journal = {European Conference on Computer Vision (ECCV)}, 
    year = "2020" 
} 
@InProceedings{Park_2019_CVPR,
    author = {Park, Jeong Joon and Florence, Peter and Straub, Julian and Newcombe, Richard and Lovegrove, Steven},
    title = {DeepSDF: Learning Continuous Signed Distance Functions for Shape Representation},
    booktitle = {The IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
    month = {June},
    year = {2019}
}

License

Please note that this code is released under an MIT licence, see LICENCE. We have included and modified third-party components, which have their own licenses. We thank all of the respective authors for releasing their code, especially the team behind DeepSDF!

LineBoard - Python+React+MySQL-白板即時系統改善人群行為

LineBoard-白板即時系統改善人群行為 即時顯示實驗室的使用狀況,並遠端預約排隊,以此來改善人們的工作效率 程式架構 運作流程 使用者先至該實驗室網站預約

Bo-Jyun Huang 1 Feb 22, 2022
🔥 Cannlytics-powered artificial intelligence 🤖

Cannlytics AI 🔥 Cannlytics-powered artificial intelligence 🤖 🏗️ Installation 🏃‍♀️ Quickstart 🧱 Development 🦾 Automation 💸 Support 🏛️ License ?

Cannlytics 3 Nov 11, 2022
Rule based classification A hotel s customers dataset

Rule-based-classification-A-hotel-s-customers-dataset- Aim: Categorize new customers by segment and predict how much revenue they can generate This re

Şebnem 4 Jan 02, 2022
It's like Shape Editor in Maya but works with skeletons (transforms).

Skeleposer What is Skeleposer? Briefly, it's like Shape Editor in Maya, but works with transforms and joints. It can be used to make complex facial ri

Alexander Zagoruyko 1 Nov 11, 2022
Tensorflow python implementation of "Learning High Fidelity Depths of Dressed Humans by Watching Social Media Dance Videos"

Learning High Fidelity Depths of Dressed Humans by Watching Social Media Dance Videos This repository is the official tensorflow python implementation

Yasamin Jafarian 287 Jan 06, 2023
Ejemplo Algoritmo Viterbi - Example of a Viterbi algorithm applied to a hidden Markov model on DNA sequence

Ejemplo Algoritmo Viterbi Ejemplo de un algoritmo Viterbi aplicado a modelo ocul

Mateo Velásquez Molina 1 Jan 10, 2022
PaddleRobotics is an open-source algorithm library for robots based on Paddle, including open-source parts such as human-robot interaction, complex motion control, environment perception, SLAM positioning, and navigation.

简体中文 | English PaddleRobotics paddleRobotics是基于paddle的机器人开源算法库集,包括人机交互、复杂运动控制、环境感知、slam定位导航等开源算法部分。 人机交互 主动多模交互技术TFVT-HRI 主动多模交互技术是通过视觉、语音、触摸传感器等输入机器人

185 Dec 26, 2022
Cereal box identification in store shelves using computer vision and a single train image per model.

Product Recognition on Store Shelves Description You can read the task description here. Report You can read and download our report here. Step A - Mu

Nicholas Baraghini 1 Jan 21, 2022
Self-Supervised Learning with Kernel Dependence Maximization

Self-Supervised Learning with Kernel Dependence Maximization This is the code for SSL-HSIC, a self-supervised learning loss proposed in the paper Self

DeepMind 29 Dec 29, 2022
An efficient 3D semantic segmentation framework for Urban-scale point clouds like SensatUrban, Campus3D, etc.

An efficient 3D semantic segmentation framework for Urban-scale point clouds like SensatUrban, Campus3D, etc.

Zou 33 Jan 03, 2023
Code for the Convolutional Vision Transformer (ConViT)

ConViT : Vision Transformers with Convolutional Inductive Biases This repository contains PyTorch code for ConViT. It builds on code from the Data-Eff

Facebook Research 418 Jan 06, 2023
A keras-based real-time model for medical image segmentation (CFPNet-M)

CFPNet-M: A Light-Weight Encoder-Decoder Based Network for Multimodal Biomedical Image Real-Time Segmentation This repository contains the implementat

268 Nov 27, 2022
Official implementation of "Articulation Aware Canonical Surface Mapping"

Articulation-Aware Canonical Surface Mapping Nilesh Kulkarni, Abhinav Gupta, David F. Fouhey, Shubham Tulsiani Paper Project Page Requirements Python

Nilesh Kulkarni 56 Dec 16, 2022
RoadMap and preparation material for Machine Learning and Data Science - From beginner to expert.

ML-and-DataScience-preparation This repository has the goal to create a learning and preparation roadMap for Machine Learning Engineers and Data Scien

33 Dec 29, 2022
The undersampled DWI image using Slice-Interleaved Diffusion Encoding (SIDE) method can be reconstructed by the UNet network.

UNet-SIDE The undersampled DWI image using Slice-Interleaved Diffusion Encoding (SIDE) method can be reconstructed by the UNet network. For Super Reso

TIANTIAN XU 1 Jan 13, 2022
Implementing Graph Convolutional Networks and Information Retrieval Mechanisms using pure Python and NumPy

Implementing Graph Convolutional Networks and Information Retrieval Mechanisms using pure Python and NumPy

Noah Getz 3 Jun 22, 2022
DeepStruc is a Conditional Variational Autoencoder which can predict the mono-metallic nanoparticle from a Pair Distribution Function.

ChemRxiv | [Paper] XXX DeepStruc Welcome to DeepStruc, a Deep Generative Model (DGM) that learns the relation between PDF and atomic structure and the

Emil Thyge Skaaning Kjær 13 Aug 01, 2022
Code of TVT: Transferable Vision Transformer for Unsupervised Domain Adaptation

TVT Code of TVT: Transferable Vision Transformer for Unsupervised Domain Adaptation Datasets: Digit: MNIST, SVHN, USPS Object: Office, Office-Home, Vi

37 Dec 15, 2022
Official PyTorch implementation of the paper "Recycling Discriminator: Towards Opinion-Unaware Image Quality Assessment Using Wasserstein GAN", accepted to ACM MM 2021 BNI Track.

RecycleD Official PyTorch implementation of the paper "Recycling Discriminator: Towards Opinion-Unaware Image Quality Assessment Using Wasserstein GAN

Yunan Zhu 23 Nov 05, 2022
A cool little repl-based simulation written in Python

A cool little repl-based simulation written in Python planned to integrate machine-learning into itself to have AI battle to the death before your eye

Em 6 Sep 17, 2022