Skip to content

Commit

Permalink
feat: streamlining result log filename for preparation of benchmarkin…
Browse files Browse the repository at this point in the history
…g different pipelines at the same time

Signed-off-by: Jim Wang <yutsung.jim.wang@intel.com>
  • Loading branch information
jim-wang-intel committed Nov 4, 2024
1 parent f05b2d1 commit 164181e
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 21 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ build-benchmark:
cd performance-tools && $(MAKE) build-benchmark-docker

benchmark: build-benchmark download-models
cd performance-tools/benchmark-scripts && python benchmark.py --compose_file ../../src/docker-compose.yml \
cd performance-tools/benchmark-scripts && python benchmark.py --compose_file ../../src/$(DOCKER_COMPOSE) \
--pipeline $(PIPELINE_COUNT) --duration $(BENCHMARK_DURATION) --results_dir $(RESULTS_DIR)
# consolidate to show the summary csv
@cd performance-tools/benchmark-scripts && ROOT_DIRECTORY=$(RESULTS_DIR) $(MAKE) --no-print-directory consolidate && \
echo "Loss Prevention benchmark results are saved in $(RESULTS_DIR)/summary.csv file" && \
echo "====== Loss prevention benchmark results summary: " && cat $(RESULTS_DIR)/summary.csv

benchmark-stream-density: build-benchmark download-models
cd performance-tools/benchmark-scripts && python benchmark.py --compose_file ../../src/docker-compose.yml \
cd performance-tools/benchmark-scripts && python benchmark.py --compose_file ../../src/$(DOCKER_COMPOSE) \
--target_fps $(TARGET_FPS) --density_increment 1 --results_dir $(RESULTS_DIR)

clean-benchmark-results:
Expand Down
113 changes: 113 additions & 0 deletions src/docker-compose-2-clients.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#
# Copyright (C) 2024 Intel Corporation.
#
# SPDX-License-Identifier: Apache-2.0
#


## Current Developer Toolbox doesn't support environment files, make sure to remove any files or environment variables starting with $
version: '3.7'
services:
camera-simulator:
container_name: camera-simulator
image: aler9/rtsp-simple-server
ports:
- "127.0.0.1:8554:8554"
camera-simulator0:
image: jrottenberg/ffmpeg:4.1-alpine
container_name: camera-simulator0
network_mode: "host"
entrypoint: ["/bin/sh","-c"]
command:
- |
if [ ! -f /home/pipeline-server/sample-media/coca-cola-4465029-1920-15-bench.mp4 ]; then
mkdir -p /home/pipeline-server/sample-media
wget -O /home/pipeline-server/sample-media/coca-cola-4465029-1920-15-bench.mp4 https://www.pexels.com/download/video/4465029
fi
ffmpeg -nostdin -re -stream_loop -1 -i /home/pipeline-server/sample-media/coca-cola-4465029-1920-15-bench.mp4 -c copy -f rtsp -rtsp_transport tcp rtsp://localhost:8554/camera_0
depends_on:
- camera-simulator
volumes:
- ${RETAIL_USE_CASE_ROOT:-..}/performance-tools/sample-media:/home/pipeline-server/sample-media

OvmsClientGst1:
image: dlstreamer:dev
deploy:
mode: replicated
replicas: ${PIPELINE_COUNT:-1}
network_mode: "host"
entrypoint: /script/entrypoint.sh --pipeline_script_choice ${PIPELINE_SCRIPT:-yolov5s.sh}
privileged: true
ipc: "host"
env_file:
- ./res/gst.env
- ${DEVICE_ENV:-res/all-cpu.env}
environment:
- CONTAINER_NAME=gst1
- 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
- HTTPS_PROXY
- NO_PROXY
volumes:
- ${RESULTS_DIR:-../results}:/tmp/results
- ~/.Xauthority:/home/dlstreamer/.Xauthority
- /tmp/.X11-unix
- ~/.cl-cache:/home/pipeline-server/.cl-cache
- ./res/:/home/pipeline-server/envs
- ${RETAIL_USE_CASE_ROOT:-..}/models:/home/pipeline-server/models
- ./pipelines/:/home/pipeline-server/pipelines
- ./extensions/:/home/pipeline-server/extensions

