vagheshpatel commited on
Commit
35d376a
·
verified ·
1 Parent(s): f3a53d2

Sync crowd-detection from metro-analytics-catalog

Browse files
Files changed (2) hide show
  1. README.md +21 -9
  2. export_and_quantize.sh +9 -2
README.md CHANGED
@@ -1,6 +1,6 @@
1
  # Crowd Detection
2
 
3
- > **Validated with:** OpenVINO 2026.0.0, NNCF 3.0.0, DLStreamer 2026.0, Ultralytics 8.3.0, Python 3.11+
4
 
5
  | Property | Value |
6
  |---|---|
@@ -32,7 +32,7 @@ Smaller variants (`yolo26n`, `yolo26s`) are recommended for high-FPS edge deploy
32
  ## Prerequisites
33
 
34
  - Python 3.11+
35
- - [Install OpenVINO 2026.0.0](https://docs.openvino.ai/2026/get-started/install-openvino.html)
36
  - [Install Intel DLStreamer](https://docs.openedgeplatform.intel.com/2026.0/edge-ai-libraries/dlstreamer/get_started/install/install_guide_ubuntu.html)
37
 
38
  Create and activate a Python virtual environment before running the scripts:
@@ -52,9 +52,17 @@ Run the provided script to download, export to OpenVINO IR, and optionally quant
52
 
53
  ```bash
54
  chmod +x export_and_quantize.sh
55
- ./export_and_quantize.sh yolo26n # default: FP16
 
 
 
 
 
 
 
56
  ./export_and_quantize.sh yolo26n FP32 # full-precision
57
  ./export_and_quantize.sh yolo26n INT8 # quantized
 
58
  ```
59
 
60
  Replace `yolo26n` with any variant (`yolo26s`, `yolo26m`, `yolo26l`, `yolo26x`).
@@ -80,9 +88,9 @@ Output files:
80
  | FP16 | Yes | Yes | Yes |
81
  | INT8 | Yes | Yes | Yes |
82
 
83
- > **Note:** For production accuracy, replace the random calibration tensors in
84
- > `export_and_quantize.sh` with a representative sample of frames from the
85
- > target deployment site.
86
 
87
  ### OpenVINO Sample
88
 
@@ -140,13 +148,17 @@ The `export_and_quantize.sh` script downloads `test.jpg` automatically.
140
  Re-run the OpenVINO sample above.
141
  The script reads `test.jpg`, prints the crowd count to the console, and writes the annotated frame to `output.jpg`.
142
 
143
- Expected console output:
144
 
145
  ```text
146
- Detected persons: 4
147
  ```
148
 
149
- `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.
 
 
 
 
150
 
151
  ### DLStreamer Sample
152
 
 
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
  |---|---|
 
32
  ## Prerequisites
33
 
34
  - Python 3.11+
35
+ - [Install OpenVINO](https://docs.openvino.ai/2026/get-started/install-openvino.html) (latest version)
36
  - [Install Intel DLStreamer](https://docs.openedgeplatform.intel.com/2026.0/edge-ai-libraries/dlstreamer/get_started/install/install_guide_ubuntu.html)
37
 
38
  Create and activate a Python virtual environment before running the scripts:
 
52
 
53
  ```bash
54
  chmod +x export_and_quantize.sh
55
+ ./export_and_quantize.sh
56
+ ```
57
+
58
+ This exports the default **yolo26n** model in **FP16** precision.
59
+
60
+ #### Optional: Select a Different Variant or Precision
61
+
62
+ ```bash
63
  ./export_and_quantize.sh yolo26n FP32 # full-precision
64
  ./export_and_quantize.sh yolo26n INT8 # quantized
65
+ ./export_and_quantize.sh yolo26s # larger variant, default FP16
66
  ```
67
 
68
  Replace `yolo26n` with any variant (`yolo26s`, `yolo26m`, `yolo26l`, `yolo26x`).
 
88
  | FP16 | Yes | Yes | Yes |
89
  | INT8 | Yes | Yes | Yes |
90
 
91
+ > **Note:** The INT8 calibration uses the bundled sample image.
92
+ > For production accuracy, replace it with a representative set of frames from
93
+ > the target deployment site.
94
 
95
  ### OpenVINO Sample
96
 
 
148
  Re-run the OpenVINO sample above.
149
  The script reads `test.jpg`, prints the crowd count to the console, and writes the annotated frame to `output.jpg`.
150
 
151
+ Expected console output (representative -- actual count depends on the sample image):
152
 
153
  ```text
154
+ Detected persons: <N>
155
  ```
156
 
157
+ `output.jpg` is the same image with a green bounding box drawn around each detected person and the text `Crowd count: <N>` overlaid in the top-left corner.
158
+
159
+ > **Tip:** The bundled `test.jpg` (an airport scene) is suitable for a quick
160
+ > demo. For production testing, replace it with an image from your target
161
+ > deployment site showing a representative crowd density.
162
 
163
  ### DLStreamer Sample
164
 
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://raw.githubusercontent.com/ultralytics/assets/main/im/airport.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