KinectFusion implemented in Python with PyTorch

Overview

KinectFusion implemented in Python with PyTorch

This is a lightweight Python implementation of KinectFusion. All the core functions (TSDF volume, frame-to-model tracking, point-to-plane ICP, raycasting, TSDF fusion, etc.) are implemented using pure PyTorch, i.e. no custom CUDA kernels.

Although without any custom CUDA functions, the system could still run at a fairly fast speed: The demo reconstructs the TUM fr1_desk sequence into a 225 x 171 x 111 TSDF volume with 2cm resolution at round 17 FPS with a single RTX-2080 GPU (~1.5 FPS in CPU mode)

Note that this project is mainly for study purpose, and is not fully optimized for accurate camera tracking.

Requirements

The core functionalities were implemented in PyTorch (1.10). Open3D (0.14.0) is used for visualisation. Other important dependancies include:

  • numpy==1.21.2
  • opencv-python==4.5.5
  • imageio==2.14.1
  • scikit-image==0.19.1
  • trimesh==3.9.43

You can create an anaconda environment called kinfu with the required dependencies by running:

conda env create -f environment.yml
conda activate kinfu

Data Preparation

The code was tested on TUM dataset. After downloading the raw sequences, you will need to run the pre-processing script under dataset/. For example:

python dataset/preprocess.py --config configs/fr1_desk.yaml

There are some example config files under configs/ which correspond to different sequences. You need to replace data_root to your own sequence directory before running the script. After running the script a new directory processed/ will appear under your sequence directory.

Run

After obtaining the processed sequence, you can simply run kinfu.py. For example:

python kinfu.py --config configs/fr1_desk.yaml --save_dir reconstruct/fr1_desk

which will perform the tracking and mapping headlessly and save the results. Or you could run:

python kinfu_gui.py --config configs/fr1_desk.yaml

If you want to visualize the tracking and reconstruction process on-the-fly.

Acknowledgement

Part of the tracking code was borrowed and modified from DeepIC. Also thank Binbin Xu for implementing part of the TSDF volume code which is inspired by Andy Zeng's tsdf-fusion-python.

You might also like...
Reinforcement learning framework and algorithms implemented in PyTorch.

Reinforcement learning framework and algorithms implemented in PyTorch.

This is the official source code for SLATE. We provide the code for the model, the training code, and a dataset loader for the 3D Shapes dataset. This code is implemented in Pytorch.

SLATE This is the official source code for SLATE. We provide the code for the model, the training code and a dataset loader for the 3D Shapes dataset.

 Equivariant CNNs for the sphere and SO(3) implemented in PyTorch
Equivariant CNNs for the sphere and SO(3) implemented in PyTorch

Equivariant CNNs for the sphere and SO(3) implemented in PyTorch

AutoDeeplab / auto-deeplab / AutoML for semantic segmentation, implemented in Pytorch
AutoDeeplab / auto-deeplab / AutoML for semantic segmentation, implemented in Pytorch

AutoML for Image Semantic Segmentation Currently this repo contains the only working open-source implementation of Auto-Deeplab which, by the way out-

This is a file about Unet implemented in Pytorch
This is a file about Unet implemented in Pytorch

Unet this is an implemetion of Unet in Pytorch and it's architecture is as follows which is the same with paper of Unet component of Unet Convolution

Technical Indicators implemented in Python only using Numpy-Pandas as Magic  - Very Very Fast! Very tiny!  Stock Market Financial Technical Analysis Python library .  Quant Trading automation or cryptocoin exchange
Technical Indicators implemented in Python only using Numpy-Pandas as Magic - Very Very Fast! Very tiny! Stock Market Financial Technical Analysis Python library . Quant Trading automation or cryptocoin exchange

MyTT Technical Indicators implemented in Python only using Numpy-Pandas as Magic - Very Very Fast! to Stock Market Financial Technical Analysis Python

Machine learning evaluation metrics, implemented in Python, R, Haskell, and MATLAB / Octave

Note: the current releases of this toolbox are a beta release, to test working with Haskell's, Python's, and R's code repositories. Metrics provides i

Implemented fully documented Particle Swarm Optimization algorithm (basic model with few advanced features) using Python programming language
Implemented fully documented Particle Swarm Optimization algorithm (basic model with few advanced features) using Python programming language

Implemented fully documented Particle Swarm Optimization (PSO) algorithm in Python which includes a basic model along with few advanced features such as updating inertia weight, cognitive, social learning coefficients and maximum velocity of the particle.

DIT is a DTLS MitM proxy implemented in Python 3. It can intercept, manipulate and suppress datagrams between two DTLS endpoints and supports psk-based and certificate-based authentication schemes (RSA + ECC).

DIT - DTLS Interception Tool DIT is a MitM proxy tool to intercept DTLS traffic. It can intercept, manipulate and/or suppress DTLS datagrams between t

