Skip to content
This repository has been archived by the owner on Jul 10, 2023. It is now read-only.

Commit

Permalink
Merge pull request #103 from dlstreamer/v0.7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Bruce committed Feb 22, 2022
2 parents ead1dee + 8a35450 commit 87de4c9
Show file tree
Hide file tree
Showing 87 changed files with 3,842 additions and 812 deletions.
254 changes: 161 additions & 93 deletions README.md

Large diffs are not rendered by default.

58 changes: 29 additions & 29 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
# SPDX-License-Identifier: BSD-3-Clause
#

ARG BASE=video-analytics-serving-gstreamer-base
ARG BASE=dlstreamer-pipeline-server-gstreamer-base
ARG MODELS_COMMAND=do_not_copy_models
ARG PIPELINES_COMMAND=do_not_copy_pipelines
ARG FINAL_STAGE=video-analytics-serving-environment
ARG FINAL_STAGE=dlstreamer-pipeline-server-environment

########################################################
# First stage installs video-analytics-serving and its dependencies on top of a compatible Media Analytics Base.
# First stage installs dlstreamer-pipeline-server and its dependencies on top of a compatible Media Analytics Base.
# See documentation for more details on requirements for the Media Analytics Base.

FROM ${BASE} as video-analytics-serving
FROM ${BASE} as dlstreamer-pipeline-server
ARG FRAMEWORK=gstreamer

# Multi-License Disclaimer
Expand All @@ -23,14 +23,14 @@ RUN echo "IMPORTANT: This script will build third party components licensed unde
USER root

# Dependencies for OpenVINO
ARG BASE=video-analytics-serving-gstreamer-base
ARG BASE=dlstreamer-pipeline-server-gstreamer-base
ENV VA_SERVING_BASE=${BASE}
SHELL ["/bin/bash", "-c"]

# Creating user vaserving and adding it to groups "video" and "users" to use GPU and VPU
ARG USER=vaserving
RUN useradd -ms /bin/bash -G video,audio,users ${USER} -d /home/video-analytics-serving && \
chown ${USER} -R /home/video-analytics-serving /root
# Creating user pipeline-server and adding it to groups "video" and "users" to use GPU and VPU
ARG USER=pipeline-server
RUN useradd -ms /bin/bash -G video,audio,users ${USER} -d /home/pipeline-server && \
chown ${USER} -R /home/pipeline-server /root

RUN if [ -f /opt/intel/openvino/install_dependencies/install_NEO_OCL_driver.sh ]; then \
/opt/intel/openvino/install_dependencies/install_NEO_OCL_driver.sh -y ; exit 0; \
Expand Down Expand Up @@ -74,17 +74,17 @@ COPY ./requirements.txt /
RUN pip3 install --upgrade pip --no-cache-dir -r /requirements.txt
RUN rm -f /requirements.txt

# Video Analytics Serving Python Modules
COPY ./vaserving /home/video-analytics-serving/vaserving
COPY ./vaclient /home/video-analytics-serving/vaclient
COPY --chown=vaserving ./tools /home/video-analytics-serving/tools
# Intel(R) DL Streamer Pipeline Server Python Modules
COPY ./vaserving /home/pipeline-server/vaserving
COPY ./vaclient /home/pipeline-server/vaclient
COPY --chown=pipeline-server ./tools /home/pipeline-server/tools

# Copy GVA Python extensions
COPY ./extensions /home/video-analytics-serving/extensions
COPY ./extensions /home/pipeline-server/extensions

# Media Analytics Framework set via environment variable
ENV FRAMEWORK=${FRAMEWORK}
WORKDIR /home/video-analytics-serving
WORKDIR /home/pipeline-server
########################################################

########################################################
Expand All @@ -93,16 +93,16 @@ WORKDIR /home/video-analytics-serving
# The stage used in the final image is controlled via the build argument MODEL_COMMAND.

# Creates a stage that does not copy models
FROM video-analytics-serving as do_not_copy_models
FROM dlstreamer-pipeline-server as do_not_copy_models

