Class filtering
Learn how to filter model outputs by class to reduce clutter, streamline downstream logic, and focus on what matters to your application.
Estimated read time: 4 minutes
Models are often trained on many labels (e.g., COCO’s 80), but your application may only need a subset.
Use model.label_dictionary to see exactly which labels a model predicts (for detection, classification, or segmentation). Then, optionally restrict outputs to the classes you care about using output_class_set—reducing clutter and simplifying downstream logic.
Inspect labels without filtering

Use this baseline run to confirm label names before filtering. Knowing the exact strings ensures you pass the right values to output_class_set later.
Example
Expect console output similar to the snippet below.
Example
Filter to a subset of classes

Apply class filtering to focus overlays and downstream logic on just the labels you need. Adjust the set before loading the model so every result reports only the chosen classes.
Example
Last updated
Was this helpful?

