EfficientDet-D0
Object detection with EfficientDet-D0 trained on COCO. The model was originally
distributed as a frozen TensorFlow graph (efficientdet-d0.pb) and converted to
ONNX for use with OpenCV's DNN module. This is a backbone-only export: the
graph emits raw class logits and box regressions, while anchor generation, sigmoid,
box decoding and non-maximum suppression are performed in host code (see the demos).
Model Details
- Architecture: EfficientDet-D0
- Input: RGB image, 512×512, raw uint8, NHWC layout (
image_arrays:0, shape[1, 512, 512, 3]) - Output: raw class logits (
concat:0, shape[1, 49104, 90]) and box regression (concat_1:0, shape[1, 49104, 4]); anchor decode + NMS are done in host code, not in the graph - Framework: ONNX (converted from the TensorFlow frozen graph via tf2onnx, opset 18)
- Original weights: https://www.dropbox.com/s/9mqp99fd2tpuqn6/efficientdet-d0.pb?dl=1
The graph outputs are per-anchor predictions only. The demos build the 49104 anchors (5 pyramid levels × 9 anchors/cell), apply sigmoid to the logits, decode the box regressions relative to the anchors, threshold on confidence and run NMS (IoU 0.6).
Usage
Python
python demo.py --model efficientdet-d0_2026jul.onnx --image example_outputs/input_image.png --output example_outputs/output_image.png --conf 0.4
Or import directly:
import cv2
net = cv2.dnn.readNet("efficientdet-d0_2026jul.onnx")
# see demo.py for the full anchor decode + NMS pipeline
C++
The C++ demo runs inference with OpenCV's DNN module. Adjust the OpenCV paths to your setup:
OCV=/path/to/opencv # OpenCV source tree
OCVBUILD=/path/to/opencv/build # OpenCV build directory (generated headers + libs)
g++ -std=c++17 demo.cpp -o demo \
-I$OCV/include \
-I$OCV/modules/core/include \
-I$OCV/modules/dnn/include \
-I$OCV/modules/imgproc/include \
-I$OCV/modules/imgcodecs/include \
-I$OCVBUILD \
-L$OCVBUILD/lib -Wl,-rpath,$OCVBUILD/lib -lopencv_dnn -lopencv_imgcodecs -lopencv_imgproc -lopencv_core
./demo --model efficientdet-d0_2026jul.onnx --image example_outputs/input_image.png --output example_outputs/output_image.png
Conversion
The ONNX model was exported from the frozen TensorFlow graph with tf2onnx (opset 18)
via convert_to_onnx.py — input image_arrays:0, outputs
concat:0 and concat_1:0, input shape overridden to [1, 512, 512, 3]. Requires
tensorflow, tf2onnx, and onnx.
python convert_to_onnx.py --pb ../pb/efficientdet-d0.pb
License
See LICENSE — released under the Apache License 2.0.