# Creates a stage that copies models from the build context
FROM video-analytics-serving as copy_models
FROM dlstreamer-pipeline-server as copy_models
ONBUILD ARG MODELS_PATH
ONBUILD ENV MODELS_PATH=${MODELS_PATH}
ONBUILD COPY ${MODELS_PATH} /home/video-analytics-serving/models
ONBUILD COPY ${MODELS_PATH} /home/pipeline-server/models

# Stage that is used is controlled via MODELS_COMMAND build argument
FROM ${MODELS_COMMAND} as video-analytics-serving-with-models
FROM ${MODELS_COMMAND} as dlstreamer-pipeline-server-with-models
########################################################

########################################################
Expand All @@ -111,27 +111,27 @@ FROM ${MODELS_COMMAND} as video-analytics-serving-with-models
# The stage used in the final image is controlled via the build argument PIPELINES_COMMAND.

# Creates a stage that does not copy pipelines
FROM video-analytics-serving-with-models as do_not_copy_pipelines
FROM dlstreamer-pipeline-server-with-models as do_not_copy_pipelines

# Creates a stage that copies pipelines from the build context
FROM video-analytics-serving-with-models as copy_pipelines
FROM dlstreamer-pipeline-server-with-models as copy_pipelines
ONBUILD ARG PIPELINES_PATH
ONBUILD ENV PIPELINES_PATH=${PIPELINES_PATH}
ONBUILD COPY ${PIPELINES_PATH} /home/video-analytics-serving/pipelines
ONBUILD COPY ${PIPELINES_PATH} /home/pipeline-server/pipelines

# Stage that is used is controlled via PIPELINES_COMMAND build argument
FROM ${PIPELINES_COMMAND} as video-analytics-serving-with-models-and-pipelines
FROM ${PIPELINES_COMMAND} as dlstreamer-pipeline-server-with-models-and-pipelines
########################################################

########################################################
# Fourth stage creates the final image either with a default command or with a default entrypoint.
# Final stage is controlled by the FINAL_STAGE build argument.

FROM video-analytics-serving-with-models-and-pipelines as video-analytics-serving-library
ONBUILD RUN rm -rf /home/video-analytics-serving/vaserving/__main__.py
ONBUILD RUN rm -rf /home/video-analytics-serving/vaserving/rest_api
FROM dlstreamer-pipeline-server-with-models-and-pipelines as dlstreamer-pipeline-server-library
ONBUILD RUN rm -rf /home/pipeline-server/vaserving/__main__.py
ONBUILD RUN rm -rf /home/pipeline-server/vaserving/rest_api

FROM video-analytics-serving-with-models-and-pipelines as video-analytics-serving-service
FROM dlstreamer-pipeline-server-with-models-and-pipelines as dlstreamer-pipeline-server-service

# Dependencies installed via pip
ONBUILD COPY ./requirements.service.txt /
Expand All @@ -141,9 +141,9 @@ ONBUILD ENTRYPOINT ["python3", "-m", "vaserving"]

FROM ${FINAL_STAGE} as deploy

ARG USER=vaserving
ARG USER=pipeline-server

ENV PYTHONPATH=$PYTHONPATH:/home/video-analytics-serving
ENV PYTHONPATH=$PYTHONPATH:/home/pipeline-server

