vagheshpatel commited on
Commit
676796b
·
verified ·
1 Parent(s): 641e004

Sync person-detection from metro-analytics-catalog

Browse files
Files changed (2) hide show
  1. README.md +18 -17
  2. export_and_quantize.sh +9 -2
README.md CHANGED
@@ -1,6 +1,6 @@
1
  # Person 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
 
@@ -153,10 +161,10 @@ The script reads `test.jpg`, prints the person count to the console, and writes
153
  Expected console output:
154
 
155
  ```text
156
- Detected persons: 4
157
  ```
158
 
159
- `output.jpg` shows a green bounding box around each detected person and the text `Persons: 4` in the top-left corner.
160
 
161
  ### DLStreamer Sample
162
 
@@ -216,16 +224,9 @@ def on_buffer(pad, info):
216
  return Gst.PadProbeReturn.OK
217
 
218
 
219
- # Attach probe to the src pad of gvawatermark for person counting.
220
- it = pipeline.iterate_elements()
221
- while True:
222
- ok, elem = it.next()
223
- if not ok:
224
- break
225
- if elem.get_factory() and elem.get_factory().get_name() == "gvawatermark":
226
- pad = elem.get_static_pad("src")
227
- pad.add_probe(Gst.PadProbeType.BUFFER, on_buffer)
228
- break
229
 
230
  pipeline.set_state(Gst.State.PLAYING)
231
  bus = pipeline.get_bus()
 
1
  # Person 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
 
 
161
  Expected console output:
162
 
163
  ```text
164
+ Detected persons: 2
165
  ```
166
 
167
+ `output.jpg` shows a green bounding box around each detected person and the text `Persons: 2` in the top-left corner.
168
 
169
  ### DLStreamer Sample
170
 
 
224
  return Gst.PadProbeReturn.OK
225
 
226
 
227
+ sink = pipeline.get_by_name("sink")
228
+ sink_pad = sink.get_static_pad("sink")
229
+ sink_pad.add_probe(Gst.PadProbeType.BUFFER, on_buffer)
 
 
 
 
 
 
 
230
 
231
  pipeline.set_state(Gst.State.PLAYING)
232
  bus = pipeline.get_bus()
export_and_quantize.sh CHANGED
@@ -38,7 +38,7 @@ fi
38
 
39
  echo "--- Downloading sample test image ---"
40
  if [[ ! -f test.jpg ]]; then
41
- wget -q -O test.jpg https://ultralytics.com/images/bus.jpg
42
  echo "Downloaded: test.jpg"
43
  else
44
  echo "Already present: test.jpg"
@@ -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
 
 
38
 
39
  echo "--- Downloading sample test image ---"
40
  if [[ ! -f test.jpg ]]; then
41
+ wget -q -O test.jpg https://ultralytics.com/images/zidane.jpg
42
  echo "Downloaded: test.jpg"
43
  else
44
  echo "Already present: test.jpg"
 
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