The use of run.py in instant-ngp

Instant-ngp is briefly introduced in https://blog.csdn.net/fengbingchun/article/details/129642774. Here is a brief introduction on how to use run.py.
1. If you can run run.py, you first need to use CMake to compile the instant-ngp source code, then call the .pyd file in it, and compile the instant-ngp source code through CMake on Windows:

(1). From https://github.com/NVlabs/instant-ngp clone code:

git clone --recursive https://github.com/nvlabs/instant-ngp

(2). Install cuda 11.6 on this machine, and install the four files under the C:\Program Files\\
VIDIA GPU Computing Toolkit\CUDA\v11.6\extras\visual_studio_integration\MSBuildExtensions directory CUDA 11.6. props, CUDA 11.6.targets, CUDA 11.6.xml, Nvda.Build.CudaTasks.v11.1.dll, copy to C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\ \Microsoft\VC\v160\BuildCustomizations directory;

(3). Open the Developer Command Prompt for VS 2019, and locate it in the instant-ngp directory, execute the following command, and the execution result is shown in the figure below:

cmake . -B build

(4). Execute the following command, and the execution result is shown in the figure below:

cmake --build build --config RelWithDebInfo -j

After execution, the executable file instant-ngp.exe will be generated in the current directory, and it can be run by double-clicking directly, indicating that the compilation is successful, as shown in the following figure:

After testing, executing the above command through Git Bash on Windows can also generate the executable file instant-ngp.exe normally.

Open instant-ngp.sln in the build directory, the result is as shown in the figure below:

2. Run run.py:
(1). After compiling with CMake, pyngp.cp39-win_amd64.pyd will be generated in the build directory. This pyd file is generated by python 3.9.13;

(2). Refer to https://blog.csdn.net/fengbingchun/article/details/129642774 to build the virtual environment instant-ngp2, locate it in the instant-ngp directory, and execute the following commands in sequence:

conda create -n instant-ngp2 python=3.9.13
conda activate instant-ngp2
pip install -r requirements.txt
conda install -c conda-forge colmap
conda install -c conda-forge ffmpeg
conda install -c conda-forge mpir

(3). Copy pyngp.cp39-win_amd64.pyd to the DLLs directory of the installation directory of instant-ngp2, here is C:\ProgramData\Anaconda3\envs\instant-ngp2\DLLs, otherwise execute run .py will report an error that ngp cannot be found;

(4). Execute the following command to get the usage instructions:

python scripts/run.py --help

3. Description of input parameters supported by run.py:

(1).–scene, –training_data: The default is empty, the scene to be loaded can be the name of the scene or the full path of the training data, such as training lego, save it as lego.ingp, execute the following command: the execution result is as follows As shown in the figure: The generated lego.ingp can be loaded by instant-ngp.exe, supported image formats: “png”, “jpg”, “jpeg”, “bmp”, ” gif”, “tga”, “pic”, “pnm”, “psd”, “exr”;

python scripts/run.py --scene "D:\fengbingchun\instant-ngp\data\\
erf\lego" --save_snapshot "lego.ingp"

(2).–mode: The default is empty and obsolete;

(3).–network: The default is empty, the path of network configuration, if not specified, use the default value of scene, such as instant-ngp\configs\\
erf\base.json;
(4).–load_snapshot, –snapshot: Default is empty, load this snapshot before train, recommended extension: .ingp or .msgpack;
(5).–save_snapshot: Default is empty, save this snapshot after training, recommended extension: .ingp or .msgpack;
(6).–nerf_compatibility: True if specified, False if not specified; match the parameters with the original NeRF. In some scenes, it may cause slower speed and worse effect, but in synthetic scenes (synthetic scenes ) helps to improve PSNR (Peak Signal to Noise Ratio, peak signal-to-noise ratio);
(7).–test_transforms: The default is empty, the path to the nerf style transforms json, we will calculate the PSNR from it, if the following command is executed, the execution result is shown in the figure below:

