On this page

This workflow covers the full computer vision process within Houdini using the top_computervision.hip example file. This process allows you to take a video, isolate an object of interest, train a model on that dataset, and then run the model on the video to isolate that object throughout the video.

At a high level, the workflow within Houdini is:

  1. In the video, mask out selected frames by hand using the Paint 3D COP or other DCC programs.

  2. Use the ML Preprocess Computer Vision TOP to create a dataset on disk.

  3. Train the model using that dataset with ML Train Computer Vision TOP.

  4. Use ML Computer Vision Inference COP to apply the trained data to the video, masking out the object of interest in the remaining frames.

Prerequisites

Locate the $HH/help/files/pdg_examples/top_computervision folder. You will find a top_computervision.hip file for Houdini and an input.mp4 as the video source.

If you want to use your own sources, you need:

  • A video source or image sequence that has a target object of interest.

  • A method to create a mask for selected frames. This can be done within Houdini or in another DCC program.

Preparing your images

The first step is to mask out your object of interest from the video. The goal is to create enough examples for the model to learn from the object without hand masking the full video.

  • Before selecting your training frames, you may want to clean up the source footage. For example, crop out black borders or other unwanted image artifacts so the model trains on the actual content you want to detect.

  • Select a number of frames relative to your video length. In the example, the video is 10 seconds at 30fps and has 300 frames. A rough recommendation is to mask out at least 10 of these frames by hand to create a better and more accurate dataset.

  • Choose frames that represent a good range of cases the training model will see in the next stage. Good examples include frames where the object appears from different angles, close to the edge of the frame, or slightly cutoff.

  • The masks do not need to be a perfect one-to-one match to the object of interest. In the example, you can see the logo is roughly masked out using a brush stroke.

  • To prepare your images, you can use a node like Paint 3D COP or a DCC software.

In the example file, open the training_data geometry node, then the copnet1 COP Network.

  • The input.mp4 file is connected to a batch of Time Shift COP node node to select the desired frames for the training stage.

    • These frames are then masked out using a Paint 3D COP node at the position of the object of interest.

Preprocess for dataset generation

The ML Preprocess Computer Vision TOP prepares image datasets for the computer vision training tasks. It prepares a .json file that uses the same format as the COCO dataset to represent the images, sizes, and masks. The generated dataset folder that contains the source images, mask images, and COCO .json. These can then be trained using the ML Train Computer Vision TOP.

To generate a dataset:

  1. In the example file, locate the topnet TOP network. Then the Preprocess Computer Vision TOP node.

  2. Set the Object Classes. The example uses Logo as the class for the blurred out logo.

    • The Class Color is an optional setting and is more for visualization purposes.

  3. Choose how to Input Images. There are multiple methods to input images such as dictionary attributes, multi-aov EXRs, and COP nodes. See Input Format for more information.

    • The example uses the COP Nodes as the Input Source. The Source COP and Mask COP parameters point to the selected frames and masked out frames.

  4. Set your Evaluating Using option. This example uses a Custom Range which allows for more control to set a single frame, frame range, or skip certain frames.

    • This can be useful to skip frames where your object of interest pans out of the camera in certain frames.

  5. Cook the node.

  6. Review the generated dataset folder.

    • It should contain the source images, mask images, and COCO format .json file. You will then use the generated dataset directory as the input dataset for the ML Train Computer Vision TOP node.

Train a Computer Vision model

The ML Train Computer Vision TOP trains an object detection, masking, or keypoint detection model using a dataset prepared by the ML Preprocess Computer Vision TOP. This means the node uses the generated dataset folder including the COCO .json, masks, and source images to train.

There are various parameters that change how your dataset is trained. You can read descriptions for each parameter in the node’s parameters section. Some of the tabs such as Checkpointing, Execution, and Schedulers are similar to other TOPs and ML nodes. Here’s a brief description of each tab:

Tab

Description

Data

Defines the dataset directory, training output directory, image loading settings, input configuration, and input randomization.

Network

Controls the computer vision model setup. For most users, it’s recommended to choose a built-in preset using Pre-Trained Weights. Then use Download Weights if the preset weights are not already installed.

Training

Controls the training process including Max Epochs, log/config output, mixed precision, optimizer settings, and learning rate.

Testing

Controls validation and visual test output during training. Validation records numeric metrics, while testing generates image results that can be inspected in the Training Monitor.

Checkpointing

Controls PyTorch model checkpoints and ONNX export. The exported ONNX file is used later by the ML Computer Vision Inference COP node.

Execution

Controls the training runtime environment including Python/virtual environment settings, device selection, CPU thread count, and single work item training.

Schedulers

Controls PDG/TOP scheduling behavior, not the machine learning model itself.

