Sync object-detection from metro-analytics-catalog
Browse files- README.md +16 -14
- export_and_quantize.sh +8 -1
README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
# Object Detection
|
| 2 |
|
| 3 |
-
> **Validated with:** OpenVINO 2026.1.0, NNCF 3.0.0, DLStreamer 2026.0, Ultralytics 8.
|
| 4 |
|
| 5 |
| Property | Value |
|
| 6 |
|---|---|
|
|
@@ -55,9 +55,17 @@ Run the provided script to download, export to OpenVINO IR, and optionally quant
|
|
| 55 |
|
| 56 |
```bash
|
| 57 |
chmod +x export_and_quantize.sh
|
| 58 |
-
./export_and_quantize.sh
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
./export_and_quantize.sh yolo26n FP32 # full-precision
|
| 60 |
./export_and_quantize.sh yolo26n INT8 # quantized
|
|
|
|
| 61 |
```
|
| 62 |
|
| 63 |
Replace `yolo26n` with any variant (`yolo26s`, `yolo26m`, `yolo26l`, `yolo26x`).
|
|
@@ -83,9 +91,9 @@ Output files:
|
|
| 83 |
| FP16 | Yes | Yes | Yes |
|
| 84 |
| INT8 | Yes | Yes | Yes |
|
| 85 |
|
| 86 |
-
> **Note:**
|
| 87 |
-
>
|
| 88 |
-
> target deployment site.
|
| 89 |
|
| 90 |
### OpenVINO Sample
|
| 91 |
|
|
@@ -230,15 +238,9 @@ def on_buffer(pad, info):
|
|
| 230 |
return Gst.PadProbeReturn.OK
|
| 231 |
|
| 232 |
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
if not ok:
|
| 237 |
-
break
|
| 238 |
-
if elem.get_factory() and elem.get_factory().get_name() == "gvawatermark":
|
| 239 |
-
pad = elem.get_static_pad("src")
|
| 240 |
-
pad.add_probe(Gst.PadProbeType.BUFFER, on_buffer)
|
| 241 |
-
break
|
| 242 |
|
| 243 |
pipeline.set_state(Gst.State.PLAYING)
|
| 244 |
bus = pipeline.get_bus()
|
|
|
|
| 1 |
# Object Detection
|
| 2 |
|
| 3 |
+
> **Validated with:** OpenVINO 2026.1.0, NNCF 3.0.0, DLStreamer 2026.0, Ultralytics 8.4.46, Python 3.11+
|
| 4 |
|
| 5 |
| Property | Value |
|
| 6 |
|---|---|
|
|
|
|
| 55 |
|
| 56 |
```bash
|
| 57 |
chmod +x export_and_quantize.sh
|
| 58 |
+
./export_and_quantize.sh
|
| 59 |
+
```
|
| 60 |
+
|
| 61 |
+
This exports the default **yolo26n** model in **FP16** precision.
|
| 62 |
+
|
| 63 |
+
#### Optional: Select a Different Variant or Precision
|
| 64 |
+
|
| 65 |
+
```bash
|
| 66 |
./export_and_quantize.sh yolo26n FP32 # full-precision
|
| 67 |
./export_and_quantize.sh yolo26n INT8 # quantized
|
| 68 |
+
./export_and_quantize.sh yolo26s # larger variant, default FP16
|
| 69 |
```
|
| 70 |
|
| 71 |
Replace `yolo26n` with any variant (`yolo26s`, `yolo26m`, `yolo26l`, `yolo26x`).
|
|
|
|
| 91 |
| FP16 | Yes | Yes | Yes |
|
| 92 |
| INT8 | Yes | Yes | Yes |
|
| 93 |
|
| 94 |
+
> **Note:** The INT8 calibration uses the bundled sample image.
|
| 95 |
+
> For production accuracy, replace it with a representative set of frames from
|
| 96 |
+
> the target deployment site.
|
| 97 |
|
| 98 |
### OpenVINO Sample
|
| 99 |
|
|
|
|
| 238 |
return Gst.PadProbeReturn.OK
|
| 239 |
|
| 240 |
|
| 241 |
+
sink = pipeline.get_by_name("sink")
|
| 242 |
+
sink_pad = sink.get_static_pad("sink")
|
| 243 |
+
sink_pad.add_probe(Gst.PadProbeType.BUFFER, on_buffer)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 244 |
|
| 245 |
pipeline.set_state(Gst.State.PLAYING)
|
| 246 |
bus = pipeline.get_bus()
|
export_and_quantize.sh
CHANGED
|
@@ -67,12 +67,19 @@ if [[ "${PRECISION}" == "INT8" ]]; then
|
|
| 67 |
import nncf
|
| 68 |
import openvino as ov
|
| 69 |
import numpy as np
|
|
|
|
| 70 |
|
| 71 |
core = ov.Core()
|
| 72 |
model = core.read_model('${MODEL_NAME}_openvino_model/${MODEL_NAME}.xml')
|
| 73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
def transform_fn(data_item):
|
| 75 |
-
return
|
| 76 |
|
| 77 |
calibration_dataset = nncf.Dataset(list(range(300)), transform_fn)
|
| 78 |
|
|
|
|
| 67 |
import nncf
|
| 68 |
import openvino as ov
|
| 69 |
import numpy as np
|
| 70 |
+
import cv2
|
| 71 |
|
| 72 |
core = ov.Core()
|
| 73 |
model = core.read_model('${MODEL_NAME}_openvino_model/${MODEL_NAME}.xml')
|
| 74 |
|
| 75 |
+
# Use the downloaded test image for calibration instead of random noise.
|
| 76 |
+
img = cv2.imread('test.jpg')
|
| 77 |
+
img = cv2.resize(img, (640, 640))
|
| 78 |
+
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB).astype(np.float32) / 255.0
|
| 79 |
+
img = img.transpose(2, 0, 1)[np.newaxis, ...] # NCHW
|
| 80 |
+
|
| 81 |
def transform_fn(data_item):
|
| 82 |
+
return img
|
| 83 |
|
| 84 |
calibration_dataset = nncf.Dataset(list(range(300)), transform_fn)
|
| 85 |
|