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/smoke_test.sh b/smoke_test.sh index 7fef152..ea42db7 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 "Download models" + make download-models } teardown() { @@ -97,4 +99,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 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 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