Skip to content

ONNX export for single-class YOLOv7: confidences not normalized (Frigate/OpenVINO integration issue) #2138

@kerotonic

Description

@kerotonic

Hello,

I’ve trained a YOLOv7 single-class model for rodent detection (class: rat) and I’m exporting to ONNX for use in Frigate with OpenVINO.

Export command:

python3 export.py --weights best.pt \
  --grid --end2end --simplify \
  --topk-all 100 --iou-thres 0.45 --conf-thres 0.25 \
  --img-size 320 320 --max-wh 320

Issue:

  • The exported ONNX runs, but confidence scores are raw logits instead of probabilities.
  • In Frigate, this shows up as huge scores (e.g. score=248.0 (logs) or 20000% (Explore view)) and can crash tracking with NaNs.
  • When I try --include-nms, the export succeeds but ONNX contains EfficientNMS_TRT nodes, which OpenVINO does not support.

What I tried:

  • Suggested by AIs (ChatGPT, Gemini), attempted to patch export.py or Detect.forward_export to apply sigmoid() to objectness.
  • Also tried modifying models/yolo.py so that objectness and class scores go through sigmoid before export.
  • Still struggling to get a clean ONNX that:
    • has normalized confidences [0–1],
    • does not depend on TensorRT-specific ops.

Questions:

  • Is there an officially recommended way to export YOLOv7 for single-class use cases, ensuring objectness is normalized in ONNX?
  • Has anyone tested ONNX + OpenVINO pipelines (without EfficientNMS) for YOLOv7?

Thanks for any guidance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions