From a6c199713289fccc37db911e15ae603d44a1947b Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Mon, 16 Sep 2024 18:56:00 -0700 Subject: [PATCH 1/6] feat: Added yolov8s pipeline with ROI and tracking Signed-off-by: Antonio Martinez --- Makefile | 22 ++++++++++++++++++---- src/entrypoint.sh | 4 ++-- src/pipelines/roi.json | 30 ++++++++++++++++++++++++++++++ src/pipelines/yolov8s_roi.sh | 27 +++++++++++++++++++++++++++ 4 files changed, 77 insertions(+), 6 deletions(-) create mode 100644 src/pipelines/roi.json create mode 100755 src/pipelines/yolov8s_roi.sh diff --git a/Makefile b/Makefile index fc65ded..0a2c3dc 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ .PHONY: build build-realsense run down .PHONY: build-telegraf run-telegraf run-portainer clean-all clean-results clean-telegraf clean-models down-portainer -.PHONY: download-models clean-test run-demo run-headless +.PHONY: download-models clean-test run-demo run-headless download-yolov8s MKDOCS_IMAGE ?= asc-mkdocs PIPELINE_COUNT ?= 1 @@ -12,9 +12,23 @@ DOCKER_COMPOSE ?= docker-compose.yml RESULTS_DIR ?= $(PWD)/results RETAIL_USE_CASE_ROOT ?= $(PWD) -download-models: - ./download_models/downloadModels.sh - +download-models: download-yolov8s + ./download_models/downloadModels.sh + +download-yolov8s: + @if [ ! -d "$(PWD)/models/object_detection/yolov8s/" ]; then \ + echo "The yolov8s folder doesn't exist. Creating it and downloading the model..."; \ + mkdir -p $(PWD)/models/object_detection/yolov8s/; \ + docker run --user 1000:1000 -e HTTPS_PROXY=${HTTPS_PROXY} -e HTTP_PROXY=${HTTPS_PROXY} --rm \ + -e YOLO_DEBUG=1 \ + -v $(PWD)/models/object_detection/yolov8s:/models \ + ultralytics/ultralytics:latest-cpu \ + bash -c "cd /models && yolo export model=yolov8s.pt format=openvino"; \ + mv $(PWD)/models/object_detection/yolov8s/yolov8s_openvino_model $(PWD)/models/object_detection/yolov8s/FP32; \ + else \ + echo "yolov8s already exists."; \ + fi + download-sample-videos: cd performance-tools/benchmark-scripts && ./download_sample_videos.sh diff --git a/src/entrypoint.sh b/src/entrypoint.sh index 6f8dca7..00be914 100755 --- a/src/entrypoint.sh +++ b/src/entrypoint.sh @@ -32,7 +32,7 @@ DECODE="${DECODE:="decodebin force-sw-decoders=1"}" #decodebin|vaapidecodebin DEVICE="${DEVICE:="CPU"}" #GPU|CPU|MULTI:GPU,CPU show_help() { - echo "usage: \"--pipeline_script_choice\" requires an argument yolov5s.sh|yolov5s_effnetb0.sh|yolov5s_full.sh|people_detection.sh" + echo "usage: \"--pipeline_script_choice\" requires an argument yolov5s.sh|yolov5s_effnetb0.sh|yolov5s_full.sh|people_detection.sh|yolov8s_roi.sh" } while :; do @@ -66,7 +66,7 @@ while :; do done -if [ "$PIPELINE_SCRIPT" != "yolov5s.sh" ] && [ "$PIPELINE_SCRIPT" != "yolov5s_effnetb0.sh" ] && [ "$PIPELINE_SCRIPT" != "yolov5s_full.sh" ] && [ "$PIPELINE_SCRIPT" != "people_detection.sh" ] +if [ "$PIPELINE_SCRIPT" != "yolov5s.sh" ] && [ "$PIPELINE_SCRIPT" != "yolov5s_effnetb0.sh" ] && [ "$PIPELINE_SCRIPT" != "yolov5s_full.sh" ] && [ "$PIPELINE_SCRIPT" != "people_detection.sh" ] && [ "$PIPELINE_SCRIPT" != "yolov8s_roi.sh" ] then echo "Error on your input: $PIPELINE_SCRIPT" show_help diff --git a/src/pipelines/roi.json b/src/pipelines/roi.json new file mode 100644 index 0000000..875a704 --- /dev/null +++ b/src/pipelines/roi.json @@ -0,0 +1,30 @@ +[ + + { + + "objects": [ + + { + + "detection": { + + "label": "ROI1" + + }, + + "x": 0, + + "y": 0, + + "w": 480, + + "h": 1080 + + } + + + ] + + } + +] \ No newline at end of file diff --git a/src/pipelines/yolov8s_roi.sh b/src/pipelines/yolov8s_roi.sh new file mode 100755 index 0000000..78ba42b --- /dev/null +++ b/src/pipelines/yolov8s_roi.sh @@ -0,0 +1,27 @@ + #!/bin/bash +# +# Copyright (C) 2024 Intel Corporation. +# +# SPDX-License-Identifier: Apache-2.0 +# + +PRE_PROCESS="${PRE_PROCESS:=""}" #""|pre-process-backend=vaapi-surface-sharing|pre-process-backend=vaapi-surface-sharing pre-process-config=VAAPI_FAST_SCALE_LOAD_FACTOR=1 +AGGREGATE="${AGGREGATE:="gvametaaggregate name=aggregate !"}" # Aggregate function at the end of the pipeline ex. "" | gvametaaggregate name=aggregate +PUBLISH="${PUBLISH:="name=destination file-format=2 file-path=/tmp/results/r$cid\"_gst\".jsonl"}" # address=localhost:1883 topic=inferenceEvent method=mqtt + +ROI="${ROI:="0,0,400,400"}" + +if [ "$RENDER_MODE" == "1" ]; then + OUTPUT="${OUTPUT:="! videoconvert ! gvawatermark ! videoconvert ! fpsdisplaysink video-sink=ximagesink sync=true --verbose"}" +else + OUTPUT="${OUTPUT:="! fpsdisplaysink video-sink=fakesink sync=true --verbose"}" +fi + +echo "decode type $DECODE" +echo "Run yolov8 pipeline with ROI on $DEVICE with batch size = $BATCH_SIZE" + +gstLaunchCmd="GST_DEBUG=\"GST_TRACER:7\" GST_TRACERS=\"latency_tracer(flags=pipeline,interval=100)\" gst-launch-1.0 $inputsrc ! $DECODE ! gvaattachroi mode=1 file-path=/home/pipeline-server/pipelines/roi.json ! gvadetect batch-size=$BATCH_SIZE model-instance-id=odmodel name=detection model=models/object_detection/yolov8s/FP32/yolov8s.xml device=$DEVICE $PRE_PROCESS inference-region=1 object-class=ROI1 ! gvatrack ! $AGGREGATE gvametaconvert name=metaconvert add-empty-results=true ! gvametapublish name=destination file-format=2 file-path=/tmp/results/r$cid\"_gst\".jsonl $OUTPUT 2>&1 | tee >/tmp/results/gst-launch_$cid\"_gst\".log >(stdbuf -oL sed -n -e 's/^.*current: //p' | stdbuf -oL cut -d , -f 1 > /tmp/results/pipeline$cid\"_gst\".log)" + +echo "$gstLaunchCmd" + +eval $gstLaunchCmd \ No newline at end of file From 7834def2d9d38aa9f8f14e506ee5a995c4ede977 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Mon, 16 Sep 2024 18:59:19 -0700 Subject: [PATCH 2/6] Adding smoke test Signed-off-by: Antonio Martinez --- smoke_test.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/smoke_test.sh b/smoke_test.sh index 7fef152..59d93b6 100755 --- a/smoke_test.sh +++ b/smoke_test.sh @@ -71,7 +71,7 @@ waitForLogFile() { # initial setup setup -# 1. test Loss Prevention: should run and exit without any error +1. test Loss Prevention: should run and exit without any error echo "Running Loss Prevention..." make run status_code=$? @@ -97,4 +97,14 @@ verifyStatusCode $status_code # allowing some time to process waitForLogFile verifyNonEmptyPipelineLog +teardown + +# 4. Yolov8s pipeine: should see non-empty pipeline0.log contents +echo "Running YOLOv8s pipeline with logs..." +INPUTSRC=https://github.com/intel-iot-devkit/sample-videos/raw/master/people-detection.mp4 PIPELINE_SCRIPT=yolov8s_roi.sh docker compose -f src/docker-compose.yml up -d +status_code=$? +verifyStatusCode $status_code +# allowing some time to process +waitForLogFile +verifyNonEmptyPipelineLog teardown \ No newline at end of file From 4f65915fc971e1c71de47b338a4ceb4e5ff14119 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Mon, 16 Sep 2024 19:00:11 -0700 Subject: [PATCH 3/6] Adding smoke test Signed-off-by: Antonio Martinez --- smoke_test.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/smoke_test.sh b/smoke_test.sh index 59d93b6..b3aba27 100755 --- a/smoke_test.sh +++ b/smoke_test.sh @@ -16,6 +16,8 @@ setup() { make clean-all || true echo "Build Loss Prevention image" make build + echo "Downlaod models" + make download-models } teardown() { From b3878628c3202d9a5e5ec0e258a4b2d0b52da3a3 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Tue, 17 Sep 2024 12:26:54 -0700 Subject: [PATCH 4/6] comment a line in smoke test Signed-off-by: Antonio Martinez --- smoke_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smoke_test.sh b/smoke_test.sh index b3aba27..08dd497 100755 --- a/smoke_test.sh +++ b/smoke_test.sh @@ -73,7 +73,7 @@ waitForLogFile() { # initial setup setup -1. test Loss Prevention: should run and exit without any error +# 1. test Loss Prevention: should run and exit without any error echo "Running Loss Prevention..." make run status_code=$? From 0fb0e69aeaf9ceaf944ba3bee9efa9a12fe90d9a Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Tue, 17 Sep 2024 17:29:04 -0700 Subject: [PATCH 5/6] Fixing proxy issues Signed-off-by: Antonio Martinez --- src/docker-compose.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/docker-compose.yml b/src/docker-compose.yml index 520dca4..660e329 100644 --- a/src/docker-compose.yml +++ b/src/docker-compose.yml @@ -47,9 +47,9 @@ services: - INPUTSRC=${INPUTSRC:-rtsp://localhost:8554/camera_0} - RENDER_MODE=${RENDER_MODE:-0} #RENDER_MODE=1 will work only after running xhost +local:docker - DISPLAY=$DISPLAY - - HTTP_PROXY=${HTTP_PROXY} - - HTTPS_PROXY=${HTTPS_PROXY} - - NO_PROXY=${NO_PROXY} + - HTTP_PROXY + - HTTPS_PROXY + - NO_PROXY volumes: - ${RESULTS_DIR:-../results}:/tmp/results - ~/.Xauthority:/home/dlstreamer/.Xauthority From 7a16fe933bd68849a5a640080229c764957cff45 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Thu, 19 Sep 2024 14:03:54 -0700 Subject: [PATCH 6/6] grammar error Signed-off-by: Antonio Martinez --- smoke_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smoke_test.sh b/smoke_test.sh index 08dd497..ea42db7 100755 --- a/smoke_test.sh +++ b/smoke_test.sh @@ -16,7 +16,7 @@ setup() { make clean-all || true echo "Build Loss Prevention image" make build - echo "Downlaod models" + echo "Download models" make download-models }