OvmsClientGst2:
image: dlstreamer:dev
deploy:
mode: replicated
replicas: ${PIPELINE_COUNT:-1}
network_mode: "host"
entrypoint: /script/entrypoint.sh --pipeline_script_choice ${PIPELINE_SCRIPT:-yolov8s_roi.sh}
privileged: true
ipc: "host"
env_file:
- ./res/gst.env
- ${DEVICE_ENV:-res/all-cpu.env}
environment:
- CONTAINER_NAME=gst2
- 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
- HTTPS_PROXY
- NO_PROXY
volumes:
- ${RESULTS_DIR:-../results}:/tmp/results
- ~/.Xauthority:/home/dlstreamer/.Xauthority
- /tmp/.X11-unix
- ~/.cl-cache:/home/pipeline-server/.cl-cache
- ./res/:/home/pipeline-server/envs
- ${RETAIL_USE_CASE_ROOT:-..}/models:/home/pipeline-server/models
- ./pipelines/:/home/pipeline-server/pipelines
- ./extensions/:/home/pipeline-server/extensions

mosquitto:
image: eclipse-mosquitto:2.0
container_name: mosquitto
network_mode: "host"
ports:
- "127.0.0.1:1883:1883"
depends_on:
- OvmsClientGst1
- OvmsClientGst2

mqtt_tracker:
image: loss-prevention:dev
network_mode: "host"
environment:
- MQTT_URL=127.0.0.1
- MQTT_PORT=1883
- MQTT_TOPIC=event/detection
- ROI_NAME=BASKET
restart: always
depends_on:
- mosquitto
14 changes: 8 additions & 6 deletions src/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ checkBatchSize() {
}

cid_count="${cid_count:=0}"
CONTAINER_NAME="${CONTAINER_NAME:=gst}"
cameras="${cameras:=}"
stream_density_mount="${stream_density_mount:=}"
stream_density_params="${stream_density_params:=}"
Expand Down Expand Up @@ -125,14 +126,15 @@ fi

# generate unique container id based on the date with the precision upto nano-seconds
cid=$(date +%Y%m%d%H%M%S%N)
cid="${cid}"_${CONTAINER_NAME}
echo "cid: $cid"

touch /tmp/results/r"$cid"_gst.jsonl
chown 1000:1000 /tmp/results/r"$cid"_gst.jsonl
touch /tmp/results/gst-launch_"$cid"_gst.log
chown 1000:1000 /tmp/results/gst-launch_"$cid"_gst.log
touch /tmp/results/pipeline"$cid"_gst.log
chown 1000:1000 /tmp/results/pipeline"$cid"_gst.log
touch /tmp/results/r"$cid".jsonl
chown 1000:1000 /tmp/results/r"$cid".jsonl
touch /tmp/results/gst-launch_"$cid".log
chown 1000:1000 /tmp/results/gst-launch_"$cid".log
touch /tmp/results/pipeline"$cid".log
chown 1000:1000 /tmp/results/pipeline"$cid".log

cl_cache_dir="/home/pipeline-server/.cl-cache" \
DISPLAY="$DISPLAY" \
Expand Down
4 changes: 2 additions & 2 deletions src/pipelines/age_recognition.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

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
PUBLISH="${PUBLISH:="name=destination file-format=2 file-path=/tmp/results/r$cid.jsonl"}" # address=localhost:1883 topic=inferenceEvent method=mqtt

CLASSIFICATION_OPTIONS="${CLASSIFICATION_OPTIONS:="reclassify-interval=1 $DETECTION_OPTIONS"}" # Extra Classification model parameters ex. "" | reclassify-interval=1 batch-size=1 nireq=4 gpu-throughput-streams=4

