Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yolov8 support with ROI and tracking #7

Merged
merged 6 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really great method for doing this!

@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

Expand Down
12 changes: 12 additions & 0 deletions smoke_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ setup() {
make clean-all || true
echo "Build Loss Prevention image"
make build
echo "Downlaod models"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
echo "Downlaod models"
echo "Download models"

make download-models
}

teardown() {
Expand Down Expand Up @@ -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
4 changes: 2 additions & 2 deletions src/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future we can look at refactoring out the ASC pipelines

}

while :; do
Expand Down Expand Up @@ -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
Expand Down
30 changes: 30 additions & 0 deletions src/pipelines/roi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[

{

"objects": [

{

"detection": {

"label": "ROI1"

},

"x": 0,

"y": 0,

"w": 480,

"h": 1080

}


]

}

]
27 changes: 27 additions & 0 deletions src/pipelines/yolov8s_roi.sh
Original file line number Diff line number Diff line change
@@ -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
Loading