Comments
  • Code run fine, but need clarification regarding pose matrix

    Code run fine, but need clarification regarding pose matrix

    1. Can we assume that this algorithm only needs an initial pose matrix, or does it need poses for each step in the entire camera trajectory?
    2. If so, how can we specify initial pose for a custom dataset?

    I checked the world_mats variable in tum_rgbd.py and I tweeked it to use only store the first pose value in a repeated fashion (eg below)

    pose1 = np.array([[ 3.18131473e+02, 4.60102595e+02, -2.37143996e+02, 6.60288595e+00], [ 1.32248250e+02, -1.87081717e+02, -5.28617550e+02, 5.54961371e+02], [-3.51650973e-01, 5.42460640e-01, -7.62940395e-01, 1.31740951e+00]])

    pose2 = np.array([[ 3.44746770e+02, 4.56713777e+02, -2.04209444e+02, -5.30226155e+02], [ 9.00883139e+01, -1.36841787e+02, -5.52344190e+02, 8.36896216e+02], [-3.39983783e-01, 6.50759651e-01, -6.78913032e-01, 9.25806734e-01]])

    ini_pose = pose2 tentative_poses = [ini_pose for _ in range(572)] world_mats = np.stack(tentative_poses, axis=0)

    I see that if I set ini_pose=pose1 (a random value), reconstruction messes up, but if I set=pose2 (cameras.npz, first pose matrix) then the code works as usual, so is there something special about the initial pose ?

    opened by Homagn 1
Owner
Jingwen Wang
I'm a PhD student at University College London (UCL) working on Object SLAM and 3D Vision.
Jingwen Wang
NFNets and Adaptive Gradient Clipping for SGD implemented in PyTorch

PyTorch implementation of Normalizer-Free Networks and SGD - Adaptive Gradient Clipping Paper: https://arxiv.org/abs/2102.06171.pdf Original code: htt

Vaibhav Balloli 320 Jan 2, 2023
SimDeblur is a simple framework for image and video deblurring, implemented by PyTorch

SimDeblur (Simple Deblurring) is an open source framework for image and video deblurring toolbox based on PyTorch, which contains most deep-learning based state-of-the-art deblurring algorithms. It is easy to implement your own image or video deblurring or other restoration algorithms.

null 220 Jan 7, 2023
Chinese Mandarin tts text-to-speech 中文 (普通话) 语音 合成 , by fastspeech 2 , implemented in pytorch, using waveglow as vocoder,

Chinese mandarin text to speech based on Fastspeech2 and Unet This is a modification and adpation of fastspeech2 to mandrin(普通话). Many modifications t

null 291 Jan 2, 2023
In this project we investigate the performance of the SetCon model on realistic video footage. Therefore, we implemented the model in PyTorch and tested the model on two example videos.

Contrastive Learning of Object Representations Supervisor: Prof. Dr. Gemma Roig Institutions: Goethe University CVAI - Computational Vision & Artifici

Dirk Neuhäuser 6 Dec 8, 2022
Transformer model implemented with Pytorch

transformer-pytorch Transformer model implemented with Pytorch Attention is all you need-[Paper] Architecture Self-Attention self_attention.py class

Mingu Kang 12 Sep 3, 2022
Many Class Activation Map methods implemented in Pytorch for CNNs and Vision Transformers. Including Grad-CAM, Grad-CAM++, Score-CAM, Ablation-CAM and XGrad-CAM

Class Activation Map methods implemented in Pytorch pip install grad-cam ⭐ Tested on many Common CNN Networks and Vision Transformers. ⭐ Includes smoo

Jacob Gildenblat 6.6k Jan 6, 2023
NEG loss implemented in pytorch

Pytorch Negative Sampling Loss Negative Sampling Loss implemented in PyTorch. Usage neg_loss = NEG_loss(num_classes, embedding_size) optimizer =

Daniil Gavrilov 123 Sep 13, 2022
Recurrent Variational Autoencoder that generates sequential data implemented with pytorch

Pytorch Recurrent Variational Autoencoder Model: This is the implementation of Samuel Bowman's Generating Sentences from a Continuous Space with Kim's

Daniil Gavrilov 347 Nov 14, 2022
Time Delayed NN implemented in pytorch

Pytorch Time Delayed NN Time Delayed NN implemented in PyTorch. Usage kernels = [(1, 25), (2, 50), (3, 75), (4, 100), (5, 125), (6, 150)] tdnn = TDNN

Daniil Gavrilov 79 Aug 4, 2022
Highway networks implemented in PyTorch.

PyTorch Highway Networks Highway networks implemented in PyTorch. Just the MNIST example from PyTorch hacked to work with Highway layers. Todo Make th

Conner Vercellino 56 Dec 14, 2022