Train data in example file
  1. In the example file, locate the ML Train Computer Vision TOP node in the TOP network.

  2. In the Input Data Source tab, you input your generated dataset from the previous stage here.

    • To get started, it’s recommended to use a pre-trained weight in the Network tab instead of setting things manually.

  3. Cook the node.

    • Make sure you have your pre-trained weights downloaded or it may cause an error.

The results will be located in the folder specified in the Output Directory parameter. This folder contains the following:

config - Stores training configuration files and logs. Use it to inspect or reproduce the settings used for the run.

models - Stores model checkpoints and exported model files. PyTorch checkpoints can be used to resume or preserve training states. ONNX files are exported models that can be used for inference.

plots - Stores training-progress data used by the Training Monitor. These plots show values such as loss/error and validation metrics. This helps you judge whether training is improving.

tests - Stores visual test images generated during training. These images show what the model detected at different checkpoints making it easier to inspect false positives, missed objects, and overall model quality.

Validation outputs may also be written as CSV files. These store numerical validation metrics and are automatically detected by the Training Monitor.

Image from the tests folder showing the confidence

Training monitor panel

You can inspect the training progress using the PDG ML Training Monitor Panel or checking the output files on disk.

The monitor displays:

  • Loss and error graphs which should generally trend downwards towards zero.

  • Validation metrics which should improve upward over time.

  • Visual test results showing what the model detected at different training checkpoints.

Using the trained model: interactive or render to disk

The example files provides two methods to use your trained data.

  1. Use the ROP Image Output TOP and FFmpeg Encode Video TOP to render the inference result to disk.

  2. Use the ML Computer Vision Inference COP interactively in Houdini.

These two methods use the same trained model and inference COP network. The difference is mainly where and how the result is viewed or written.

In the example TOP network, the _ROP Image Output TOP cooks the same inference COP network. The difference is that it runs the COP result as a PDG background task and writes the resulting frames to disk.

Then, the FFmpeg Encode Video TOP assembles those rendered frames into a final movie file, such as an .mp4.

Run inference on trained model using COPs

The ML Computer Vision Inference COP applies an ONNX model trained using the ML Train Computer Vision TOP to detect and mask objects in an input image.

This is the final stage of the computer vision workflow. After the model has been trained and exported as an ONNX file, the inference COP applies that trained model back to the source video or image sequence to detect the target object in frames that were not manually masked.

  1. In the example file, locate the inference SOP network. Then select the ML Computer Vision Inference COP node.

    • You can see a video or image sequence source is connected to the node. This is the same video generated using the FFMpeg method.

  2. In the Model File parameter, select one of the .onnx models generated in the earlier stages.

  3. Select the same Detect Type that matches the model. The example uses Masks.

  4. Adjust the Minimum Confidence as needed.

    • This adjusts the minimum confidence value for detecting objects. Detections below this threshold will be discarded. If the confidence is too low, false positives may appear.

  5. Set the display flag on the blur1 node.

    • You can now see the video displayed in the viewport. Scrub the timeline to play back the video.

Executing tasks with PDG/TOPs

Basics

Beginner Tutorials

Next steps

  • Running external programs

    How to wrap external functionality in a TOP node.

  • File tags

    Work items track the results created by their work. Each result is tagged with a type.

  • PDG Path Map

    The PDG Path Map manages the mapping of paths between file systems.

  • Feedback loops

    You can use for-each blocks to process looping, sequential chains of operations on work items.

  • Service Blocks

    Services blocks let you define a section of work items that should run using a shared Service process

  • PDG Services

    PDG services manages pools of persistent Houdini sessions that can be used to reduce work item cooking time.

  • Integrating PDG with render farm schedulers

    How to use different schedulers to schedule and execute work.

  • Visualizing work item performance

    How to visualize the relative cook times (or file output sizes) of work items in the network.

  • Event handling

    You can register a Python function to handle events from a PDG node or graph

  • Tips and tricks

    Useful general information and best practices for working with TOPs.

  • Troubleshooting PDG scheduler issues on the farm

    Useful information to help you troubleshoot scheduling PDG work items on the farm.

  • PilotPDG

    Standalone application or limited license for working with PDG-specific workflows.

Reference

  • All TOPs nodes

    TOP nodes define a workflow where data is fed into the network, turned into work items and manipulated by different nodes. Many nodes represent external processes that can be run on the local machine or a server farm.

  • Processor Node Callbacks

    Processor nodes generate work items that can be executed by a scheduler

  • Partitioner Node Callbacks

    Partitioner nodes group multiple upstream work items into single partitions.

  • Scheduler Node Callbacks

    Scheduler nodes execute work items

  • Custom File Tags and Handlers

    PDG uses file tags to determine the type of an output file.

  • Python API

    The classes and functions in the Python pdg package for working with dependency graphs.

  • Job API

    Python API used by job scripts.

  • Utility API

    The classes and functions in the Python pdgutils package are intended for use both in PDG nodes and scripts as well as out-of-process job scripts.