Sync worker-safety-detection from metro-analytics-catalog
Browse files- README.md +7 -3
- export_and_quantize.sh +28 -5
README.md
CHANGED
|
@@ -89,7 +89,7 @@ The script performs the following steps:
|
|
| 89 |
|
| 90 |
Output files:
|
| 91 |
|
| 92 |
-
- `./models/
|
| 93 |
|
| 94 |
> **Note:** The FP32 model is ready for production use on CPU and GPU.
|
| 95 |
> An INT8 variant is also available from the [INT8 models directory](https://github.com/open-edge-platform/edge-ai-resources/tree/main/models/INT8) for higher throughput.
|
|
@@ -103,7 +103,8 @@ annotated result to `output_dlstreamer.mp4`.
|
|
| 103 |
> **Notes on running this sample:**
|
| 104 |
>
|
| 105 |
> - The Geti-exported model embeds post-processing and labels internally.
|
| 106 |
-
> `gvadetect` auto-discovers the model type for Geti-exported IRs
|
|
|
|
| 107 |
> - Export `PYTHONPATH` so the DLStreamer Python module is importable:
|
| 108 |
>
|
| 109 |
> ```bash
|
|
@@ -122,7 +123,10 @@ from gi.repository import Gst, GLib, GstAnalytics
|
|
| 122 |
|
| 123 |
Gst.init([])
|
| 124 |
|
| 125 |
-
MODEL_XML =
|
|
|
|
|
|
|
|
|
|
| 126 |
INPUT_VIDEO = "test_video.avi"
|
| 127 |
|
| 128 |
# For CPU: change device=GPU to device=CPU.
|
|
|
|
| 89 |
|
| 90 |
Output files:
|
| 91 |
|
| 92 |
+
- `./models/worker_safety_gear_detection/deployment/Detection/model/model.xml` -- FP32 OpenVINO IR used by the DLStreamer sample.
|
| 93 |
|
| 94 |
> **Note:** The FP32 model is ready for production use on CPU and GPU.
|
| 95 |
> An INT8 variant is also available from the [INT8 models directory](https://github.com/open-edge-platform/edge-ai-resources/tree/main/models/INT8) for higher throughput.
|
|
|
|
| 103 |
> **Notes on running this sample:**
|
| 104 |
>
|
| 105 |
> - The Geti-exported model embeds post-processing and labels internally.
|
| 106 |
+
> `gvadetect` auto-discovers the model type for Geti-exported IRs, so no
|
| 107 |
+
> external `model-proc` JSON is required for this flow.
|
| 108 |
> - Export `PYTHONPATH` so the DLStreamer Python module is importable:
|
| 109 |
>
|
| 110 |
> ```bash
|
|
|
|
| 123 |
|
| 124 |
Gst.init([])
|
| 125 |
|
| 126 |
+
MODEL_XML = (
|
| 127 |
+
"models/worker_safety_gear_detection/"
|
| 128 |
+
"deployment/Detection/model/model.xml"
|
| 129 |
+
)
|
| 130 |
INPUT_VIDEO = "test_video.avi"
|
| 131 |
|
| 132 |
# For CPU: change device=GPU to device=CPU.
|
export_and_quantize.sh
CHANGED
|
@@ -10,12 +10,26 @@
|
|
| 10 |
set -euo pipefail
|
| 11 |
|
| 12 |
OUTPUT_DIR="${1:-./models}"
|
| 13 |
-
MODEL_DIR="${OUTPUT_DIR}/
|
| 14 |
ZIP_URL="https://github.com/open-edge-platform/edge-ai-resources/raw/main/models/FP32/worker-safety-gear-detection.zip"
|
| 15 |
ZIP_FILE="${OUTPUT_DIR}/worker-safety-gear-detection.zip"
|
|
|
|
| 16 |
|
| 17 |
echo "--- Installing dependencies ---"
|
| 18 |
-
pip install -qU
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
echo "--- Downloading sample test video ---"
|
| 21 |
if [[ ! -f test_video.avi ]]; then
|
|
@@ -36,14 +50,23 @@ else
|
|
| 36 |
fi
|
| 37 |
|
| 38 |
echo "--- Extracting model ---"
|
|
|
|
|
|
|
| 39 |
unzip -qo "${ZIP_FILE}" -d "${MODEL_DIR}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
echo "Extracted to: ${MODEL_DIR}"
|
| 41 |
|
| 42 |
# Locate the model XML.
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
echo "ERROR: model.xml not found in extracted archive." >&2
|
| 46 |
exit 1
|
| 47 |
fi
|
|
|
|
| 48 |
echo "Model IR found: ${MODEL_XML}"
|
| 49 |
echo "--- Done ---"
|
|
|
|
| 10 |
set -euo pipefail
|
| 11 |
|
| 12 |
OUTPUT_DIR="${1:-./models}"
|
| 13 |
+
MODEL_DIR="${OUTPUT_DIR}/worker_safety_gear_detection"
|
| 14 |
ZIP_URL="https://github.com/open-edge-platform/edge-ai-resources/raw/main/models/FP32/worker-safety-gear-detection.zip"
|
| 15 |
ZIP_FILE="${OUTPUT_DIR}/worker-safety-gear-detection.zip"
|
| 16 |
+
EXPECTED_XML="${MODEL_DIR}/deployment/Detection/model/model.xml"
|
| 17 |
|
| 18 |
echo "--- Installing dependencies ---"
|
| 19 |
+
pip install -qU openvino
|
| 20 |
+
|
| 21 |
+
# Ask for approval before downloading models and sample files
|
| 22 |
+
echo ""
|
| 23 |
+
echo "This script will download:"
|
| 24 |
+
echo " - Worker Safety Gear Detection model"
|
| 25 |
+
echo " - Sample test video"
|
| 26 |
+
echo ""
|
| 27 |
+
read -p "Continue with downloads? (yes/no): " APPROVAL
|
| 28 |
+
if [[ "${APPROVAL}" != "yes" ]]; then
|
| 29 |
+
echo "Download cancelled by user."
|
| 30 |
+
exit 0
|
| 31 |
+
fi
|
| 32 |
+
echo ""
|
| 33 |
|
| 34 |
echo "--- Downloading sample test video ---"
|
| 35 |
if [[ ! -f test_video.avi ]]; then
|
|
|
|
| 50 |
fi
|
| 51 |
|
| 52 |
echo "--- Extracting model ---"
|
| 53 |
+
rm -rf "${MODEL_DIR}"
|
| 54 |
+
mkdir -p "${MODEL_DIR}"
|
| 55 |
unzip -qo "${ZIP_FILE}" -d "${MODEL_DIR}"
|
| 56 |
+
|
| 57 |
+
# The archive may contain an extra top-level worker_safety_gear_detection dir.
|
| 58 |
+
if [[ -d "${MODEL_DIR}/worker_safety_gear_detection/deployment" ]]; then
|
| 59 |
+
mv "${MODEL_DIR}/worker_safety_gear_detection"/* "${MODEL_DIR}/"
|
| 60 |
+
rmdir "${MODEL_DIR}/worker_safety_gear_detection" || true
|
| 61 |
+
fi
|
| 62 |
+
|
| 63 |
echo "Extracted to: ${MODEL_DIR}"
|
| 64 |
|
| 65 |
# Locate the model XML.
|
| 66 |
+
if [[ ! -f "${EXPECTED_XML}" ]]; then
|
| 67 |
+
echo "ERROR: expected model.xml not found at ${EXPECTED_XML}" >&2
|
|
|
|
| 68 |
exit 1
|
| 69 |
fi
|
| 70 |
+
MODEL_XML="${EXPECTED_XML}"
|
| 71 |
echo "Model IR found: ${MODEL_XML}"
|
| 72 |
echo "--- Done ---"
|