vagheshpatel commited on
Commit
8dc949c
·
verified ·
1 Parent(s): 248e10c

Sync vehicle-detection from metro-analytics-catalog

Browse files
Files changed (2) hide show
  1. README.md +16 -14
  2. export_and_quantize.sh +8 -1
README.md CHANGED
@@ -1,6 +1,6 @@
1
  # Vehicle Detection
2
 
3
- > **Validated with:** OpenVINO 2026.1.0, NNCF 3.0.0, DLStreamer 2026.0, Ultralytics 8.3.0, Python 3.11+
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 yolo26n # default: FP16
 
 
 
 
 
 
 
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:** For production accuracy, replace the random calibration tensors in
87
- > `export_and_quantize.sh` with a representative sample of frames from the
88
- > target deployment site.
89
 
90
  ### OpenVINO Sample
91
 
@@ -223,15 +231,9 @@ def on_buffer(pad, info):
223
  return Gst.PadProbeReturn.OK
224
 
225
 
226
- it = pipeline.iterate_elements()
227
- while True:
228
- ok, elem = it.next()
229
- if not ok:
230
- break
231
- if elem.get_factory() and elem.get_factory().get_name() == "gvawatermark":
232
- pad = elem.get_static_pad("src")
233
- pad.add_probe(Gst.PadProbeType.BUFFER, on_buffer)
234
- break
235
 
236
  pipeline.set_state(Gst.State.PLAYING)
237
  bus = pipeline.get_bus()
 
1
  # Vehicle 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
 
 
231
  return Gst.PadProbeReturn.OK
232
 
233
 
234
+ sink = pipeline.get_by_name("sink")
235
+ sink_pad = sink.get_static_pad("sink")
236
+ sink_pad.add_probe(Gst.PadProbeType.BUFFER, on_buffer)
 
 
 
 
 
 
237
 
238
  pipeline.set_state(Gst.State.PLAYING)
239
  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 np.random.rand(1, 3, 640, 640).astype(np.float32)
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