vagheshpatel commited on
Commit
4dfd5e4
·
verified ·
1 Parent(s): d33db61

Sync vehicle-detection from metro-analytics-catalog

Browse files
README.md CHANGED
@@ -1,6 +1,25 @@
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
  |---|---|
@@ -78,7 +97,7 @@ The second argument selects the precision (`FP32`, `FP16`, `INT8`); the default
78
  The script performs the following steps:
79
 
80
  1. Installs dependencies (`openvino`, `ultralytics`; adds `nncf` for INT8).
81
- 2. Downloads a sample test image (`test.jpg`).
82
  3. Downloads the PyTorch weights and exports to OpenVINO IR.
83
  4. *(INT8 only)* Quantizes the model using NNCF post-training quantization.
84
 
@@ -154,7 +173,7 @@ for det in dets:
154
  cv2.FONT_HERSHEY_SIMPLEX, 0.6, color, 2)
155
  print(f" {label} at ({x1},{y1})-({x2},{y2})")
156
 
157
- cv2.imwrite("output.jpg", image)
158
  ```
159
 
160
  **Device targets:**
@@ -167,7 +186,7 @@ cv2.imwrite("output.jpg", image)
167
 
168
  The `export_and_quantize.sh` script downloads `test.jpg` automatically.
169
  Re-run the OpenVINO sample above.
170
- The script reads `test.jpg`, prints each detected vehicle to the console, and writes the annotated frame to `output.jpg`.
171
 
172
  Expected console output:
173
 
@@ -176,12 +195,17 @@ Detected vehicles: 1
176
  bus 0.92 at (0,229)-(804,744)
177
  ```
178
 
 
 
 
 
179
  ### DLStreamer Sample
180
 
181
- The pipeline below runs the FP16 YOLO26 detector on a single image via
182
  `gvadetect`, filters detections to vehicle classes in a buffer probe using
183
  the DLStreamer Python bindings (`gstgva.VideoFrame`), overlays bounding boxes,
184
- and prints the vehicle count.
 
185
 
186
  > **Notes on running this sample:**
187
  >
@@ -197,8 +221,6 @@ and prints the vehicle count.
197
  > /opt/intel/dlstreamer/gstreamer/lib/python3/dist-packages:${PYTHONPATH:-}
198
  > ```
199
 
200
- **Image-based quick test** (uses `filesrc` with a single JPEG):
201
-
202
  ```python
203
  import gi
204
 
@@ -209,18 +231,20 @@ from gstgva import VideoFrame
209
 
210
  Gst.init(None)
211
 
 
212
  VEHICLE_LABELS = {"car", "motorcycle", "bus", "truck"}
213
 
214
- # For GPU: change device=CPU to device=GPU, add vapostproc !
215
- # video/x-raw(memory:VASurface) after jpegdec, and set
216
- # pre-process-backend=vaapi-surface-sharing on gvadetect.
217
- # For NPU: change device=CPU to device=NPU (batch-size=1 recommended).
218
  pipeline_str = (
219
- "filesrc location=test.jpg ! jpegdec ! videoconvert ! "
220
- "video/x-raw,format=BGR ! "
221
  "gvadetect model=yolo26n_openvino_model/yolo26n.xml "
222
- "device=CPU threshold=0.4 ! queue ! "
223
- "gvawatermark ! videoconvert ! jpegenc ! filesink name=sink location=output.jpg"
 
 
 
224
  )
225
  pipeline = Gst.parse_launch(pipeline_str)
226
 