# Prepare XDG_RUNTIME_DIR
ENV XDG_RUNTIME_DIR=/home/.xdg_runtime_dir
Expand Down
26 changes: 13 additions & 13 deletions docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ OPEN_MODEL_ZOO_TOOLS_IMAGE=${OPEN_MODEL_ZOO_TOOLS_IMAGE:-"openvino/ubuntu20_data
OPEN_MODEL_ZOO_VERSION=${OPEN_MODEL_ZOO_VERSION:-"2021.4.2"}
FORCE_MODEL_DOWNLOAD=

DEFAULT_GSTREAMER_BASE_BUILD_TAG="video-analytics-serving-gstreamer-base"
DEFAULT_GSTREAMER_BASE_BUILD_TAG="dlstreamer-pipeline-server-gstreamer-base"
DEFAULT_GSTREAMER_BASE_BUILD_ARGS="--build-arg ENABLE_PAHO_INSTALLATION=true --build-arg ENABLE_RDKAFKA_INSTALLATION=true"

DEFAULT_FFMPEG_BASE_BUILD_TAG="video-analytics-serving-ffmpeg-base"
DEFAULT_FFMPEG_BASE_BUILD_TAG="dlstreamer-pipeline-server-ffmpeg-base"
DEFAULT_FFMPEG_BASE_BUILD_ARGS=""

function launch { echo $@
Expand Down Expand Up @@ -250,7 +250,7 @@ get_options() {
if [ -f "$MODELS" ]; then
if [[ ! " ${SUPPORTED_IMAGES[@]} " =~ " ${BASE_IMAGE} " ]]; then
if [ -z "$OPEN_MODEL_ZOO_VERSION" ]; then
error 'ERROR: Unknown version of Intel(R) distribution of OpenVINO(TM) Toolkit in base image: '"${BASE_IMAGE}"'. Specify corresponding Open Model Zoo version for model download.'
error 'ERROR: Unknown version of Intel(R) Distribution of OpenVINO(TM) Toolkit in base image: '"${BASE_IMAGE}"'. Specify corresponding Open Model Zoo version for model download.'
fi
fi
if [ ! -d "$SOURCE_DIR/models" ]; then
Expand Down Expand Up @@ -311,7 +311,7 @@ get_options() {
fi

if [ -z "$TAG" ]; then
TAG="video-analytics-serving-${FRAMEWORK}"
TAG="dlstreamer-pipeline-server-${FRAMEWORK}"
fi
}

Expand All @@ -328,15 +328,15 @@ show_base_options() {

show_image_options() {
echo ""
echo "Building Video Analytics Serving Image: '${TAG}'"
echo "Building Intel(R) DL Streamer Pipeline Server Image: '${TAG}'"
echo ""
echo " Base: '${BASE_IMAGE}'"
echo " Build Context: '${SOURCE_DIR}'"
echo " Dockerfile: '${DOCKERFILE_DIR}/Dockerfile'"
echo " Build Options: '${BUILD_OPTIONS}'"
echo " Build Arguments: '${BUILD_ARGS}'"
echo " Models: '${MODELS}'"
echo " Docker Image for downloading models: '${OPEN_MODEL_ZOO_TOOLS_IMAGE}:${OPEN_MODEL_ZOO_VERSION}'"
echo " Docker image for downloading models: '${OPEN_MODEL_ZOO_TOOLS_IMAGE}:${OPEN_MODEL_ZOO_VERSION}'"
echo " Pipelines: '${PIPELINES}'"
echo " Framework: '${FRAMEWORK}'"
echo " Target: '${TARGET}'"
Expand All @@ -350,8 +350,8 @@ show_help() {
echo " [--base base image]"
echo " [--framework ffmpeg || gstreamer]"
echo " [--models path to models directory or model list file or NONE]"
echo " [--open-model-zoo-image specify the openvino image to be used for downloading models from Open Model Zoo]"
echo " [--open-model-zoo-version specify the version of openvino image to be used for downloading models from Open Model Zoo]"
echo " [--open-model-zoo-image specify the OpenVINO(TM) image to be used for downloading models from Open Model Zoo]"
echo " [--open-model-zoo-version specify the version of OpenVINO(TM) image to be used for downloading models from Open Model Zoo]"
echo " [--force-model-download force the download of models from Open Model Zoo]"
echo " [--pipelines path to pipelines directory relative to $SOURCE_DIR or NONE]"
echo " [--base-build-context docker context for building base image]"
Expand All @@ -361,7 +361,7 @@ show_help() {
echo " [--build-arg additional build args to pass to docker build]"
echo " [--base-build-arg additional build args to pass to docker build for base image]"
echo " [--tag docker image tag]"
echo " [--create-service create an entrypoint to run video-analytics-serving as a service]"
echo " [--create-service create an entrypoint to run dlstreamer-pipeline-server as a service]"
echo " [--target build a specific target]"
echo " [--dockerfile-dir specify a different dockerfile directory]"
echo " [--environment-file read and set environment variables from a file. Can be supplied multiple times.]"
Expand Down Expand Up @@ -410,9 +410,9 @@ else
fi

if [ "$CREATE_SERVICE" == "TRUE" ]; then
BUILD_ARGS+="--build-arg FINAL_STAGE=video-analytics-serving-service "
BUILD_ARGS+="--build-arg FINAL_STAGE=dlstreamer-pipeline-server-service "
else
BUILD_ARGS+="--build-arg FINAL_STAGE=video-analytics-serving-library "
BUILD_ARGS+="--build-arg FINAL_STAGE=dlstreamer-pipeline-server-library "
fi

cp -f $DOCKERFILE_DIR/Dockerfile $DOCKERFILE_DIR/Dockerfile.env
Expand All @@ -431,9 +431,9 @@ done

if [ ! -z "$ENVIRONMENT_FILE_LIST" ]; then
cat $ENVIRONMENT_FILE_LIST | grep -E '=' | sed -e 's/,\s\+/,/g' | tr '\n' ' ' | tr '\r' ' ' > $DOCKERFILE_DIR/final.env
echo " HOME=/home/video-analytics-serving " >> $DOCKERFILE_DIR/final.env
echo " HOME=/home/pipeline-server " >> $DOCKERFILE_DIR/final.env
echo "ENV " | cat - $DOCKERFILE_DIR/final.env | tr -d '\n' >> $DOCKERFILE_DIR/Dockerfile.env
printf "\nENV PYTHONPATH=\$PYTHONPATH:/home/video-analytics-serving\nENV GST_PLUGIN_PATH=\$GST_PLUGIN_PATH:/usr/lib/x86_64-linux-gnu/gstreamer-1.0/" >> $DOCKERFILE_DIR/Dockerfile.env
printf "\nENV PYTHONPATH=\$PYTHONPATH:/home/pipeline-server\nENV GST_PLUGIN_PATH=\$GST_PLUGIN_PATH:/usr/lib/x86_64-linux-gnu/gstreamer-1.0/" >> $DOCKERFILE_DIR/Dockerfile.env
fi

show_image_options
Expand Down
12 changes: 6 additions & 6 deletions docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ VOLUME_MOUNT=
MODE=SERVICE
PORTS=
DEVICES=
DEFAULT_GSTREAMER_IMAGE="video-analytics-serving-gstreamer"
DEFAULT_FFMPEG_IMAGE="video-analytics-serving-ffmpeg"
DEFAULT_GSTREAMER_IMAGE="dlstreamer-pipeline-server-gstreamer"
DEFAULT_FFMPEG_IMAGE="dlstreamer-pipeline-server-ffmpeg"
ENTRYPOINT=
ENTRYPOINT_ARGS=
PRIVILEGED=
Expand All @@ -33,7 +33,7 @@ ENVIRONMENT=$(env | cut -f1 -d= | grep -E '_(proxy)$' | sed 's/^/-e / ' | tr '\n

show_options() {
echo ""
echo "Running Video Analytics Serving Image: '${IMAGE}'"
echo "Running Intel(R) DL Streamer Pipeline Server Image: '${IMAGE}'"
echo " Models: '${MODELS}'"
echo " Pipelines: '${PIPELINES}'"
echo " Framework: '${FRAMEWORK}'"
Expand Down Expand Up @@ -297,7 +297,7 @@ if [ -z "$NAME" ]; then
fi

if [ "${MODE}" == "DEV" ]; then
VOLUME_MOUNT+="-v $SOURCE_DIR:/home/video-analytics-serving/ "
VOLUME_MOUNT+="-v $SOURCE_DIR:/home/pipeline-server/ "
VOLUME_MOUNT+="-v /tmp:/tmp "
VOLUME_MOUNT+="-v /dev:/dev "
if [ -z "$NETWORK" ]; then
Expand Down Expand Up @@ -332,11 +332,11 @@ if [ ! -z "$ENABLE_RTSP" ]; then
fi

if [ ! -z "$MODELS" ]; then
VOLUME_MOUNT+="-v $MODELS:/home/video-analytics-serving/models "
VOLUME_MOUNT+="-v $MODELS:/home/pipeline-server/models "
fi

if [ ! -z "$PIPELINES" ]; then
VOLUME_MOUNT+="-v $PIPELINES:/home/video-analytics-serving/pipelines "
VOLUME_MOUNT+="-v $PIPELINES:/home/pipeline-server/pipelines "
fi

if [ ! -z "$VOLUME_MOUNT" ]; then
Expand Down
Loading

0 comments on commit 87de4c9

Please sign in to comment.