vagheshpatel commited on
Commit
ae4de59
·
verified ·
1 Parent(s): 5f7dca6

Sync crowd-detection from metro-analytics-catalog

Browse files
.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ expected_output_dlstreamer.gif filter=lfs diff=lfs merge=lfs -text
37
+ expected_output_openvino.jpg filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,10 +1,9 @@
1
  # Crowd 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
  |---|---|
7
  | **Category** | Object Detection (Crowd / Person Counting) |
 
8
  | **Source Framework** | PyTorch (Ultralytics) |
9
  | **Supported Precisions** | FP32, FP16, INT8 (mixed-precision) |
10
  | **Inference Engine** | OpenVINO |
@@ -16,7 +15,7 @@
16
  ## Overview
17
 
18
  Crowd Detection is a Metro Analytics use case that detects and counts people in video streams to estimate occupancy and identify crowd build-up.
19
- It is built on [YOLO26](https://docs.ultralytics.com/models/yolo26/), a real-time object detector trained on the COCO dataset, filtered at runtime to the `person` class.
20
  Typical Metro deployments include:
21
 
22
  - **Platform Occupancy** -- count waiting passengers on station platforms.
@@ -75,7 +74,7 @@ The second argument selects the precision (`FP32`, `FP16`, `INT8`); the default
75
  The script performs the following steps:
76
 
77
  1. Installs dependencies (`openvino`, `ultralytics`; adds `nncf` for INT8).
78
- 2. Downloads a sample test image (`test.jpg`).
79
  3. Downloads the PyTorch weights and exports to OpenVINO IR.
80
  4. *(INT8 only)* Quantizes the model using NNCF post-training quantization.
81
 
@@ -143,14 +142,14 @@ cv2.putText(
143
  image, f"Crowd count: {crowd_count}", (10, 30),
144
  cv2.FONT_HERSHEY_SIMPLEX, 1.0, (0, 255, 0), 2,
145
  )
146
- cv2.imwrite("output.jpg", image)
147
  ```
148
 
149
  ### Try It on a Sample Image
150
 
151
  The `export_and_quantize.sh` script downloads `test.jpg` automatically.
152
  Re-run the OpenVINO sample above.
153
- The script reads `test.jpg`, prints the crowd count to the console, and writes the annotated frame to `output.jpg`.
154
 
155
  Expected console output:
156
 
@@ -158,17 +157,22 @@ Expected console output:
158
  Detected persons: 4
159
  ```
160
 
161
- `output.jpg` is the same image with a green bounding box drawn around each detected person and the text `Crowd count: 4` overlaid in the top-left corner.
162
 
163
  > **Tip:** For production testing, replace the bundled `test.jpg` with an image
164
  > from your target deployment site showing a representative crowd density.
165
 
 
 
 
 
166
  ### DLStreamer Sample
167
 
168
- The pipeline below runs the FP16 YOLO26 detector on a test image via
169
  `gvadetect`, filters detections to the `person` class in a buffer probe using
170
  the DLStreamer Python bindings (`gstgva.VideoFrame`), overlays bounding boxes,
171
- saves the annotated result to `output.jpg`, and prints the crowd count.
 
172
 
173
  > **Notes on running this sample:**
174
  >
@@ -201,13 +205,19 @@ from gstgva import VideoFrame
201
 
202
  Gst.init(None)
203
 
 
 
 
 
204
  pipeline_str = (
205
- "filesrc location=test.jpg ! jpegdec ! videoconvert ! "
206
- "video/x-raw,format=BGR ! "
207
  "gvadetect model=yolo26n_openvino_model/yolo26n.xml "
208
- "device=CPU threshold=0.4 ! queue ! "
209
- "gvawatermark ! videoconvert ! jpegenc ! "
210
- "filesink name=sink location=output.jpg"
 
 
211
  )
212
  pipeline = Gst.parse_launch(pipeline_str)
213
 
@@ -236,10 +246,15 @@ bus.timed_pop_filtered(
236
  pipeline.set_state(Gst.State.NULL)
237
  ```
238
 
239
- To run on integrated GPU, change `device=CPU` to `device=GPU`, add
240
- `vapostproc ! video/x-raw(memory:VASurface)` after `jpegdec`, and set
241
- `pre-process-backend=vaapi-surface-sharing` on `gvadetect`.
242
- For NPU, change `device=CPU` to `device=NPU`.
 
 
 
 
 
243
 
244
  ---
245
 
 
1
  # Crowd Detection
2
 
 
 
3
  | Property | Value |
4
  |---|---|
5
  | **Category** | Object Detection (Crowd / Person Counting) |
6
+ | **Base Model** | [YOLO26](https://docs.ultralytics.com/models/yolo26/) (Ultralytics) |
7
  | **Source Framework** | PyTorch (Ultralytics) |
8
  | **Supported Precisions** | FP32, FP16, INT8 (mixed-precision) |
9
  | **Inference Engine** | OpenVINO |
 
15
  ## Overview
16
 
17
  Crowd Detection is a Metro Analytics use case that detects and counts people in video streams to estimate occupancy and identify crowd build-up.
18
+ It is built on [YOLO26](https://docs.ultralytics.com/models/yolo26/), a state-of-the-art real-time object detector trained on the COCO dataset, quantized to INT8 and filtered at runtime to the `person` class.
19
  Typical Metro deployments include:
20
 
21
  - **Platform Occupancy** -- count waiting passengers on station platforms.
 
74
  The script performs the following steps:
75
 
76
  1. Installs dependencies (`openvino`, `ultralytics`; adds `nncf` for INT8).
77
+ 2. Downloads a sample test image (`test.jpg`) and a sample test video (`test_video.mp4`).
78
  3. Downloads the PyTorch weights and exports to OpenVINO IR.
79
  4. *(INT8 only)* Quantizes the model using NNCF post-training quantization.
80
 
 
142
  image, f"Crowd count: {crowd_count}", (10, 30),
143
  cv2.FONT_HERSHEY_SIMPLEX, 1.0, (0, 255, 0), 2,
144
  )
145
+ cv2.imwrite("output_openvino.jpg", image)
146
  ```
147
 
148
  ### Try It on a Sample Image
149
 
150
  The `export_and_quantize.sh` script downloads `test.jpg` automatically.
151
  Re-run the OpenVINO sample above.
152
+ The script reads `test.jpg`, prints the crowd count to the console, and writes the annotated frame to `output_openvino.jpg`.
153
 
154
  Expected console output:
155
 
 
157
  Detected persons: 4
158
  ```
159
 
160
+ `output_openvino.jpg` is the same image with a green bounding box drawn around each detected person and the text `Crowd count: 4` overlaid in the top-left corner.
161
 
162
  > **Tip:** For production testing, replace the bundled `test.jpg` with an image
163
  > from your target deployment site showing a representative crowd density.
164
 
165
+ #### Expected Output
166
+
167
+ ![OpenVINO expected output](expected_output_openvino.jpg)
168
+
169
  ### DLStreamer Sample
170
 
171
+ The pipeline below runs the FP16 YOLO26 detector on the sample video via
172
  `gvadetect`, filters detections to the `person` class in a buffer probe using
173
  the DLStreamer Python bindings (`gstgva.VideoFrame`), overlays bounding boxes,
174
+ saves the annotated result to `output_dlstreamer.mp4`, and prints the crowd count per
175
+ frame.
176
 
177
  > **Notes on running this sample:**
178
  >
 
205
 
206
  Gst.init(None)
207
 
208
+ INPUT_VIDEO = "test_video.mp4"
209
+
210
+ # For CPU: change device=GPU to device=CPU.
211
+ # For NPU: change device=GPU to device=NPU (batch-size=1, nireq=4 recommended).
212
  pipeline_str = (
213
+ f"filesrc location={INPUT_VIDEO} ! decodebin3 ! "
214
+ "videoconvert ! "
215
  "gvadetect model=yolo26n_openvino_model/yolo26n.xml "
216
+ "device=GPU "
217
+ "threshold=0.4 ! queue ! "
218
+ "gvawatermark ! videoconvert ! video/x-raw,format=I420 ! "
219
+ "openh264enc ! h264parse ! "
220
+ "mp4mux ! filesink name=sink location=output_dlstreamer.mp4"
221
  )
222
  pipeline = Gst.parse_launch(pipeline_str)
223
 
 
246
  pipeline.set_state(Gst.State.NULL)
247
  ```
248
 
249
+ #### Expected Output
250
+
251
+ ![DLStreamer expected output](expected_output_dlstreamer.gif)
252
+
253
+ **Device targets:**
254
+
255
+ - `device=GPU` -- default in the sample code.
256
+ - `device=CPU` -- change `device=GPU` to `device=CPU`.
257
+ - `device=NPU` -- change `device=GPU` to `device=NPU`; use `batch-size=1` and `nireq=4` for best NPU utilization.
258
 
259
  ---
260
 
expected_output_dlstreamer.gif ADDED

Git LFS Details

  • SHA256: 9eec52efea37d96ed2ae6acd55f2fcc4439a5b0ef618d362a0feffb749568e69
  • Pointer size: 132 Bytes
  • Size of remote file: 1.73 MB
expected_output_openvino.jpg ADDED

Git LFS Details

  • SHA256: e86ab3820665ed810ca7340e6415a1f77bc84ea9cffc2fadb34f7d22c7e7e34b
  • Pointer size: 131 Bytes
  • Size of remote file: 345 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/open-edge-platform/edge-ai-resources/raw/main/videos/VIRAT_S_000101.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"