AI Training - Tutorial - Turn a video into a 3D model using NVIDIA Neuralangelo
Objective
The project
Neuralangelo is a research project led by NVIDIA allowing to perform High-Fidelity Neural Surface Reconstruction. Starting from a video of a scene or an object, it recovers 3D surface structures from the video keyframes through an AI model.
This tutorial
This tutorial aims at showing how to run NVIDIA sample use case with OVHcloud AI-Training jobs.
This tutorial scenario is based on Neuralangelo git repository and colab notebook.
After getting a sample video of a toy vehicle, we see how to put it through Neuralangelo model until we get a 3D mesh file.
The processing will follow 3 main steps :
- Data preparation
- Data processing
- 3D model extraction
Each step will be run using an AI-Training job and these jobs will share their data using an AI-Training volume synced with a S3* compatible Object Storage bucket.
Makefile
A Makefile is provided here to run each of these steps. For each step the command underneath will be described.
The 3 main steps (prepare, process, extract) have their targets in the Makefile built the same way:
- Submit an AI-Training job and keep its JSON representation in logs/ directory
- Use the JSON file to keep track of job ID and get status or logs
Requirements
Development tools:
- git
- make
- jq
- blender
- python/pip
OVHcloud account and tools
- Access to the OVHcloud Control Panel
- ovhai CLI installed
- An AI Training project created inside a Public Cloud project in your OVHcloud account
- A user for AI Training
Instructions
Prepare projects
Clone Neuralangelo and init git repositories:
Neuralangelo is the main project we will use, including Neuralangelo itself and the tools configuration such as COLMAP.
We need BlenderNeuralangelo for its tooling on top of Blender. We will use it to adjust our input data.
Actual commands:
Install gdown to fetch a Lego™ sample video:
Download the sample video:
Configure an S3 compatible Object Storage bucket using ovhai
To be able to share data between the AI Training jobs we will run as well as providing code and data to our workloads, we need to configure an AI datastore pointing to an S3 compatible endpoint.
Data store information (endpoint, region, access_key and secret key) can refer to an OVHcloud S3 compatible Object Storage bucket or any other provider.
Using --store-credentials-locally is needed here to be able to push/pull data from a bucket, using ovhai CLI in the next steps.
See this page for help about S3 compatible usage.
Prepare model input using COLMAP
Data preparation relies on the process described in Neuralangelo documentation.
Push the Neuralangelo project in the S3 compatible bucket
Actual command:
As a bucket shall be unique in an S3 compatible region, the Makefile uses the current username in the bucket name (experiments in this example).
Extract pictures from the video
Neuralangelo works on pictures of the Object. These pictures are extracted from the source video using COLMAP.
We are here triggering the extraction of pictures from the input video and generating data allowing us (in the next step) to adjust the area of interest we will ask Neuralangelo to work on.
Read detailed documentation for data preparation here.
Actual commands:
It takes approximately 8 minutes to run on 1 ai1-1-gpu GPU (V100S).
You can follow the training job status using the following commands based on ovhai job get and ovhai job logs:
Once the job is done, we get generated data from the S3 compatible bucket:
Actual command:
Adjust COLMAP results
To get better results, we need to adjust the results bounding sphere.
Detailed documentation is available here.
Here we chose the Blender from command line way:
Actual command:
Follow the process described here to adjust the bounding sphere.
Push the adjusted configuration in the S3 compatible bucket:
Process data and generate model
Now we are triggering an AI Training job running Neuralangelo to train its model over the input data prepared in the previous steps.
Actual commands:
To limit the time spent in processing, the iterations are set to 1000 but would need to be much more for a more detailed result (in Neuralangelo collab example, it is set to 20000).
Here the step should take approximately 5 min to run on 1 ai1-1-gpu GPU (1 hour for 20000 iterations).
You can follow the training job status using the following commands:
Once the job is done, we can run the 3D model extraction that will work with the model we just trained.
Extract meshes from model
The AI Training job we are running will now generate a 3D mesh .ply file out of the model:
Actual commands:
The checkpoint should be set to the latest .pt file generated by process step in the neuralangelo/logs/experiments/lego directory (the filename is stored in neuralangelo/logs/experiments/lego/latest_checkpoint.txt).
It takes approximately 3 min to run on 1 ai1-1-gpu GPU.
You can follow the training job status using the following commands:
Once the job is done, we get generated data from the S3 compatible bucket:
The .ply file is now available in neuralangelo/logs/experiments/lego/ and we are now able to open it with Blender.
Go further
Neuralangelo configuration
A small subset of parameters is tunable using the Make command. Each target can be tuned using a set of variables defined on top of the file. As an example, if you want to run the process step with another GPU flavor and over more iterations:
To get deeper into Neuralangelo configuration, it takes its configuration from the file
neuralangelo/projects/neuralangelo/configs/custom/lego.yaml generated by preparation step. Default values are set
in neuralangelo/projects/neuralangelo/configs/base.yaml.
It is possible to change it:
- either using
torchruncommand line parameters. - or editing the file directly and sync it to the S3 compatible bucket using
make data-push.
Checkpoints rendering
If the process is configured with a large amount of iterations, the processing can be long. As Neuralangelo creates intermediate checkpoints, we are able to try extraction on any intermediate model.
To perform this, we need use ovhai to trigger a data-push on the running job to sync the S3 compatible content and use
the previously described make extract command.
If you need training or technical assistance to implement our solutions, contact your sales representative or click on this link to get a quote and ask our Professional Services experts for a custom analysis of your project.
Feedback
Please send us your questions, feedback and suggestions to improve the service:
- On the OVHcloud Discord server
*: S3 is a trademark of Amazon Technologies, Inc. OVHcloud’s service is not sponsored by, endorsed by, or otherwise affiliated with Amazon Technologies, Inc.