Expand All @@ -29,7 +29,7 @@ gstLaunchCmd="gst-launch-1.0 $inputsrc ! $DECODE ! \
gvadetect batch-size=$BATCH_SIZE model-instance-id=odmodel name=detection model=$DETECT_MODEL_PATH threshold=.8 device=$DEVICE ! \
gvaclassify batch-size=$BATCH_SIZE model-instance-id=classifier name=recognition model-proc=$CLASS_MODEL_PROC_PATH model=$CLASS_MODEL_PATH device=$DEVICE $CLASSIFICATION_OPTIONS ! \
$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)"
gvametapublish name=destination file-format=2 file-path=/tmp/results/r$cid.jsonl $OUTPUT 2>&1 | tee >/tmp/results/gst-launch_$cid.log >(stdbuf -oL sed -n -e 's/^.*current: //p' | stdbuf -oL cut -d , -f 1 > /tmp/results/pipeline$cid.log)"

echo "$gstLaunchCmd"

Expand Down
4 changes: 2 additions & 2 deletions src/pipelines/people_detection.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

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
PUBLISH="${PUBLISH:="name=destination file-format=2 file-path=/tmp/results/r$cid.jsonl"}" # address=localhost:1883 topic=inferenceEvent method=mqtt

ROI="${ROI:="0,0,400,400"}"

Expand All @@ -20,7 +20,7 @@ fi
echo "decode type $DECODE"
echo "Run person-detection pipeline 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 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)"
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.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.log)"

echo "$gstLaunchCmd"

Expand Down
4 changes: 2 additions & 2 deletions src/pipelines/yolov5s.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

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
PUBLISH="${PUBLISH:="name=destination file-format=2 file-path=/tmp/results/r$cid.jsonl"}" # address=localhost:1883 topic=inferenceEvent method=mqtt

if [ "$RENDER_MODE" == "1" ]; then
OUTPUT="${OUTPUT:="! videoconvert ! video/x-raw,format=I420 ! gvawatermark ! videoconvert ! fpsdisplaysink video-sink=ximagesink sync=true --verbose"}"
Expand All @@ -18,7 +18,7 @@ fi
echo "decode type $DECODE"
echo "Run yolov5s pipeline 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 ! gvadetect batch-size=$BATCH_SIZE model-instance-id=odmodel name=detection model=models/object_detection/yolov5s/FP16-INT8/yolov5s.xml model-proc=models/object_detection/yolov5s/yolov5s.json threshold=.5 device=$DEVICE $PRE_PROCESS ! $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)"
gstLaunchCmd="GST_DEBUG=\"GST_TRACER:7\" GST_TRACERS=\"latency_tracer(flags=pipeline,interval=100)\" gst-launch-1.0 $inputsrc ! $DECODE ! gvadetect batch-size=$BATCH_SIZE model-instance-id=odmodel name=detection model=models/object_detection/yolov5s/FP16-INT8/yolov5s.xml model-proc=models/object_detection/yolov5s/yolov5s.json threshold=.5 device=$DEVICE $PRE_PROCESS ! $AGGREGATE gvametaconvert name=metaconvert add-empty-results=true ! gvametapublish name=destination file-format=2 file-path=/tmp/results/r$cid.jsonl $OUTPUT 2>&1 | tee >/tmp/results/gst-launch_$cid.log >(stdbuf -oL sed -n -e 's/^.*current: //p' | stdbuf -oL cut -d , -f 1 > /tmp/results/pipeline$cid.log)"

echo "$gstLaunchCmd"

Expand Down
6 changes: 3 additions & 3 deletions src/pipelines/yolov5s_effnetb0.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

if [ "$INPUTSRC_TYPE" == "REALSENSE" ]; then
# TODO: update with vaapipostproc when MJPEG codec is supported.
echo "Not supported until D436 with MJPEG." > /tmp/results/pipeline$cid_count.log
echo "Not supported until D436 with MJPEG." > /tmp/results/pipeline$cid.log
exit 2
fi

Expand All @@ -17,7 +17,7 @@ DETECTION_OPTIONS="${DETECTION_OPTIONS:="gpu-throughput-streams=4 nireq=4 batch-

