LogoLogo
AI HubCommunityWebsite
  • Start Here
  • AI Hub
    • Overview
    • Quickstart
    • Teams
    • Device Farm
    • Browser Inference
    • Model Zoo
      • Hailo
      • Intel
      • MemryX
      • BrainChip
      • Google
      • DeGirum
      • Rockchip
    • View and Create Model Zoos
    • Model Compiler
    • PySDK Integration
  • PySDK
    • Overview
    • Quickstart
    • Installation
    • Runtimes and Drivers
      • Hailo
      • OpenVINO
      • MemryX
      • BrainChip
      • Rockchip
      • ONNX
    • PySDK User Guide
      • Core Concepts
      • Organizing Models
      • Setting Up an AI Server
      • Loading an AI Model
      • Running AI Model Inference
      • Model JSON Structure
      • Command Line Interface
      • API Reference Guide
        • PySDK Package
        • Model Module
        • Zoo Manager Module
        • Postprocessor Module
        • AI Server Module
        • Miscellaneous Modules
      • Older PySDK User Guides
        • PySDK 0.16.0
        • PySDK 0.15.2
        • PySDK 0.15.1
        • PySDK 0.15.0
        • PySDK 0.14.3
        • PySDK 0.14.2
        • PySDK 0.14.1
        • PySDK 0.14.0
        • PySDK 0.13.4
        • PySDK 0.13.3
        • PySDK 0.13.2
        • PySDK 0.13.1
        • PySDK 0.13.0
    • Release Notes
      • Retired Versions
    • EULA
  • DeGirum Tools
    • Overview
      • Streams
        • Streams Base
        • Streams Gizmos
      • Compound Models
      • Inference Support
      • Analyzers
        • Clip Saver
        • Event Detector
        • Line Count
        • Notifier
        • Object Selector
        • Object Tracker
        • Zone Count
  • DeGirumJS
    • Overview
    • Get Started
    • Understanding Results
    • Release Notes
    • API Reference Guides
      • DeGirumJS 0.1.3
      • DeGirumJS 0.1.2
      • DeGirumJS 0.1.1
      • DeGirumJS 0.1.0
      • DeGirumJS 0.0.9
      • DeGirumJS 0.0.8
      • DeGirumJS 0.0.7
      • DeGirumJS 0.0.6
      • DeGirumJS 0.0.5
      • DeGirumJS 0.0.4
      • DeGirumJS 0.0.3
      • DeGirumJS 0.0.2
      • DeGirumJS 0.0.1
  • Orca
    • Overview
    • Benchmarks
    • Unboxing and Installation
    • M.2 Setup
    • USB Setup
    • Thermal Management
    • Tools
  • Resources
    • External Links
Powered by GitBook

Get Started

  • AI Hub Quickstart
  • PySDK Quickstart
  • PySDK in Colab

Resources

  • AI Hub
  • Community
  • DeGirum Website

Social

  • LinkedIn
  • YouTube

Legal

  • PySDK EULA
  • Terms of Service
  • Privacy Policy

© 2025 DeGirum Corp.

On this page
  • Result Analyzer Base Module Overview
  • Key Concepts
  • Typical Usage Example
  • Classes
  • ResultAnalyzerBase
  • Functions
  • image_overlay_substitute(result, ...)
  • clone_result(result)

Was this helpful?

  1. Resources
  2. Archive and Test Pages
  3. DeGirum Tools API Reference Guide Staging

Analyzers

This API Reference is based on DeGirum Tools version 0.16.6.

Result Analyzer Base Module Overview

This module provides a base class (ResultAnalyzerBase) for performing custom post-processing and image annotation on DeGirum PySDK inference results. These analyzers can be used with compound models, streaming gizmos, and regular models to add advanced data processing and annotation steps to inference pipelines.

Key Concepts

  • Analysis: By overriding the analyze() method, child classes can read and augment the InferenceResults (e.g., by adding extra keys to the internal results list).

  • Annotation: By overriding the annotate() method, child classes can draw additional overlays on the original input image (e.g., bounding boxes, text labels, or any custom markings).

  • Integration: Analyzers can be attached to a model or a compound model via the attach_analyzers() method, so their analysis and annotation is automatically applied to each inference result.

Typical Usage Example

  1. Create a custom analyzer subclass:

    from degirum_tools.result_analyzer_base import ResultAnalyzerBase
    
    class MyCustomAnalyzer(ResultAnalyzerBase):
        def analyze(self, result):
            # E.g., add custom fields to each detection
            for r in result.results:
                r["custom_info"] = "my_data"
    
        def annotate(self, result, image):
            # E.g., draw text or bounding boxes on the image
            # Return the annotated image
            return image
    
  2. Attach it to a model or compound model:

    model.attach_analyzers(MyCustomAnalyzer())
    
  3. Run inference. Each InferenceResults object will be passed through your analyzer, optionally modifying the result data and providing a new overlay.

Classes

ResultAnalyzerBase

ResultAnalyzerBase

Bases: ABC

Base class for result analyzers which can modify or extend the content of inference results and optionally annotate images with new data.

Subclasses should override

  • analyze(result): to augment or inspect the inference result.

  • annotate(result, image): to draw additional overlays or text onto the provided image.

Functions

__del__

__del__()

Called when the analyzer object is about to be destroyed.

Invokes finalize() to ensure any open resources are cleaned up.

analyze(result)

analyze(result)

abstractmethod

Analyze and optionally modify a DeGirum PySDK inference result.

This method should access and potentially modify result.results (the list of detections, classifications, or similar structures) to add any custom fields. These modifications will then appear in downstream processes or when the result is displayed/serialized.

Parameters:

Name
Type
Description
Default

result

InferenceResults

The inference result object to analyze. Subclasses can read and/or modify the internal results list or other properties.

required

analyze_and_annotate(result, ...)

analyze_and_annotate(result, image)

Helper method to perform both analysis and annotation in one step.

  1. Calls self.analyze(result).

  2. Calls self.annotate(result, image).

Parameters:

Name
Type
Description
Default

result

InferenceResults

The inference result object to process.

required

image

ndarray

The image to annotate.

required

Returns:

Type
Description

ndarray

numpy.ndarray: The annotated image after analysis.

finalize

finalize()

Perform any finalization or cleanup actions before the analyzer is discarded.

This can be useful for analyzers that accumulate state (e.g., for multi-frame analysis). By default, this does nothing.

Functions

image_overlay_substitute(result, ...)

image_overlay_substitute(result, analyzers)

Substitute the image_overlay property of the given inference result object so that future calls to result.image_overlay automatically apply the analyzers'annotate() methods.

This method creates a new class that inherits from the original result class and overrides the image_overlay property. The new class does the following:

  1. Calls the base class's image_overlay property to get the image annotated by original result class.

  2. Applies each analyzer's annotate() method to the image, in order.

Parameters:

Name
Type
Description
Default

result

InferenceResults

The inference result whose image_overlay property will be replaced.

required

analyzers

A list of analyzer objects to apply for annotation.

required

clone_result(result)

clone_result(result)

Create a shallow clone of a DeGirum PySDK inference result object, duplicating the internal inference results list but reusing references to the original image.

This is useful when you want to create a separate copy of the result for further modifications without altering the original.

Parameters:

Name
Type
Description
Default

result

InferenceResults

The inference result object to clone.

required

Returns:

Type
Description

InferenceResults

A cloned result object with result._inference_results deep-copied.

Last updated 5 days ago

Was this helpful?

List[]

ResultAnalyzerBase