Advanced Tutorial

This page explains advanced features for fine-tuning NeuralVDB encoder.

Fine-tuning the Compression

While encode_grids_with_auto_config with AutoConfigParams should cover most of the use cases, there can be a scenario where fine tuning the encoding and decoding processes is necessary. The following example shows how to use EncodeParams instead of AutoConfigParams.

import omni.volume
import omni.vdb.neuralvdb

# Acquire interfaces
ivolume = omni.volume.get_volume_interface()
ineuralvdb = omni.vdb.neuralvdb.get_neuralvdb_interface()

# Raed VDB file
volume = ivolume.create_from_file("my_volume.vdb")

# Create EncodeParams
encode_params = omni.vdb.neuralvdb.EncodeParams()

# Customize the encoding parameters
encode_params.neural_grid_params.tree_class = omni.vdb.neuralvdb.NeuralGridParams.TreeClass.NeuralValueTree;
encode_params.neural_grid_params.precision = omni.vdb.neuralvdb.NeuralGridParams.Precision.Float16
encode_params.voxel_value_params.num_neurons = 128
encode_params.voxel_value_params.feature_mapping.ffm_mapping_size = 256

...

# Encode
mvdb_volume = ineuralvdb.encode_grids(volume, encode_params)

In this example, we are configuring the encoder to encode voxel values only (NeuralGridParams.TreeClass.NeuralValueTree) and use 16-bit precision for the final network (NeuralGridParams.Precision.Float16). We are also making the neural network to have 128 neurons per hidden layer and use 256 feature mapping size. Higher number of these parameters will produce larger, slower, but accurate encoding. Please refer to the API document for more information about the parameters.

It is also possible to automatically create EncodeParams instance from a given VDB, and then fine-tune the specific parameters if needed.

import omni.volume
import omni.vdb.neuralvdb

...

# Create EncodeParams
auto_config_params = omni.vdb.neuralvdb.AutoConfigParams()
encode_params = omni.vdb.neuralvdb.auto_config_encode_params(volume, auto_config_params)

# Customize the encoding parameters
# Let the network training to spend at least 500 epochs and iterate at most 5000 times.
encode_params.voxel_value_params.optim.min_epochs = 500
encode_params.voxel_value_params.optim.max_epochs = 5000

...