CLASSIFICATION_OPTIONS="${CLASSIFICATION_OPTIONS:="reclassify-interval=1 $DETECTION_OPTIONS"}" # Extra Classification model parameters ex. "" | reclassify-interval=1 batch-size=1 nireq=4 gpu-throughput-streams=4

PUBLISH="${PUBLISH:="name=destination file-format=2 file-path=/tmp/results/r$cid\"_gst\".jsonl"}" # address=localhost:1883 topic=inferenceEvent method=mqtt
PUBLISH="${PUBLISH:="name=destination file-format=2 file-path=/tmp/results/r$cid.jsonl"}" # address=localhost:1883 topic=inferenceEvent method=mqtt

if [ "$RENDER_MODE" == "1" ]; then
OUTPUT="${OUTPUT:="! videoconvert ! video/x-raw,format=I420 ! gvawatermark ! videoconvert ! fpsdisplaysink video-sink=ximagesink sync=true --verbose"}"
Expand All @@ -27,7 +27,7 @@ fi

echo "Run run yolov5s with efficientnet classification pipeline on $DEVICE with batch size = $BATCH_SIZE"

gstLaunchCmd="gst-launch-1.0 $inputsrc ! $DECODE ! gvadetect batch-size=$BATCH_SIZE model-instance-id=odmodel name=detection model=/home/pipeline-server/models/object_detection/yolov5s/FP16-INT8/yolov5s.xml model-proc=/home/pipeline-server/models/object_detection/yolov5s/yolov5s.json threshold=.5 device=$DEVICE $PRE_PROCESS $DETECTION_OPTIONS ! gvatrack name=tracking tracking-type=zero-term-imageless ! queue max-size-bytes=0 max-size-buffers=0 max-size-time=0 ! gvaclassify model-instance-id=clasifier labels=/home/pipeline-server/models/object_classification/efficientnet-b0/imagenet_2012.txt model=/home/pipeline-server/models/object_classification/efficientnet-b0/FP32/efficientnet-b0.xml model-proc=/home/pipeline-server/models/object_classification/efficientnet-b0/efficientnet-b0.json device=$CLASSIFICATION_DEVICE inference-region=roi-list name=classification $CLASSIFICATION_PRE_PROCESS $CLASSIFICATION_OPTIONS ! 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)"
gstLaunchCmd="gst-launch-1.0 $inputsrc ! $DECODE ! gvadetect batch-size=$BATCH_SIZE model-instance-id=odmodel name=detection model=/home/pipeline-server/models/object_detection/yolov5s/FP16-INT8/yolov5s.xml model-proc=/home/pipeline-server/models/object_detection/yolov5s/yolov5s.json threshold=.5 device=$DEVICE $PRE_PROCESS $DETECTION_OPTIONS ! gvatrack name=tracking tracking-type=zero-term-imageless ! queue max-size-bytes=0 max-size-buffers=0 max-size-time=0 ! gvaclassify model-instance-id=clasifier labels=/home/pipeline-server/models/object_classification/efficientnet-b0/imagenet_2012.txt model=/home/pipeline-server/models/object_classification/efficientnet-b0/FP32/efficientnet-b0.xml model-proc=/home/pipeline-server/models/object_classification/efficientnet-b0/efficientnet-b0.json device=$CLASSIFICATION_DEVICE inference-region=roi-list name=classification $CLASSIFICATION_PRE_PROCESS $CLASSIFICATION_OPTIONS ! gvametaconvert name=metaconvert add-empty-results=true ! gvametapublish name=destination file-format=2 file-path=/tmp/results/r$cid.jsonl $OUTPUT 2>&1 | tee >/tmp/results/gst-launch_$cid.log >(stdbuf -oL sed -n -e 's/^.*current: //p' | stdbuf -oL cut -d , -f 1 > /tmp/results/pipeline$cid.log)"

echo "$gstLaunchCmd"

Expand Down
Loading

0 comments on commit 164181e

Please sign in to comment.