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 #40 from intel/v0.4.0-alpha-preview
Browse files Browse the repository at this point in the history
v0.4.0-alpha-preview
  • Loading branch information
tobiasmo1 committed Oct 28, 2020
2 parents e735a17 + 4dfa131 commit 01223b0
Show file tree
Hide file tree
Showing 127 changed files with 6,556 additions and 41,175 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ __pycache__/
*.generated
docker/Dockerfile.env
docker/final.env

models
4 changes: 3 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,9 @@ ignore-on-opaque-inference=yes
# List of class names for which member attributes should not be checked (useful
# for classes with dynamically set attributes). This supports the use of
# qualified names.
ignored-classes=optparse.Values,thread._local,_thread._local
ignored-classes=optparse.Values,thread._local,_thread._local,
extension__pb2.MediaStreamMessage,
MediaStreamMessage

# List of module names for which member attributes should not be checked
# (useful for modules/projects where namespaces are manipulated during runtime
Expand Down
41 changes: 40 additions & 1 deletion Attribution.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ https://packages.debian.org/sid/python3-setuptools
six (MIT) https://pypi.org/project/six/
https://github.com/benjaminp/six/blob/master/LICENSE

Python 3 (Custom) https://packages.debian.org/sid/python3
Python 3 (PSF) https://packages.debian.org/sid/python3
https://docs.python.org/3/license.html

pip3 (MIT) https://packages.debian.org/sid/python3-pip
Expand Down Expand Up @@ -90,3 +90,42 @@ https://gstreamer.freedesktop.org/src/gstreamer-vaapi/

Numpy (BSD 3-clause) https://github.com/numpy/numpy
https://github.com/numpy/numpy/blob/master/LICENSE.txt

jsonschema (MIT) https://github.com/Julian/jsonschema/
https://github.com/Julian/jsonschema/blob/main/COPYING

strict-rfc3339 (GPLv3) https://pypi.org/project/strict-rfc3339/
https://pypi.org/project/strict-rfc3339/

pyyaml (MIT) https://pypi.org/project/strict-rfc3339/
https://pypi.org/project/strict-rfc3339/

protobuf (BSD 3-clause) https://github.com/protocolbuffers/protobuf
https://github.com/protocolbuffers/protobuf/blob/master/LICENSE

pillow (PIL) https://pillow.readthedocs.io/en/latest/handbook/index.html
https://github.com/python-pillow/Pillow/blob/master/LICENSE

gunicorn (MIT) http://docs.gunicorn.org/
https://pypi.org/project/gunicorn/

grpcio (Apache 2.0) https://grpc.io/docs/guides/
https://pypi.org/project/grpcio/

rfc3987 (GPLv3) https://pypi.org/project/rfc3987/
https://pypi.org/project/rfc3987/

Live Video Analytics (MIT) https://azure.microsoft.com/en-us/services/media-services/live-video-analytics/
https://github.com/Azure/live-video-analytics/blob/master/LICENSE

RunIt (three-clause BSD alike license) http://smarden.org/runit
http://smarden.org/runit/faq.html#license

nginx (BSD 2-clause) http://nginx.org/
https://nginx.org/LICENSE

libnginx-mod-nchan (MIT) https://nchan.io/
https://github.com/slact/nchan/blob/master/LICENCE

