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

Feat: People detection with Region of Interest #6

Merged
merged 4 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
models/
15 changes: 15 additions & 0 deletions download_models/downloadModels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ if [ "$REFRESH_MODE" -eq 1 ]; then
fi

pipelineZooModel="https://github.com/dlstreamer/pipeline-zoo-models/raw/main/storage/"
openVINOModelZoo="https://storage.openvinotoolkit.org/repositories/open_model_zoo/2022.3/models_bin/1/"

# $1 model file name
# $2 download URL
Expand Down Expand Up @@ -136,8 +137,22 @@ downloadTextRecognition() {
fi
}

downloadPersonDetection() {
personDetection0106="person-detection-0200"
modelType="object_detection"
personjsonModelPath="$modelType/$personDetection0106/$modelPrecisionFP16INT8/$personDetection0106.bin"
echo $personjsonModelPath

if [ ! -f $personjsonModelPath ]; then
getModelFiles $personDetection0106 $openVINOModelZoo$personDetection0106 $modelPrecisionFP16INT8 $modelType
else
echo "personDetection0106 $modelPrecisionFP16INT8 model already exists, skip downloading..."
fi
}

### Run custom downloader section below:
downloadYolov5sFP16INT8
downloadEfficientnetb0
downloadHorizontalText
downloadTextRecognition
downloadPersonDetection
2 changes: 1 addition & 1 deletion src/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# SPDX-License-Identifier: Apache-2.0
#

FROM intel/dlstreamer:2024.1.1-dev-ubuntu22 as base
FROM intel/dlstreamer:2024.1.2-ubuntu24 as base
USER root

FROM base as build-default
Expand Down
3 changes: 3 additions & 0 deletions src/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +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}
volumes:
- ${RESULTS_DIR:-../results}:/tmp/results
- ~/.Xauthority:/home/dlstreamer/.Xauthority
Expand Down
12 changes: 8 additions & 4 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"
echo "usage: \"--pipeline_script_choice\" requires an argument yolov5s.sh|yolov5s_effnetb0.sh|yolov5s_full.sh|people_detection.sh"
}

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" ]
if [ "$PIPELINE_SCRIPT" != "yolov5s.sh" ] && [ "$PIPELINE_SCRIPT" != "yolov5s_effnetb0.sh" ] && [ "$PIPELINE_SCRIPT" != "yolov5s_full.sh" ] && [ "$PIPELINE_SCRIPT" != "people_detection.sh" ]
then
echo "Error on your input: $PIPELINE_SCRIPT"
show_help
Expand Down Expand Up @@ -96,11 +96,15 @@ elif grep -q "file" <<< "$INPUTSRC"; then
arrfilesrc=(${INPUTSRC//:/ })
# use vids since container maps a volume to this location based on sample-media folder
inputsrc="filesrc location=vids/"${arrfilesrc[1]}" ! qtdemux ! h264parse "
elif grep -q "video" <<< "$INPUTSRC"; then
elif grep -q "/dev" <<< "$INPUTSRC"; then
inputsrc="v4l2src device="$INPUTSRC
DECODE="$DECODE ! videoconvert ! video/x-raw,format=BGR"
# when using realsense camera, the dgpu.0 not working
# for http:// videos
elif grep -q "http" <<< "$INPUTSRC"; then
inputsrc="urisourcebin buffer-size=4096 uri="$INPUTSRC
DECODE="decodebin"
else
# when using realsense camera, the dgpu.0 not working
# rs-serial realsenssrc
inputsrc="realsensesrc cam-serial-number="$INPUTSRC" stream-type=0 align=0 imu_on=false"
echo "----- in run_gst.sh COLOR_WIDTH=$COLOR_WIDTH, COLOR_HEIGHT=$COLOR_HEIGHT, COLOR_FRAMERATE=$COLOR_FRAMERATE"
Expand Down
27 changes: 27 additions & 0 deletions src/pipelines/people_detection.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 ! video/x-raw,format=I420 ! 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 yolov5s pipeline on $DEVICE with batch size = $BATCH_SIZE"
antoniomtz marked this conversation as resolved.
Show resolved Hide resolved

gstLaunchCmd="GST_DEBUG=\"GST_TRACER:7\" GST_TRACERS=\"latency_tracer(flags=pipeline,interval=100)\" gst-launch-1.0 $inputsrc ! $DECODE ! gvaattachroi roi=$ROI ! gvadetect batch-size=$BATCH_SIZE model-instance-id=odmodel name=detection model=models/object_detection/person-detection-0200/FP16-INT8/person-detection-0200.xml threshold=.5 device=$DEVICE $PRE_PROCESS inference-region=1 ! $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
1 change: 1 addition & 0 deletions src/res/person-detection.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ROI="400,200,600,400"
Loading