Skip to main content
SDK Version: Next
DX-APP manual (PDF)

DX-APP Python Post-processing

Overview​

The dx_postprocess module provides high-performance Python bindings for the DEEPX C++ post-processing library. By utilizing pybind11, it allows Python applications to execute hardware-optimized decoding logic with near-native C++ performance.

Performance Benefits

Integrating C++ post-processing into your Python pipeline offers two primary advantages

  • Stage Acceleration: The post-processing operation itself (e.g., NMS, coordinate scaling) is significantly faster than native Python implementations.
  • Pipeline-Wide Improvement: End-to-end FPS gains occur in specific scenarios.
    • Primary Bottleneck: When the post-processing stage is the slowest part of the pipeline.
    • CPU Contention: In CPU-constrained environments (e.g., embedded boards), reduced CPU usage in the post-processing stage helps other stages (Read, Preprocess) and NPU utilization function more efficiently.
NOTE

While the C++ library is faster, overall pipeline improvement depends on the bottleneck location. If NPU inference or data reading is the limiting factor, end-to-end FPS gains may be minimal, though CPU power consumption will still decrease.

For end-to-end Python example usage, refer to DX-APP Python Example Usage Guide.


Technical Strategy & Support​

Technical Strategy​

The SDK follows a Single Source of Truth strategy to ensure reliability across platforms:

  • Implementation: C++ post-processing classes are wrapped with pybind11 for seamless Python integration.
  • Unified Logic: It directly wraps the C++ source in src/postprocess/, so a class used from Python runs the same decoding as that C++ library.
  • Build System: Utilizes CMake with scikit-build-core for robust, cross-platform extension building.
  • Source Code Locations:
    • Python Bindings: src/bindings/python/dx_postprocess/postprocess_pybinding.cpp
    • C++ Implementations: src/postprocess/

Supported Models & Tasks​

The library wraps 58 C++ post-processing classes with pybind11 bindings, ensuring consistent results between C++ and Python implementations.

  • Object Detection: YOLOv4, YOLOv5, YOLOv7, YOLOv8, YOLOv9, YOLOv10, YOLOv11, YOLOv12, YOLOv26, YOLOX, NanoDet, DAMOYOLO, SSD, CenterPose, EfficientDet, RT-DETR (v1/v2/v3), PP-PicoDet (PP-ShiTu mainbody), YOLO26 pre-optimized (top-k table; detection and pose)
  • Face Detection: SCRFD, YOLOv5Face, RetinaFace, ULFGFD
  • Face Landmark: Face3D (3DDFA-v2)
  • Pose Estimation: YOLOv5Pose, YOLOv8Pose, VitPose, CenterPose
  • Keypoint Detection: SuperPoint
  • Object Pose Estimation: DOPE
  • 3D Object Detection: SFA3D
  • Panoptic Driving Perception: YOLOPv2
  • Hand Detection: MediaPipe Hand
  • Semantic Segmentation: DeepLabV3, SemanticSeg (BiSeNet/SegFormer)
  • Instance Segmentation: YOLOv5Seg, YOLOv8Seg, YOLACT, mask-RT-DETR
  • Image Matting: PP-Matting (alpha matte at the model resolution; the examples resize it)
  • OBB Detection: YOLOv26-OBB
  • Classification: ClassificationPostProcess (all image-classification families, e.g. EfficientNet, ResNet, RegNet)
  • Attribute Recognition: AttributePostProcess (person attribute, face attribute)
  • Depth Estimation: DepthPostProcess (FastDepth, SCDepth, Depth Anything V2, YOLO26-depth)
  • Image Denoising: DnCNN
  • Super Resolution: ESPCN, RealESRGAN
  • Image Enhancement: Zero-DCE
  • Embedding: ArcFace, CLIP text encoder
  • Hand Landmark: HandLandmark
  • Anomaly Detection: EfficientAD (teacher + student + autoencoder outputs), AnomalyFeature (PatchCore backbone response). Both return the anomaly map at feature-map resolution; the Python examples resize it to the image with OpenCV.
  • PPU Variants: YOLOv5-PPU, YOLOv7-PPU, YOLOv8-PPU, SCRFD-PPU, YOLOv5Pose-PPU, YOLOX-PPU, YOLOv3Tiny-PPU. SCRFD-PPU and YOLOv5Pose-PPU are postprocess classes only; SCRFD500M_PPU and YOLOV5Pose_PPU are not registered examples.
Generic fast segmentation in Python examples

FastSegmentationPostprocessor is available from common.processors for Python example-layer semantic segmentation. It is intentionally generic and selected by the fast_segmentation generation alias. It is not a direct dx_postprocess pybind class; use it from src/python_example/common/processors/fast_segmentation_postprocessor.py when the model outputs low-resolution logits or class maps that should be argmaxed before resize.


Installation & Setup​

Prerequisites​

Before building, ensure the following are installed on your system

  • Python: 3.8 or higher
  • Compiler: C++14-compatible (GCC 7.5+, Clang, etc.)
  • Build Tool: CMake 3.16 or higher

pybind11 is installed by pip as a build dependency (pyproject.toml) and found with find_package(pybind11).

Installation Steps​

The module is automatically built during the standard SDK build, but it can also be installed independently from the binding directory.

MethodCommandRecommended For
Default Build (minimal)./build.shStandard developer build; builds run_demo C++ targets and installs dx_postprocess
Full Build./build.sh --allFull SDK deployment (all targets) — requires explicit --all flag
Standalonecd ./src/bindings/python/dx_postprocess && python3 -m pip install .Focused updates to the post-processing logic

Standalone Installation Notes

The standalone installation uses the local pyproject.toml and the configured Python packaging backend. Ensure your active Python environment has access to the required build dependencies before running python3 -m pip install ..

Verification

To ensure the module is correctly linked to your Python environment, run:

python3 -c "import dx_postprocess; print('dx_postprocess successfully installed!')"

Usage Guide & Running Examples​

The dx_postprocess classes expect a list of NumPy arrays directly from the InferenceEngine.

Running Examples​

# Python examples in src/python_example/ utilize this library in their '_cpp_postprocess.py' variants.
# From dx_app/ directory

# Sync (Image Inference)
python src/python_example/object_detection/yolov9/yolov9-s_640x640/yolov9-s_640x640_sync_cpp_postprocess.py --image sample/img/sample_kitchen.jpg

# Async (Stream Inference)
python src/python_example/object_detection/yolov9/yolov9-s_640x640/yolov9-s_640x640_async_cpp_postprocess.py --video assets/videos/dance-group.mov

Each *_cpp_postprocess.py script defines an on_engine_init(runner) callback and passes it to run_entry(). Once the engine reports the model input size, the callback creates the model's dx_postprocess class (for example YOLOv8PostProcess or ClassificationPostProcess) and sets it as runner._cpp_postprocessor, so the C++ class replaces the Python postprocessor. dx_postprocess is imported inside the callback, so --help works before the module is built.

Direct API Call​

from dx_postprocess import YOLOv9PostProcess
import numpy as np

# Initialize the optimized C++ post-processor
postprocessor = YOLOv9PostProcess(
input_w=640,
input_h=640,
score_threshold=0.25,
nms_threshold=0.45,
is_ort_configured=True
)

# Post-process inference output
# ie_output is a list of numpy arrays from InferenceEngine
detections = postprocessor.postprocess(ie_output)

# detections is a numpy array with shape (N, 6)
# Each row: [x1, y1, x2, y2, confidence, class_id]