python-psutil (BSD 3-clause) https://psutil.readthedocs.io/en/latest/
https://github.com/giampaolo/psutil/blob/master/LICENSE
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ Pipeline Instance Id
Start a new shell and execute the following command to issue an HTTP POST request, start a pipeline and analyze a sample [video](https://github.com/intel-iot-devkit/sample-videos/blob/master/preview/head-pose-face-detection-male.gif).

```bash
curl localhost:8080/pipelines/object_detection/1 -X POST -H \
curl localhost:8080/pipelines/emotion_recognition/1 -X POST -H \
'Content-Type: application/json' -d \
'{
"source": {
Expand Down Expand Up @@ -467,9 +467,9 @@ After pretty-printing:
</details>

# Further Reading
| **Documentation** | **Reference Guides** |
| ------------ | ------------------ |
| **-** [Defining Media Analytics Pipelines](docs/defining_pipelines.md) <br/> **-** [Building Video Analytics Serving](docs/building_video_analytics_serving.md) <br/> **-** [Running Video Analytics Serving](docs/running_video_analytics_serving.md) | **-** [Video Analytics Serving Architecture Diagram](docs/images/video_analytics_service_architecture.png) <br/> **-** [Microservice Endpoints](docs/restful_microservice_interfaces.md) <br/> **-** [Build Script Reference](docs/build_script_reference.md) <br/> **-** [Run Script Reference](docs/run_script_reference.md) |
| **Documentation** | **Reference Guides** | **Tutorials** |
| ------------ | ------------------ | ----------- |
| **-** [Defining Media Analytics Pipelines](docs/defining_pipelines.md) <br/> **-** [Building Video Analytics Serving](docs/building_video_analytics_serving.md) <br/> **-** [Running Video Analytics Serving](docs/running_video_analytics_serving.md) <br/> **-** [Customizing Pipeline Requests](docs/customizing_pipeline_requests.md) | **-** [Video Analytics Serving Architecture Diagram](docs/images/video_analytics_service_architecture.png) <br/> **-** [Microservice Endpoints](docs/restful_microservice_interfaces.md) <br/> **-** [Build Script Reference](docs/build_script_reference.md) <br/> **-** [Run Script Reference](docs/run_script_reference.md) | <br/> **-** Object Detecion Tutorials <br/> &nbsp;&nbsp;&nbsp;&nbsp; **-** [Changing Object Detection Models](docs/changing_object_detection_models.md) |

## Related Links

Expand Down
12 changes: 10 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ RUN echo "IMPORTANT: This script will build third party components licensed unde
# Switching to root user to create user and install packages
USER root

# Dependencies for OpenVINO
RUN if [ -f /opt/intel/openvino/install_dependencies/install_openvino_dependencies.sh ]; then \
/opt/intel/openvino/install_dependencies/install_openvino_dependencies.sh ;\
fi

# 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 && \
Expand All @@ -30,9 +35,9 @@ RUN useradd -ms /bin/bash -G video,audio,users ${USER} -d /home/video-analytics-
# Dependencies installed via apt-get
RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
apt-get install -y -q --no-install-recommends \
python3 \
python3-setuptools \
python3-pip \
python3 && \
python3-pip && \
rm -rf /var/lib/apt/lists/*

# Dependencies installed via pip
Expand All @@ -42,6 +47,7 @@ RUN rm -f /requirements.txt

# Video Analytics Serving Python Modules
COPY ./vaserving /home/video-analytics-serving/vaserving
COPY --chown=vaserving ./tools /home/video-analytics-serving/tools

# Media Analytics Framework set via environment variable
ENV FRAMEWORK=${FRAMEWORK}
Expand Down Expand Up @@ -104,4 +110,6 @@ FROM ${FINAL_STAGE} as deploy

ARG USER=vaserving

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

USER ${USER}
71 changes: 60 additions & 11 deletions docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,35 @@
# SPDX-License-Identifier: BSD-3-Clause
#


DOCKERFILE_DIR=$(dirname "$(readlink -f "$0")")
SOURCE_DIR=$(dirname $DOCKERFILE_DIR)

BASE_IMAGE=
BASE_BUILD_CONTEXT=
BASE_BUILD_DOCKERFILE=
BASE_BUILD_TAG=
USER_BASE_BUILD_ARGS=
MODELS=models
MODELS=$SOURCE_DIR/models_list/models.list.yml
MODELS_PATH=models
PIPELINES=
FRAMEWORK=
TAG=
RUN_PREFIX=
CREATE_SERVICE=TRUE
ENVIRONMENT_FILES=()
DOCKER_RUN_ENVIRONMENT=$(env | cut -f1 -d= | grep -E '_(proxy)$' | sed 's/^/-e / ' | tr '\n' ' ')
TARGET="deploy"

DOCKERFILE_DIR=$(dirname "$(readlink -f "$0")")
SOURCE_DIR=$(dirname $DOCKERFILE_DIR)

BUILD_ARGS=$(env | cut -f1 -d= | grep -E '_(proxy|REPO|VER)$' | sed 's/^/--build-arg / ' | tr '\n' ' ')
BASE_BUILD_ARGS=$(env | cut -f1 -d= | grep -E '_(proxy|REPO|VER)$' | sed 's/^/--build-arg / ' | tr '\n' ' ')
BUILD_OPTIONS="--network=host "
BASE_BUILD_OPTIONS="--network=host "

OPEN_MODEL_ZOO_VERSION=
FORCE_MODEL_DOWNLOAD=

DEFAULT_GSTREAMER_BASE_BUILD_CONTEXT="https://github.com/opencv/gst-video-analytics.git#0d95b489f03d30bd94ffa25a2472eaab7b774821"
DEFAULT_GSTREAMER_BASE_BUILD_DOCKERFILE="docker/Dockerfile"
DEFAULT_GSTREAMER_BASE_BUILD_TAG="video-analytics-serving-gstreamer-base"
Expand Down Expand Up @@ -93,12 +101,23 @@ get_options() {
;;
--models)
if [ "$2" ]; then
MODELS=$2
MODELS=$(realpath $2)
shift
else
error 'ERROR: "--models" requires an argument.'
fi
;;
--force-model-download)
FORCE_MODEL_DOWNLOAD="--force"
;;
--open-model-zoo-version)
if [ "$2" ]; then
OPEN_MODEL_ZOO_VERSION=$2
shift
else
error 'ERROR: "--openvino-version" requires an argument.'
fi
;;
--pipelines)
if [ "$2" ]; then
PIPELINES=$2
Expand Down Expand Up @@ -155,7 +174,7 @@ get_options() {
error 'ERROR: "--create-service" requires an argument.'
fi
;;
--environment-file)
--environment-file)
if [ "$2" ]; then
ENVIRONMENT_FILES+=($2)
shift
Expand All @@ -175,10 +194,10 @@ get_options() {
shift
break
;;
-?*)
-?*)
error 'ERROR: Unknown option: ' $1
;;
?*)
?*)
error 'ERROR: Unknown option: ' $1
;;
*)
Expand All @@ -200,6 +219,33 @@ get_options() {
show_help
fi

if [ -f "$MODELS" ]; then
if [ -z "$OPEN_MODEL_ZOO_VERSION" ] && [ $FRAMEWORK = 'ffmpeg' ]; then
OPEN_MODEL_ZOO_VERSION=2020.3
elif [ -z "$OPEN_MODEL_ZOO_VERSION" ]; then
OPEN_MODEL_ZOO_VERSION=2020.4
fi
YML_DIR=$(dirname "${MODELS}")
YML_FILE_NAME=$(basename "${MODELS}")
VOLUME_MOUNT+="-v $SOURCE_DIR:/home/video-analytics-serving -v $YML_DIR:/models_yml"
$RUN_PREFIX docker run -t --rm $DOCKER_RUN_ENVIRONMENT --entrypoint /bin/bash $VOLUME_MOUNT openvino/ubuntu18_data_dev:$OPEN_MODEL_ZOO_VERSION "-i" "-c" "pip3 install jsonschema==3.2.0; python3 /home/video-analytics-serving/tools/model_downloader --model-list /models_yml/$YML_FILE_NAME --output-dir /home/video-analytics-serving/ $FORCE_MODEL_DOWNLOAD"

#TODO: remove below if condition once aclnet model downloads with model downloader
if [ $MODELS = $(realpath $SOURCE_DIR/models_list/models.list.yml) ] && [ -d $SOURCE_DIR/models_list/audio_detection ] ; then
if [ ! -d "$SOURCE_DIR/models/audio_detection" ]; then
mkdir $SOURCE_DIR/models/audio_detection
fi
cp -R $SOURCE_DIR/models_list/audio_detection/. $SOURCE_DIR/models/audio_detection
fi
elif [ -d "$MODELS" ]; then
if [ ! -d "$SOURCE_DIR/models" ]; then
mkdir $SOURCE_DIR/models
fi
cp -R $MODELS/. $SOURCE_DIR/models
else
error 'ERROR: "'$MODELS'" does not exist.'
fi

if [ -z "$PIPELINES" ]; then
PIPELINES=pipelines/$FRAMEWORK
elif [ "${PIPELINES^^}" == "NONE" ]; then
Expand Down Expand Up @@ -261,6 +307,7 @@ show_image_options() {
echo " Build Options: '${BUILD_OPTIONS}'"
echo " Build Arguments: '${BUILD_ARGS}'"
echo " Models: '${MODELS}'"
echo " Openvino Image: 'openvino/ubuntu18_data_dev:${OPEN_MODEL_ZOO_VERSION}'"
echo " Pipelines: '${PIPELINES}'"
echo " Framework: '${FRAMEWORK}'"
echo " Target: '${TARGET}'"
Expand All @@ -273,7 +320,9 @@ show_help() {
echo "usage: build.sh"
echo " [--base base image]"
echo " [--framework ffmpeg || gstreamer]"
echo " [--models path to model directory relative to $SOURCE_DIR or NONE]"
echo " [--models path to models directory or model list file or NONE]"
echo " [--open-model-zoo-version specify the version of openvino 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 " [--build-option additional docker build option that run in the context of docker build. ex. --no-cache]"
echo " [--base-build-option additional docker build option for docker build of base image]"
Expand Down Expand Up @@ -309,15 +358,15 @@ if [ "$BASE" == "BUILD" ]; then
BASE_IMAGE=$BASE_BUILD_TAG
else
#Ensure image is latest from Docker Hub
docker pull $BASE_IMAGE
$RUN_PREFIX docker pull $BASE_IMAGE
fi

# BUILD IMAGE

BUILD_ARGS+=" --build-arg BASE=$BASE_IMAGE "
BUILD_ARGS+=" --build-arg FRAMEWORK=$FRAMEWORK "
if [ -n "$MODELS" ]; then
BUILD_ARGS+="--build-arg MODELS_PATH=$MODELS "
BUILD_ARGS+="--build-arg MODELS_PATH=$MODELS_PATH "
BUILD_ARGS+="--build-arg MODELS_COMMAND=copy_models "
else
BUILD_ARGS+="--build-arg MODELS_COMMAND=do_not_copy_models "
Expand All @@ -340,7 +389,7 @@ cp -f $DOCKERFILE_DIR/Dockerfile $DOCKERFILE_DIR/Dockerfile.env
ENVIRONMENT_FILE_LIST=

if [[ "$BASE_IMAGE" == "openvino/"* ]]; then
$RUN_PREFIX docker run -t --rm --entrypoint /bin/bash -e HOSTNAME=BASE $BASE_IMAGE "-i" "-c" "env" > $DOCKERFILE_DIR/openvino_base_environment.txt
$RUN_PREFIX docker run -t --rm $DOCKER_RUN_ENVIRONMENT --entrypoint /bin/bash -e HOSTNAME=BASE $BASE_IMAGE "-i" "-c" "env" > $DOCKERFILE_DIR/openvino_base_environment.txt
ENVIRONMENT_FILE_LIST+="$DOCKERFILE_DIR/openvino_base_environment.txt "
fi

Expand Down
2 changes: 2 additions & 0 deletions docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ show_options() {
echo " Entrypoint: '${ENTRYPOINT}'"
echo " EntrypointArgs: '${ENTRYPOINT_ARGS}"
echo " User: '${USER}'"
echo " Devices: '${DEVICES}'"
echo ""
}

Expand All @@ -208,6 +209,7 @@ show_help() {
echo " [--network name network to pass to docker run]"
echo " [--user name of user to pass to docker run]"
echo " [--name container name to pass to docker run]"
echo " [--device device to pass to docker run]"
echo " [--dev run in developer mode]"
exit 0
}
Expand Down
6 changes: 3 additions & 3 deletions docs/build_script_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ $ docker/build.sh --help
usage: build.sh
[--base base image]
[--framework ffmpeg || gstreamer]
[--models path to models directory relative to /path/to/video-analytics-serving or NONE]
[--models path to models directory or model list file or NONE]
[--pipelines path to pipelines directory relative to /path/to/Projects/video-analytics-serving or NONE]
[--base-build-context docker context for building base image]
[--base-build-dockerfile docker file used to build base image]
Expand Down Expand Up @@ -38,8 +38,8 @@ This option is used in conjunction with `--base-build-context` to specify the do
## Pipeline Directory (--pipelines)
Relative path to VA Serving pipelines directory from root of video-analytics-serving project. If not specified, [sample pipelines](../pipelines/gstreamer) are included in the image. If set to `NONE` no pipelines are included and the user must ensure pipelines are made available at runtime by volume mounting.

## Model Directory (--models)
Models used by pipelines are expected to be in this directory. It is a relative path from root of video-analytics-serving project. If not specified, models for sample pipelines are included in the image. If set to `NONE` no models are included and the user must ensure models are made available at runtime by volume mounting.
## Model Directory/File List (--models)
This option can be used to specify path to models directory or a model list file. When its a directory, models used by pipelines are expected to be in this directory. When its a file, the models listed in the file are downloaded and converted to IR format if needed by the [model download tool](../tools/model_downloader/README.md) during build time. If nothing is specified, default models listed in the file `models_list/models.list.yml` are downloaded, converted to IR format if needed and included in the image. If set to `NONE` no models are included and the user must ensure models are made available at runtime by volume mounting.

## Build Arg (--build-arg)
Specify a docker build argument when building the VA Serving image.
Expand Down
Loading

0 comments on commit 01223b0

Please sign in to comment.