Skip to content

Commit

Permalink
feat: Pipeline Server versions of automated self checkout (#600)
Browse files Browse the repository at this point in the history
---------

Signed-off-by: Brian McGinn <[email protected]>
  • Loading branch information
brian-intel authored Jul 24, 2024
1 parent f2e8932 commit ccdcc89
Show file tree
Hide file tree
Showing 19 changed files with 746 additions and 51 deletions.
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ PIPELINE_COUNT ?= 1
TARGET_FPS ?= 14.95
DOCKER_COMPOSE ?= docker-compose.yml
RESULTS_DIR ?= $(PWD)/results
RETAIL_USE_CASE_ROOT ?= $(PWD)

download-models:
./download_models/downloadModels.sh
Expand Down Expand Up @@ -37,6 +38,9 @@ build:
build-realsense:
docker build --build-arg HTTPS_PROXY=${HTTPS_PROXY} --build-arg HTTP_PROXY=${HTTP_PROXY} --target build-realsense -t dlstreamer:realsense -f src/Dockerfile src/

build-pipeline-server:
docker build --build-arg HTTPS_PROXY=${HTTPS_PROXY} --build-arg HTTP_PROXY=${HTTP_PROXY} -t dlstreamer:pipeline-server -f src/pipeline-server/Dockerfile.pipeline-server src/pipeline-server

run:
docker compose -f src/$(DOCKER_COMPOSE) up -d

Expand All @@ -59,6 +63,12 @@ run-headless: | download-models update-submodules download-sample-videos
@echo Running automated self checkout pipeline
$(MAKE) run

run-pipeline-server: | download-models update-submodules download-sample-videos build-pipeline-server
RETAIL_USE_CASE_ROOT=$(RETAIL_USE_CASE_ROOT) docker compose -f src/pipeline-server/docker-compose.pipeline-server.yml up -d

down-pipeline-server:
docker compose -f src/pipeline-server/docker-compose.pipeline-server.yml down

build-benchmark:
cd performance-tools && $(MAKE) build-benchmark-docker

Expand Down
71 changes: 38 additions & 33 deletions download_models/downloadModels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

modelPrecisionFP16INT8="FP16-INT8"
modelPrecisionFP32INT8="FP32-INT8"
modelPrecisionFP32="FP32"

REFRESH_MODE=0
while [ $# -gt 0 ]; do
Expand Down Expand Up @@ -43,13 +44,9 @@ pipelineZooModel="https://github.com/dlstreamer/pipeline-zoo-models/raw/main/sto
# $2 download URL
# $3 model percision
getModelFiles() {
# Make model directory
# ex. kdir efficientnet-b0/1/FP16-INT8
mkdir -p "$1"/"$3"/1

# Get the models
wget "$2"/"$3"/"$1"".bin" -P "$1"/"$3"/1
wget "$2"/"$3"/"$1"".xml" -P "$1"/"$3"/1
wget "$2"/"$3"/"$1"".bin" -P "$4"/"$1"/"$3"/
wget "$2"/"$3"/"$1"".xml" -P "$4"/"$1"/"$3"/
}

# $1 model file name
Expand All @@ -59,75 +56,83 @@ getModelFiles() {
# $5 precision folder
getProcessFile() {
# Get process file
wget "$2"/"$3".json -O "$1"/"$5"/1/"$4".json
wget "$2"/"$3".json -O "$5"/"$1"/"$4".json
}

# $1 model name
# $2 download label URL
# $3 label file name
getLabelFile() {
mkdir -p "$1/1"

wget "$2/$3" -P "$1/1"
wget "$2/$3" -P "$4"/"$1"
}

# custom yolov5s model downloading for this particular precision FP16INT8
downloadYolov5sFP16INT8() {
yolov5s="yolov5s"
yolojson="yolo-v5"
modelType="object_detection"

# checking whether the model file .bin already exists or not before downloading
yolov5ModelFile="${PWD}/$yolov5s/$modelPrecisionFP16INT8/1/$yolov5s.bin"
yolov5ModelFile="$modelType/$yolov5s/$modelPrecisionFP16INT8/$yolov5s.bin"
if [ -f "$yolov5ModelFile" ]; then
echo "yolov5s $modelPrecisionFP16INT8 model already exists in $yolov5ModelFile, skip downloading..."
else
echo "Downloading yolov5s $modelPrecisionFP16INT8 models..."
# Yolov5s FP16_INT8
getModelFiles $yolov5s $pipelineZooModel"yolov5s-416_INT8" $modelPrecisionFP16INT8
getProcessFile $yolov5s $pipelineZooModel"yolov5s-416" $yolojson $yolov5s $modelPrecisionFP16INT8
echo "yolov5 $modelPrecisionFP16INT8 model downloaded in $yolov5ModelFile"
getModelFiles $yolov5s $pipelineZooModel"yolov5s-416_INT8" $modelPrecisionFP16INT8 $modelType
getProcessFile $yolov5s $pipelineZooModel"yolov5s-416_INT8" $yolojson $yolov5s $modelType
echo "yolov5 $modelPrecisionFP16INT8 model downloaded in $yolov5ModelFile" $modelType
fi
}

# efficientnet-b0 (model is unsupported in {'FP32-INT8'} precisions, so we have custom downloading function below:
downloadEfficientnetb0() {
efficientnetb0="efficientnet-b0"
modelType=object_classification
# FP32-INT8 efficientnet-b0 for capi
customefficientnetb0Modelfile="$efficientnetb0/$modelPrecisionFP32INT8/1/efficientnet-b0.xml"
customefficientnetb0Modelfile="$modelType/$efficientnetb0/$efficientnetb0.json"
if [ ! -f $customefficientnetb0Modelfile ]; then
echo "downloading model efficientnet $modelPrecisionFP32INT8 model..."
mkdir -p "$efficientnetb0"/"$modelPrecisionFP32INT8"
mkdir -p "$efficientnetb0"/"$modelPrecisionFP32INT8"/1

wget "https://github.com/dlstreamer/pipeline-zoo-models/raw/main/storage/efficientnet-b0_INT8/$modelPrecisionFP32INT8/efficientnet-b0.bin" -P "$efficientnetb0/$modelPrecisionFP32INT8/1"
wget "https://github.com/dlstreamer/pipeline-zoo-models/raw/main/storage/efficientnet-b0_INT8/$modelPrecisionFP32INT8/efficientnet-b0.xml" -P "$efficientnetb0/$modelPrecisionFP32INT8/1"

dlstreamerLabelURL="https://raw.githubusercontent.com/dlstreamer/dlstreamer/master/samples/labels/"
textEfficiennetJsonFilePath="$efficientnetb0/$efficientnetb0.json"
if [ ! -f $textEfficiennetJsonFilePath ]; then
wget "https://github.com/dlstreamer/pipeline-zoo-models/raw/main/storage/efficientnet-b0_INT8/efficientnet-b0.json" -O "$efficientnetb0/$efficientnetb0.json"
getLabelFile $efficientnetb0 $dlstreamerLabelURL "imagenet_2012.txt"
fi

wget "https://github.com/dlstreamer/pipeline-zoo-models/raw/main/storage/efficientnet-b0_INT8/$modelPrecisionFP32INT8/efficientnet-b0.bin" -P "$modelType/$efficientnetb0/$modelPrecisionFP32"
wget "https://github.com/dlstreamer/pipeline-zoo-models/raw/main/storage/efficientnet-b0_INT8/$modelPrecisionFP32INT8/efficientnet-b0.xml" -P "$modelType/$efficientnetb0/$modelPrecisionFP32"
wget "https://github.com/dlstreamer/pipeline-zoo-models/raw/main/storage/efficientnet-b0_INT8/efficientnet-b0.json" -P "$modelType/$efficientnetb0"
wget "https://raw.githubusercontent.com/dlstreamer/dlstreamer/master/samples/labels/imagenet_2012.txt" -P "$modelType/$efficientnetb0"
else
echo "efficientnet $modelPrecisionFP32INT8 model already exists, skip downloading..."
fi
}

downloadHorizontalText() {
horizontalText0002="horizontal-text-detection-0002"
horizontaljsonfilepath="$horizontalText0002/$modelPrecisionFP16INT8/1/$horizontalText0002.json"
modelType="text_detection"
horizontaljsonfilepath="$modelType/$horizontalText0002/$horizontalText0002.json"

if [ ! -f $horizontaljsonfilepath ]; then
getModelFiles $horizontalText0002 $pipelineZooModel$horizontalText0002 $modelPrecisionFP16INT8
getProcessFile $horizontalText0002 $pipelineZooModel$horizontalText0002 $horizontalText0002 $horizontalText0002 $modelPrecisionFP16INT8
getModelFiles $horizontalText0002 $pipelineZooModel$horizontalText0002 $modelPrecisionFP16INT8 $modelType
getProcessFile $horizontalText0002 $pipelineZooModel$horizontalText0002 $horizontalText0002 $horizontalText0002 $modelType
mv "$modelType/$horizontalText0002/$modelPrecisionFP16INT8" "$modelType/$horizontalText0002/$modelPrecisionFP32"
else
echo "horizontalText0002 $modelPrecisionFP16INT8 model already exists, skip downloading..."
fi
}

downloadTextRecognition() {
textRec0012Mod="text-recognition-0012-mod"
textRec0012Modjsonfilepath="$textRec0012Mod/$modelPrecisionFP16INT8/1/$textRec0012Mod.json"
textRec0012="text-recognition-0012"
modelType="text_recognition"
textRec0012Modjsonfilepath="$modelType/$textRec0012/$textRec0012.json"

if [ ! -f $textRec0012Modjsonfilepath ]; then
getModelFiles $textRec0012Mod $pipelineZooModel$textRec0012Mod $modelPrecisionFP16INT8
getProcessFile $textRec0012Mod $pipelineZooModel$textRec0012Mod $textRec0012Mod $textRec0012Mod $modelPrecisionFP16INT8
getModelFiles $textRec0012Mod $pipelineZooModel$textRec0012Mod $modelPrecisionFP16INT8 $modelType
getProcessFile $textRec0012Mod $pipelineZooModel$textRec0012Mod $textRec0012Mod $textRec0012Mod $modelType
mv "$modelType/$textRec0012Mod" "$modelType/$textRec0012"
mv "$modelType/$textRec0012/$modelPrecisionFP16INT8/$textRec0012Mod.xml" "$modelType/$textRec0012/$modelPrecisionFP16INT8/$textRec0012.xml"
mv "$modelType/$textRec0012/$modelPrecisionFP16INT8/$textRec0012Mod.bin" "$modelType/$textRec0012/$modelPrecisionFP16INT8/$textRec0012.bin"
mv "$modelType/$textRec0012/$modelPrecisionFP16INT8" "$modelType/$textRec0012/$modelPrecisionFP32"
mv "$modelType/$textRec0012/$textRec0012Mod.json" "$modelType/$textRec0012/$textRec0012.json"
else
echo "textRec0012 $modelPrecisionFP16INT8 model already exists, skip downloading..."
fi
}

Expand Down
21 changes: 7 additions & 14 deletions src/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,17 @@ services:
ports:
- "127.0.0.1:8554:8554"
camera-simulator0:
image: openvino/ubuntu20_data_runtime:2021.4.2
image: jrottenberg/ffmpeg:4.1-alpine
container_name: camera-simulator0
network_mode: "host"
entrypoint: ffmpeg
command: "
-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
"
entrypoint: ["/bin/sh","-c"]
command:
- |
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/video/4465029/download
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

OvmsClientGst:
image: dlstreamer:dev
Expand Down
10 changes: 10 additions & 0 deletions src/pipeline-server/Dockerfile.pipeline-server
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#
# Copyright (C) 2024 Intel Corporation.
#
# SPDX-License-Identifier: Apache-2.0
#

FROM intel/dlstreamer-pipeline-server:2022.2.0-ubuntu20-gpu419.40

COPY ./requirements.txt /requirements.txt
RUN pip3 install --upgrade pip --no-cache-dir -r /requirements.txt
29 changes: 29 additions & 0 deletions src/pipeline-server/asc/detection/yolov5/pipeline.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"type": "GStreamer",
"template": [
"{auto_source} ! decodebin",
" ! gvadetect model={models[object_detection][yolov5s][FP16-INT8][network]} name=detection",
" ! gvametaconvert name=metaconvert ! gvametapublish name=destination",
" ! appsink name=appsink"
],
"description": "Object detection with yolov5s",
"parameters": {
"type": "object",
"properties": {
"detection-properties": {
"element": {
"name": "detection",
"format": "element-properties"
}
},
"detection-device": {
"element": {
"name": "detection",
"property": "device"
},
"type": "string",
"default": "{env[DETECTION_DEVICE]}"
}
}
}
}
30 changes: 30 additions & 0 deletions src/pipeline-server/asc/detection/yolov5_effnet/pipeline.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"type": "GStreamer",
"template": [
"{auto_source} ! decodebin",
" ! gvadetect model={models[object_detection][yolov5s][FP16-INT8][network]} name=detection",
" ! gvaclassify model={models[object_classification][efficientnet-b0][network]} name=classification",
" ! gvametaconvert name=metaconvert ! gvametapublish name=destination",
" ! appsink name=appsink"
],
"description": "Object detection with yolov5s",
"parameters": {
"type": "object",
"properties": {
"detection-properties": {
"element": {
"name": "detection",
"format": "element-properties"
}
},
"detection-device": {
"element": {
"name": "detection",
"property": "device"
},
"type": "string",
"default": "{env[DETECTION_DEVICE]}"
}
}
}
}
36 changes: 36 additions & 0 deletions src/pipeline-server/asc/detection/yolov5_full/pipeline.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"type": "GStreamer",
"template": [
"{auto_source} ! decodebin",
" ! gvadetect model={models[object_detection][yolov5s][FP16-INT8][network]} name=detection",
" ! gvatrack name=tracking tracking-type=zero-term-imageless",
" ! gvaclassify model={models[object_classification][efficientnet-b0][network]} inference-region=roi-list name=classification",
" ! gvapython class=ObjectFilter module=/home/pipeline-server/extensions/tracked_object_filter.py name=tracked_object_filter",
" ! gvadetect model={models[text_detection][horizontal-text-detection-0002][network]} name=text_detection inference-region=roi-list",
" ! gvainference model={models[text_recognition][text-recognition-0012][network]} name=text_recognition inference-region=roi-list object-class=text",
" ! gvapython class=OCR module=/home/pipeline-server/gvapython/OCR_post_processing_0012.py name=ocr_postprocess",
" ! gvapython name=barcode class=BarcodeDetection module=/home/pipeline-server/gvapython/barcode_nv12_to_gray.py",
" ! gvametaconvert name=metaconvert add-empty-results=true ! gvametapublish name=destination",
" ! appsink name=appsink"
],
"description": "Object detection with yolov5s",
"parameters": {
"type": "object",
"properties": {
"detection-properties": {
"element": {
"name": "detection",
"format": "element-properties"
}
},
"detection-device": {
"element": {
"name": "detection",
"property": "device"
},
"type": "string",
"default": "{env[DETECTION_DEVICE]}"
}
}
}
}
Loading

0 comments on commit ccdcc89

Please sign in to comment.