python scripts/run.py --scene "D:\fengbingchun\instant-ngp\data\\
erf\lego" --load_snapshot "lego.ingp" --save_snapshot " lego2.ingp" --nerf_compatibility --test_transforms "D:\fengbingchun\instant-ngp\data\\
erf\lego\transforms.json"

(8).–near_distance: The default value is -1, float type, set the camera distance for the start of train rays for nerf, <0 means use the default value of ngp;
(9).–exposure: The default value is 0.0, float type, controls the brightness of the image (brightness), positive value increases brightness, negative value decreases brightness;
(10).–screenshot_transforms: The default is empty, NeRF transforms.json file path;
(11).–screenshot_frames: list, specify the frames that need screenshots;
(12).–screenshot_dir: The default is empty, specify the path to save the screenshot;
(13).–screenshot_spp: The default value is 16, int type, the number of samples of each pixel in the screenshot, if you execute the following command, the execution result is shown in the figure below:

python scripts/run.py --scene "D:\fengbingchun\instant-ngp\data\\
erf\lego" --load_snapshot "lego.ingp" --save_snapshot " lego2.ingp" --screenshot_transforms "D:\fengbingchun\instant-ngp\data\\
erf\lego\transforms.json" --screenshot_dir "D:\fengbingchun" -- screenshot_frames (5, 10, 15) --screenshot_spp 8 --screenshot_w 400 --screenshot_h 400

(14).–video_camera_path: The default is empty, the camera path to be rendered, such as base_cam.json;
(15).–video_camera_smoothing: True if specified, False if not specified, apply smoothing to the camera trajectory (trajectory);
(16).–video_loop_animation: True if specified, False if not specified, connect the last and first keyframes in a continuous loop;
(17).–video_fps: The default value is 60, int type, the number of frames per second;
(18).–video_n_seconds: The default value is 1, int type, the number of seconds to render the video;
(19).–video_spp: The default value is 8, int type, the number of samples per pixel, a larger number means less noise, but slower rendering speed;
(20).–video_output: The default value is video.mp4, str type, the file name of the output video;
(21).–save_mesh: The default is empty. Export the mesh based on marching-cubes from the NeRF or SDF model. It supports OBJ or PLY format. The generated .obj file can be opened with a 3D viewer on windows;
(22).–marching_cubes_res: The default value is 256, int type, set the resolution of marching cubes grid, if you execute the following command, the execution result is shown in the figure below:

python scripts/run.py --scene "D:\fengbingchun\instant-ngp\data\\
erf\lego" --load_snapshot "lego.ingp" --save_mesh " lego_mesh.obj" --marching_cubes_res 512

(23).–width, –screenshot_w: The default value is 0, int type, resolution width of GUI and screenshot;
(24).–height, –screenshot_h: The default value is 0, int type, the resolution height of GUI and screenshot;
(25).–gui: True if specified, False if not specified, run the test platform GUI interactively, if you execute the following command, the execution result is shown in the figure below:

python scripts/run.py --scene "D:\fengbingchun\instant-ngp\data\\
erf\lego" --load_snapshot "lego.ingp" --save_mesh " lego_mesh.obj" --marching_cubes_res 512 --width 1920 --height 1080 --gui --train

(26).–train: True if specified, False if not specified, if the GUI is enabled, it controls whether to start training immediately;
(27).–n_steps: The default value is -1, int type, the number of steps to be trained before stopping (quitting);
(28).–second_window: True if specified, False if not specified, open the second window containing a copy of the main output;
(29).–vr: True if specified, False if not specified, render VR headset;
(30).–sharpen: The default value is 0, float type, set the amount of sharpening applied to the NeRF training image (amount of sharpening), range: [0.0, 1.0], if the following command is executed, the execution result is shown in the figure below Show:

python scripts/run.py --scene "D:\fengbingchun\instant-ngp\data\\
erf\lego" --save_snapshot "lego.ingp" --gui -- width 1920 --height 1080 --train --n_steps 500000 --sharpen 1.0