### Setup NeuralRecon Environment Source: https://context7.com/zju3dv/neuralrecon/llms.txt Commands to install system dependencies, set up the Conda environment, and download the necessary pretrained model weights. ```bash sudo apt install libsparsehash-dev conda env create -f environment.yaml conda activate neucon mkdir checkpoints && cd checkpoints gdown --id 1zKuWqm9weHSm98SZKld1PbEddgLOQkQV ``` -------------------------------- ### Start NeuralRecon Training with distributed PyTorch Source: https://github.com/zju3dv/neuralrecon/blob/master/README.md This script initiates the distributed training process for NeuralRecon using PyTorch. It sets the visible CUDA devices and launches the main training script with a specified configuration file. Ensure you have PyTorch and its distributed package installed. ```bash #!/usr/bin/env bash export CUDA_VISIBLE_DEVICES=0,1 python -m torch.distributed.launch --nproc_per_node=2 main.py --cfg ./config/train.yaml ``` -------------------------------- ### Install NeuralRecon Environment Source: https://github.com/zju3dv/neuralrecon/blob/master/README.md Commands to install system dependencies and set up the Conda environment for the project. ```shell sudo apt install libsparsehash-dev conda env create -f environment.yaml conda activate neucon ``` -------------------------------- ### Initialize and Run NeuralRecon Model Source: https://context7.com/zju3dv/neuralrecon/llms.txt Demonstrates how to load the configuration, initialize the NeuralRecon model, load pretrained weights, and perform inference on input data. ```python import torch from models import NeuralRecon from config import cfg, update_config class Args: cfg = './config/demo.yaml' opts = [] args = Args() update_config(cfg, args) model = NeuralRecon(cfg).cuda().eval() model = torch.nn.DataParallel(model, device_ids=[0]) state_dict = torch.load('./checkpoints/model_000047.ckpt') model.load_state_dict(state_dict['model'], strict=False) with torch.no_grad(): outputs, loss_dict = model(sample, save_mesh=True) ``` -------------------------------- ### Run NeuralRecon Demo Source: https://context7.com/zju3dv/neuralrecon/llms.txt Commands to execute the real-time reconstruction demo using custom ARKit data, including configuration for visualization and performance. ```bash python demo.py --cfg ./config/demo.yaml ``` -------------------------------- ### Download Pretrained Model Source: https://github.com/zju3dv/neuralrecon/blob/master/README.md Uses gdown to download the pretrained ScanNet weights into the project checkpoints directory. ```bash mkdir checkpoints && cd checkpoints gdown --id 1zKuWqm9weHSm98SZKld1PbEddgLOQkQV ``` -------------------------------- ### Configure Data Transformation Pipeline Source: https://context7.com/zju3dv/neuralrecon/llms.txt Sets up a sequential transformation pipeline for inference, including image resizing, tensor conversion, voxel space mapping, and projection matrix computation. ```python from datasets import transforms transform = [ transforms.ResizeImage((640, 480)), transforms.ToTensor(), transforms.RandomTransformSpace(voxel_dim=[96, 96, 96], voxel_size=0.04, random_rotation=False, random_translation=False, paddingXY=0, paddingZ=0, max_epoch=50), transforms.IntrinsicsPoseToProjection(n_views=9, stride=4) ] transforms_pipeline = transforms.Compose(transform) processed_data = transforms_pipeline(data) ``` -------------------------------- ### Train NeuralRecon Model Source: https://context7.com/zju3dv/neuralrecon/llms.txt Commands to initiate training on ScanNet, supporting both single-GPU and multi-GPU distributed configurations. ```bash python main.py --cfg ./config/train.yaml export CUDA_VISIBLE_DEVICES=0,1 python -m torch.distributed.launch --nproc_per_node=2 main.py --cfg ./config/train.yaml ``` -------------------------------- ### Initialize GRUFusion Module Source: https://context7.com/zju3dv/neuralrecon/llms.txt Initializes the GRU-based fusion module for integrating local TSDF predictions into a global volume. ```python import torch from models.gru_fusion import GRUFusion from config import cfg gru_fusion = GRUFusion(cfg.MODEL, direct_substitute=True) ``` -------------------------------- ### Run Inference and Evaluation Source: https://github.com/zju3dv/neuralrecon/blob/master/README.md Commands to execute model inference on the test set and evaluate the resulting meshes. ```bash python main.py --cfg ./config/test.yaml python tools/evaluation.py --model ./results/scene_scannet_release_fusion_eval_47 --n_proc 16 python tools/visualize_metrics.py --model ./results/scene_scannet_release_fusion_eval_47 ``` -------------------------------- ### Train and Infer with NeuralRecon Source: https://context7.com/zju3dv/neuralrecon/llms.txt Commands to resume training from a checkpoint and run inference on the ScanNet test set using configuration files. ```bash python main.py --cfg ./config/train.yaml RESUME True python main.py --cfg ./config/test.yaml ``` -------------------------------- ### Evaluate Reconstructed Meshes Source: https://context7.com/zju3dv/neuralrecon/llms.txt Scripts to run depth and mesh metric evaluation, including headless rendering support and metric visualization. ```bash python tools/evaluation.py --model ./results/scene_scannet_release_fusion_eval_47 --data_path ./data/scannet/scans_test --gt_path /data/scannet/scans_test --n_proc 16 --n_gpu 1 export PYOPENGL_PLATFORM=osmesa python tools/evaluation.py --model ./results/scene_scannet_release_fusion_eval_47 python tools/visualize_metrics.py --model ./results/scene_scannet_release_fusion_eval_47 ``` -------------------------------- ### Configure NeuralRecon with YACS (Python) Source: https://context7.com/zju3dv/neuralrecon/llms.txt Configures NeuralRecon using YAML files and the YACS configuration system. It loads a base configuration and allows overriding specific options via command-line arguments or a Python list. Configuration values can then be accessed directly from the cfg object. ```python from config import cfg, update_config # Load base configuration from YAML file class Args: cfg = './config/train.yaml' opts = ['TRAIN.LR', '0.0005', 'BATCH_SIZE', '2'] # Override options args = Args() update_config(cfg, args) # Access configuration values print(f"Mode: {cfg.MODE}") # 'train' or 'test' print(f"Dataset: {cfg.DATASET}") # 'scannet' or 'demo' print(f"Batch size: {cfg.BATCH_SIZE}") # 1 print(f"Voxel size: {cfg.MODEL.VOXEL_SIZE}") # 0.04 meters print(f"Volume dimensions: {cfg.MODEL.N_VOX}") # [96, 96, 96] print(f"Number of views: {cfg.TRAIN.N_VIEWS}") # 9 ``` -------------------------------- ### Prepare ScanNet Data Source: https://context7.com/zju3dv/neuralrecon/llms.txt Scripts for generating ground truth TSDF volumes from raw ScanNet data for both training and testing phases. ```bash python tools/tsdf_fusion/generate_gt.py --data_path /path/to/scannet --save_name all_tsdf_9 --window_size 9 --voxel_size 0.04 --num_layers 3 --n_proc 16 --n_gpu 2 python tools/tsdf_fusion/generate_gt.py --test --data_path /path/to/scannet --save_name all_tsdf_9 --window_size 9 ``` -------------------------------- ### Process ARKit Data for NeuralRecon (Python) Source: https://context7.com/zju3dv/neuralrecon/llms.txt Processes raw ARKit capture data (video and poses) into the fragment format required by NeuralRecon. It takes the data path and several parameters to control fragment generation, such as window size, minimum angle, and minimum distance between keyframes. ```python from tools.process_arkit_data import process_data # Process captured ARKit data process_data( data_path='/path/to/arkit_capture', data_source='ARKit', window_size=9, # Number of frames per fragment min_angle=15, # Minimum angle change between keyframes (degrees) min_distance=0.1, # Minimum translation between keyframes (meters) ori_size=(1920, 1440), # Original capture resolution size=(640, 480) # Target resolution ) ``` -------------------------------- ### Save and Process TSDF Volumes Source: https://context7.com/zju3dv/neuralrecon/llms.txt Utilities for saving reconstructed scenes, handling incremental mesh updates, and converting TSDF volumes to meshes using marching cubes. ```python from utils import SaveScene from config import cfg save_mesh_scene = SaveScene(cfg) save_mesh_scene.scene_name = 'my_scene' save_mesh_scene.keyframe_id = 0 if 'scene_tsdf' in outputs: save_mesh_scene.save_scene_eval(epoch_idx=47, outputs=outputs) save_mesh_scene.save_incremental(epoch_idx=47, batch_idx=0, imgs=sample['imgs'][0], outputs=outputs) import numpy as np tsdf_volume = outputs['scene_tsdf'][0].cpu().numpy() origin = outputs['origin'][0].cpu().numpy() mesh = SaveScene.tsdf2mesh(voxel_size=0.04, origin=origin, tsdf_vol=tsdf_volume) mesh.export('output_mesh.ply') ``` -------------------------------- ### Generate Ground Truth TSDFs Source: https://github.com/zju3dv/neuralrecon/blob/master/README.md Parses raw ScanNet data into the processed pickle format and generates ground truth TSDFs using TSDF Fusion. ```bash python tools/tsdf_fusion/generate_gt.py --data_path PATH_TO_SCANNET --save_name all_tsdf_9 --window_size 9 python tools/tsdf_fusion/generate_gt.py --test --data_path PATH_TO_SCANNET --save_name all_tsdf_9 --window_size 9 ``` -------------------------------- ### GRU Fusion for Scene Reconstruction (Python) Source: https://context7.com/zju3dv/neuralrecon/llms.txt Performs GRU fusion to reconstruct a 3D scene from input data. It takes coordinates, TSDF values, and input dictionaries, with options to control scale and mesh saving. The function can be reset for new scenes. ```python from neuralrecon.gru_fusion import gru_fusion # inputs: dict with 'fragment', 'scene', 'vol_origin', 'vol_origin_partial', etc. outputs = gru_fusion( coords=voxel_coords, values_in=tsdf_values, inputs=inputs, scale=2, # Finest scale (0=coarse, 2=fine) outputs=None, save_mesh=True ) # Output contains fused scene reconstruction: # outputs['scene_tsdf']: list of TSDF volumes # outputs['origin']: list of volume origins # outputs['scene_name']: list of scene identifiers # Reset global volume for new scene gru_fusion.reset(scale=2) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.