Basic Inference
-
Perform a health check on the gRPC endpoint.
-
Install
grpcurlfrom github.com/fullstorydev/grpcurl/releases.Example commands to run on Ubuntu:
-
Download the health checking proto:
-
Run the health check:
If the service is ready, you get a response similar to the following:
For using grpcurl with an SSL-enabled server, avoid using the
--plaintextargument, and use--cacertwith a CA certificate,--keywith a private key, or--certwith a certificate file. For more details, refer togrpcurl --help. -
-
Download the Relighting client code by cloning the gRPC client repository (NVIDIA AI for Media NIM Clients):
-
For the Python client, install the required dependencies:
Compile the Protos (Optional)
If you want to use the client code provided in the NIM Clients GitHub repository (NVIDIA AI for Media NIM Clients), you can skip this step.
The proto files are available in the relighting/protos folder. You can compile them to generate client interfaces in your preferred programming language. For more details, refer to Supported languages in the gRPC documentation.
The following example shows how to compile the protos for Python and Node.js on Linux and Windows.
Python
The grpcio version needed for compilation can be referred from requirements.txt
To compile protos on Linux, run the following commands:
To compile protos on Windows, run the following commands:
Running Inference via Python Script
You can use the sample client script in the NVIDIA AI for Media NIM Clients repo to send a gRPC request to the hosted NIM server:
-
Go to the Python relighting directory.
-
Run the command to send a gRPC request. (All command-line parameters are optional.)
-
The Relighting NIM supports both streaming and transactional modes. The server automatically selects the appropriate mode based on whether the input video is streamable (indicated by metadata at the start of the file). Streamable inputs are preferred for large files. For more information, see Input Modes.
The first inference is not indicative of the model’s actual performance because it includes the time taken by the Triton Inference Server to load the models for the first time. The subsequent inference requests reflect the actual processing performance.
For Blackwell GPUs, the initial inference might time out because of the time needed to load the models. If timeout occurs, send another request; subsequent inferences reflect the actual processing performance.
To view details of command-line arguments, run the following command:
You get a response similar to the following:
To get more information about how to run the client with these parameters, refer to the NVIDIA AI for Media NIM Clients GitHub repository: NVIDIA AI for Media NIM Clients.
For more information about configuring advanced parameters such as bitrate, IDR interval, HDR settings, and background options, see Advanced Usage.
For command-line arguments that aren’t specified, the script uses the following default values.
Default Command-Line Arguments
Example Commands
-
Basic inference with default arguments:
-
Run inference with custom input file and HDR preset:
-
Run inference with a streamable video (server auto-selects streaming mode):
-
Run inference with custom HDR file:
-
Run inference with blurred background:
-
Run inference with custom background image:
Supported Formats
The supported format for input video is MP4 with H.264 video encoding.
Input Modes
Relighting provides two modes for processing input files: streaming and transactional.
Streaming Mode
Streaming mode is the recommended way to use Relighting. It allows inference to begin without receiving the whole video from the client. It processes video frames incrementally, and inference begins as soon as the first frame of information is available. The output frames are streamed back to the client immediately after inference.
The NIM automatically detects streamable videos and enables streaming mode. This mode delivers the lowest latency, best resource efficiency, and scales well to large files.
Use streaming mode for the following use cases:
- Best overall performance—the NIM is optimized for this path.
- Streamable video inputs.
- Applications that benefit from receiving output as it is generated, without waiting for the entire file to be uploaded.
- Large video files that benefit from incremental processing and reduced disk I/O.
Streaming mode works with streamable videos in which metadata is positioned at the beginning of the file. The NIM automatically detects streamable videos and enables streaming mode. Videos that are not streamable can be easily converted to a streamable format.
To convert your video into a streamable video, use FFmpeg with the -movflags +faststart option:
You can then specify the streamable video as input to the NIM by using the --video-input parameter:
Transactional Mode
In transactional mode, the entire video and audio files have to be received by the NIM before processing can begin. The NIM falls back to this mode when the input video is not streamable.
Transactional mode is suitable for the following use cases:
- Videos that are not optimized for streaming (such as non-streamable MP4 files in which metadata is located at the end of the file, requiring the entire file to be downloaded before playback can begin).
- Processing of small video and audio files for which streaming overhead is unnecessary.
- Applications that can wait for complete processing before receiving output.
To run Relighting in transactional mode, provide a non-streamable video as input:
For best performance, convert your videos to a streamable format so that the NIM can use streaming mode.