@@ -250,11 +274,15 @@ bus.timed_pop_filtered(
250
  pipeline.set_state(Gst.State.NULL)
251
  ```
252
 
 
 
 
 
253
  **Device targets:**
254
 
255
- - `device=CPU` -- default in the sample code.
256
- - `device=GPU` -- add `vapostproc ! video/x-raw(memory:VASurface)` after `jpegdec` and set `pre-process-backend=vaapi-surface-sharing` on `gvadetect`.
257
- - `device=NPU` -- use `batch-size=1` and `nireq=4` for best NPU utilization.
258
 
259
  ---
260
 
 
1
+ ---
2
+ license: other
3
+ license_name: intel-custom
4
+ license_link: LICENSE
5
+ library_name: openvino
6
+ pipeline_tag: object-detection
7
+ tags:
8
+ - openvino
9
+ - intel
10
+ - yolo
11
+ - yolo26
12
+ - vehicle-detection
13
+ - edge-ai
14
+ - metro
15
+ - dlstreamer
16
+ datasets:
17
+ - detection-datasets/coco
18
+ language:
19
+ - en
20
+ ---
21
 
22
+ # Vehicle Detection
23
 
24
  | Property | Value |
25
  |---|---|
 
97
  The script performs the following steps:
98
 
99
  1. Installs dependencies (`openvino`, `ultralytics`; adds `nncf` for INT8).
100
+ 2. Downloads a sample test image (`test.jpg`) and a sample test video (`test_video.mp4`).
101
  3. Downloads the PyTorch weights and exports to OpenVINO IR.
102
  4. *(INT8 only)* Quantizes the model using NNCF post-training quantization.
103
 
 
173
  cv2.FONT_HERSHEY_SIMPLEX, 0.6, color, 2)
174
  print(f" {label} at ({x1},{y1})-({x2},{y2})")
175
 
176
+ cv2.imwrite("output_openvino.jpg", image)
177
  ```
178
 
179
  **Device targets:**
 
186
 
187
  The `export_and_quantize.sh` script downloads `test.jpg` automatically.
188
  Re-run the OpenVINO sample above.
189
+ The script reads `test.jpg`, prints each detected vehicle to the console, and writes the annotated frame to `output_openvino.jpg`.
190
 
191
  Expected console output:
192
 
 
195
  bus 0.92 at (0,229)-(804,744)
196
  ```
197
 
198
+ #### Expected Output
199
+
200
+ ![OpenVINO expected output](expected_output_openvino.jpg)
201
+
202
  ### DLStreamer Sample
203
 
204
+ The pipeline below runs the FP16 YOLO26 detector on the sample video via
205
  `gvadetect`, filters detections to vehicle classes in a buffer probe using
206
  the DLStreamer Python bindings (`gstgva.VideoFrame`), overlays bounding boxes,
207
+ saves the annotated result to `output_dlstreamer.mp4`, and prints the vehicle count per
208
+ frame.
209
 
210
  > **Notes on running this sample:**
211
  >
 
221
  > /opt/intel/dlstreamer/gstreamer/lib/python3/dist-packages:${PYTHONPATH:-}
222
  > ```
223
 
 
 
224
  ```python
225
  import gi
226
 
 
231
 
232
  Gst.init(None)
233
 
234
+ INPUT_VIDEO = "test_video.mp4"
235
  VEHICLE_LABELS = {"car", "motorcycle", "bus", "truck"}
236
 
237
+ # For CPU: change device=GPU to device=CPU.
238
+ # For NPU: change device=GPU to device=NPU (batch-size=1, nireq=4 recommended).
 
 
239
  pipeline_str = (
240
+ f"filesrc location={INPUT_VIDEO} ! decodebin3 ! "
241
+ "videoconvert ! "
242
  "gvadetect model=yolo26n_openvino_model/yolo26n.xml "
243
+ "device=GPU "
244
+ "threshold=0.4 ! queue ! "
245
+ "gvawatermark ! videoconvert ! video/x-raw,format=I420 ! "
246
+ "openh264enc ! h264parse ! "
247
+ "mp4mux ! filesink name=sink location=output_dlstreamer.mp4"
248
  )
249
  pipeline = Gst.parse_launch(pipeline_str)
250
 
 
274
  pipeline.set_state(Gst.State.NULL)
275
  ```
276
 
277
+ #### Expected Output
278
+
279
+ ![DLStreamer expected output](expected_output_dlstreamer.gif)
280
+
281
  **Device targets:**
282
 
283
+ - `device=GPU` -- default in the sample code.
284
+ - `device=CPU` -- change `device=GPU` to `device=CPU`.
285
+ - `device=NPU` -- change `device=GPU` to `device=NPU`; use `batch-size=1` and `nireq=4` for best NPU utilization.
286
 
287
  ---
288
 
expected_output_dlstreamer.gif ADDED

Git LFS Details

  • SHA256: 19ba89f40be3dfef27d57b138e9e5bb6514db99ead8a65bde0480f03df731f9b
  • Pointer size: 131 Bytes
  • Size of remote file: 870 kB
expected_output_openvino.jpg ADDED

Git LFS Details

  • SHA256: 8d7210b04398f9c3afe20280be4c01150eeb23da6b073213534f0767281c4e31
  • Pointer size: 131 Bytes
  • Size of remote file: 338 kB
export_and_quantize.sh CHANGED
@@ -44,6 +44,15 @@ else
44
  echo "Already present: test.jpg"
45
  fi
46
 
 
 
 
 
 
 
 
 
 
47
  if [[ "${PRECISION}" == "FP32" ]]; then
48
  HALF_FLAG="False"
49
  EXPORT_LABEL="FP32"
 
44
  echo "Already present: test.jpg"
45
  fi
46
 
47
+ echo "--- Downloading sample test video ---"
48
+ if [[ ! -f test_video.mp4 ]]; then
49
+ wget -q -O test_video.mp4 \
50
+ https://github.com/intel-iot-devkit/sample-videos/raw/master/car-detection.mp4
51
+ echo "Downloaded: test_video.mp4"
52
+ else
53
+ echo "Already present: test_video.mp4"
54
+ fi
55
+
56
  if [[ "${PRECISION}" == "FP32" ]]; then
57
  HALF_FLAG="False"
58
  EXPORT_LABEL="FP32"