diff --git a/CHANGELOG.md b/CHANGELOG.md index 28953c8ec91a433228d3f11e0b8b31714f1759a4..030ddd22982ebb54489884d3e3de4844fc43e7ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Running SAM masks decoder on frontend () +- The `person-reidentification-retail-0300` and + `faster_rcnn_inception_v2_coco` Nuclio functions were replaced with + `person-reidentification-retail-0277` and + `faster_rcnn_inception_resnet_v2_atrous_coco`, respectively + (). +- OpenVINO-based Nuclio functions now use the OpenVINO 2022.3 runtime + (). ### Deprecated - TDB @@ -24,6 +31,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - The issue azure.core.exceptions.ResourceExistsError: The specified blob already exists () - Image scaling when moving between images with different resolution () - Invalid completed job count reporting () +- OpenVINO-based Nuclio functions can now be deployed to Kubernetes + (). ### Security - TDB diff --git a/helm-chart/nuclio_func_common_files b/helm-chart/nuclio_func_common_files deleted file mode 120000 index 8e401ec14f55fbcf98d2ba1b8b99254acd9eddb7..0000000000000000000000000000000000000000 --- a/helm-chart/nuclio_func_common_files +++ /dev/null @@ -1 +0,0 @@ -../serverless/common/openvino \ No newline at end of file diff --git a/helm-chart/templates/cvat_nuclio/config.yml b/helm-chart/templates/cvat_nuclio/config.yml deleted file mode 100644 index d03575071741055e49cbdb95a78da09f50655930..0000000000000000000000000000000000000000 --- a/helm-chart/templates/cvat_nuclio/config.yml +++ /dev/null @@ -1,19 +0,0 @@ -{{- if .Values.nuclio.enabled }} -apiVersion: v1 -kind: ConfigMap -metadata: - name: cvat-nuclio-openvino-common - namespace: {{ .Release.Namespace }} - labels: - {{- include "cvat.labels" . | nindent 4 }} - app: cvat-app - tier: nuclio -{{- if semverCompare ">=1.21-0" .Capabilities.KubeVersion.GitVersion }} -immutable: true -{{- end }} -binaryData: - python3: |- - {{ .Files.Get "nuclio_func_common_files/python3" | b64enc }} - model_loader.py: - {{ .Files.Get "nuclio_func_common_files/model_loader.py" | b64enc }} -{{- end}} diff --git a/serverless/common/openvino/python3 b/serverless/common/openvino/python3 deleted file mode 100755 index dfd05669c2b2afe799a6b166005bd14076711442..0000000000000000000000000000000000000000 --- a/serverless/common/openvino/python3 +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -args=$@ - -. /opt/intel/openvino/bin/setupvars.sh -PYTHONPATH=/opt/nuclio/common/openvino:$PYTHONPATH -/usr/bin/python3 $args diff --git a/serverless/deploy_cpu.sh b/serverless/deploy_cpu.sh index 4a88158f88c6cbcc7a0d335c8286aedab019586b..8fc1dacc453c835363dca4a9ab489899db2188d6 100755 --- a/serverless/deploy_cpu.sh +++ b/serverless/deploy_cpu.sh @@ -1,22 +1,30 @@ #!/bin/bash # Sample commands to deploy nuclio functions on CPU +set -eu + SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" FUNCTIONS_DIR=${1:-$SCRIPT_DIR} -nuctl create project cvat +export DOCKER_BUILDKIT=1 + +docker build -t cvat.openvino.base "$SCRIPT_DIR/openvino/base" + +nuctl create project cvat --platform local shopt -s globstar for func_config in "$FUNCTIONS_DIR"/**/function.yaml do - func_root=$(dirname "$func_config") - echo Deploying $(dirname "$func_root") function... - nuctl deploy --project-name cvat --path "$func_root" \ - --volume "$SCRIPT_DIR/common:/opt/nuclio/common" \ - --platform local -done + func_root="$(dirname "$func_config")" + func_rel_path="$(realpath --relative-to="$SCRIPT_DIR" "$(dirname "$func_root")")" -nuctl get function + if [ -f "$func_root/Dockerfile" ]; then + docker build -t "cvat.${func_rel_path//\//.}.base" "$func_root" + fi + echo "Deploying $func_rel_path function..." + nuctl deploy --project-name cvat --path "$func_root" --platform local +done +nuctl get function --platform local diff --git a/serverless/deploy_gpu.sh b/serverless/deploy_gpu.sh index ed323ae75f8269fad5a3fe0546d37db1ce5145be..c813a8232ad4d17f07443eeed6abfd6fadb0de0a 100755 --- a/serverless/deploy_gpu.sh +++ b/serverless/deploy_gpu.sh @@ -1,20 +1,23 @@ #!/bin/bash # Sample commands to deploy nuclio functions on GPU +set -eu + SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" FUNCTIONS_DIR=${1:-$SCRIPT_DIR} -nuctl create project cvat +nuctl create project cvat --platform local shopt -s globstar for func_config in "$FUNCTIONS_DIR"/**/function-gpu.yaml do - func_root=$(dirname "$func_config") - echo "Deploying $(dirname "$func_root") function..." + func_root="$(dirname "$func_config")" + func_rel_path="$(realpath --relative-to="$SCRIPT_DIR" "$(dirname "$func_root")")" + + echo "Deploying $func_rel_path function..." nuctl deploy --project-name cvat --path "$func_root" \ - --volume "$SCRIPT_DIR/common:/opt/nuclio/common" \ --file "$func_config" --platform local done -nuctl get function +nuctl get function --platform local diff --git a/serverless/openvino/base/Dockerfile b/serverless/openvino/base/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3893f812880839d8561d1551d3518ad5417b860f --- /dev/null +++ b/serverless/openvino/base/Dockerfile @@ -0,0 +1,15 @@ +FROM openvino/ubuntu20_runtime:2022.3.0 + +USER root + +RUN apt-get update \ + && apt-get -y --no-install-recommends install python-is-python3 \ + && rm -rf /var/lib/apt/lists/* + +RUN pip install --no-cache-dir opencv-python-headless pillow pyyaml + +COPY model_loader.py shared.py /opt/nuclio/common/openvino/ + +ENV PYTHONPATH=/opt/nuclio/common/openvino:$PYTHONPATH + +USER openvino diff --git a/serverless/common/openvino/model_loader.py b/serverless/openvino/base/model_loader.py similarity index 82% rename from serverless/common/openvino/model_loader.py rename to serverless/openvino/base/model_loader.py index ffaf2975fe4ceced8d9022ab9fbd33d0114123a5..fb369a645a1d40b575eedfb426038d6d594b3454 100644 --- a/serverless/common/openvino/model_loader.py +++ b/serverless/openvino/base/model_loader.py @@ -14,24 +14,22 @@ class ModelLoader: # Initialize input blobs self._input_info_name = None - for blob_name in network.inputs: - if len(network.inputs[blob_name].shape) == 4: + for blob_name in network.input_info: + if len(network.input_info[blob_name].tensor_desc.dims) == 4: self._input_blob_name = blob_name - elif len(network.inputs[blob_name].shape) == 2: + self._input_layout = network.input_info[blob_name].tensor_desc.dims + elif len(network.input_info[blob_name].tensor_desc.dims) == 2: self._input_info_name = blob_name else: raise RuntimeError( "Unsupported {}D input layer '{}'. Only 2D and 4D input layers are supported" - .format(len(network.inputs[blob_name].shape), blob_name)) + .format(len(network.input_info[blob_name].tensor_desc.dims), blob_name)) # Initialize output blob self._output_blob_name = next(iter(network.outputs)) # Load network self._net = ie_core.load_network(network, "CPU", num_requests=2) - input_type = network.inputs[self._input_blob_name] - self._input_layout = input_type if isinstance(input_type, list) else input_type.shape - def _prepare_inputs(self, image, preprocessing): image = np.array(image) @@ -67,5 +65,5 @@ class ModelLoader: return self._input_layout[2:] @property - def layers(self): - return self._network.layers + def network(self): + return self._network diff --git a/serverless/common/openvino/shared.py b/serverless/openvino/base/shared.py similarity index 100% rename from serverless/common/openvino/shared.py rename to serverless/openvino/base/shared.py diff --git a/serverless/openvino/dextr/nuclio/Dockerfile b/serverless/openvino/dextr/nuclio/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..589e231e099b0dde87037442025fdb1c8a229b2a --- /dev/null +++ b/serverless/openvino/dextr/nuclio/Dockerfile @@ -0,0 +1,32 @@ +FROM openvino/ubuntu20_dev:2022.3.0 AS build + +USER root + +RUN apt-get update \ + && apt-get -y --no-install-recommends install patch \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /root + +ARG DEXTR_COMMIT=352ccc76067156ebcf7267b07e0a5e43d32e83d5 + +# TODO: use `ADD --checksum` when that feature becomes stable +ADD https://data.vision.ee.ethz.ch/csergi/share/DEXTR/dextr_pascal-sbd.pth ./ + +ADD https://github.com/scaelles/DEXTR-PyTorch/archive/$DEXTR_COMMIT.zip dextr.zip + +RUN python3 -m zipfile -e dextr.zip . + +WORKDIR /root/DEXTR-PyTorch-$DEXTR_COMMIT + +ADD export.py adaptive-pool.patch . + +RUN patch -p1 -i adaptive-pool.patch + +RUN python3 export.py /root/dextr_pascal-sbd.pth /root/dextr.onnx + +RUN mo --input_model=/root/dextr.onnx --model_name=dextr --output_dir=/root + +FROM cvat.openvino.base + +COPY --from=build --chown=root:root /root/dextr.xml /root/dextr.bin /opt/nuclio/ diff --git a/serverless/openvino/dextr/nuclio/adaptive-pool.patch b/serverless/openvino/dextr/nuclio/adaptive-pool.patch new file mode 100644 index 0000000000000000000000000000000000000000..94ef2e7e6ce6f705d8ee957d9fe1fc74625e9b4a --- /dev/null +++ b/serverless/openvino/dextr/nuclio/adaptive-pool.patch @@ -0,0 +1,27 @@ +This is a hack to work around the the lack of support for AdaptiveAvgPool2d +in PyTorch's ONNX exporter (). + +It might become unnecessary in the future, since OpenVINO 2023 is to add support +for AdaptiveAvgPool2d exported with operator_export_type=ONNX_ATEN_FALLBACK +(). + +diff --git a/networks/deeplab_resnet.py b/networks/deeplab_resnet.py +index ecfa084..e8ff297 100644 +--- a/networks/deeplab_resnet.py ++++ b/networks/deeplab_resnet.py +@@ -99,7 +99,14 @@ class PSPModule(nn.Module): + self.final = nn.Conv2d(out_features, n_classes, kernel_size=1) + + def _make_stage_1(self, in_features, size): +- prior = nn.AdaptiveAvgPool2d(output_size=(size, size)) ++ kernel_size, stride = { ++ 1: (64, 64), ++ 2: (32, 32), ++ 3: (22, 21), ++ 6: (11, 9), ++ }[size] ++ ++ prior = nn.AvgPool2d(kernel_size=kernel_size, stride=stride) + conv = nn.Conv2d(in_features, in_features//4, kernel_size=1, bias=False) + bn = nn.BatchNorm2d(in_features//4, affine=affine_par) + relu = nn.ReLU(inplace=True) diff --git a/serverless/openvino/dextr/nuclio/export.py b/serverless/openvino/dextr/nuclio/export.py new file mode 100644 index 0000000000000000000000000000000000000000..e244db08558fd71e705c9678aa9bb4fbf1b46d6d --- /dev/null +++ b/serverless/openvino/dextr/nuclio/export.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 + +import sys + +import torch +import torch.nn +import torch.onnx + +import networks.deeplab_resnet as resnet + +net = resnet.resnet101(1, nInputChannels=4, classifier='psp') + +state_dict_checkpoint = torch.load(sys.argv[1], map_location=torch.device('cpu')) + +net.load_state_dict(state_dict_checkpoint) + +full_net = torch.nn.Sequential( + net, + torch.nn.Upsample((512, 512), mode='bilinear', align_corners=True), + torch.nn.Sigmoid(), +) +full_net.eval() + +input_tensor = torch.randn((1, 4, 512, 512)) + +torch.onnx.export(full_net, input_tensor, sys.argv[2]) diff --git a/serverless/openvino/dextr/nuclio/function.yaml b/serverless/openvino/dextr/nuclio/function.yaml index 0adeb064e344dcca42a18bcd43f2700420ae5ab8..3a1df59ad310c5f7477e8627102adb894b9c6c17 100644 --- a/serverless/openvino/dextr/nuclio/function.yaml +++ b/serverless/openvino/dextr/nuclio/function.yaml @@ -13,43 +13,13 @@ metadata: spec: description: Deep Extreme Cut - runtime: 'python:3.6' + runtime: 'python:3.8' handler: main:handler eventTimeout: 30s - env: - - name: NUCLIO_PYTHON_EXE_PATH - value: /opt/nuclio/common/openvino/python3 - - volumes: - - volume: - name: openvino-common - configMap: - name: "cvat-nuclio-openvino-common" - defaultMode: 0750 - volumeMount: - name: openvino-common - mountPath: /opt/nuclio/common/openvino build: - image: cvat/openvino.dextr - baseImage: openvino/ubuntu18_runtime:2020.2 - - directives: - preCopy: - - kind: USER - value: root - - kind: WORKDIR - value: /opt/nuclio - - kind: RUN - value: ln -s /usr/bin/pip3 /usr/bin/pip - - postCopy: - - kind: RUN - value: curl -O https://download.01.org/openvinotoolkit/models_contrib/cvat/dextr_model_v1.zip - - kind: RUN - value: unzip dextr_model_v1.zip - - kind: RUN - value: pip3 install -U pip && pip3 install wheel Pillow + image: cvat.openvino.dextr + baseImage: cvat.openvino.dextr.base triggers: myHttpTrigger: diff --git a/serverless/openvino/omz/intel/face-detection-0205/nuclio/Dockerfile b/serverless/openvino/omz/intel/face-detection-0205/nuclio/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b721e21ddfd6d94928acd035fb33eeab3ba05781 --- /dev/null +++ b/serverless/openvino/omz/intel/face-detection-0205/nuclio/Dockerfile @@ -0,0 +1,12 @@ +FROM openvino/ubuntu20_dev:2022.3.0 AS build + +USER root + +RUN omz_downloader \ + --name face-detection-0205,emotions-recognition-retail-0003,age-gender-recognition-retail-0013 \ + --precisions FP32 \ + -o /opt/nuclio/open_model_zoo + +FROM cvat.openvino.base + +COPY --from=build --chown=root:root /opt/nuclio/open_model_zoo /opt/nuclio/open_model_zoo diff --git a/serverless/openvino/omz/intel/face-detection-0205/nuclio/function.yaml b/serverless/openvino/omz/intel/face-detection-0205/nuclio/function.yaml index 79d5883a79f9e5392c216bdb3988313875cb6b1c..09db755ea2616611d96c06144f9abc715123498b 100644 --- a/serverless/openvino/omz/intel/face-detection-0205/nuclio/function.yaml +++ b/serverless/openvino/omz/intel/face-detection-0205/nuclio/function.yaml @@ -1,5 +1,5 @@ metadata: - name: openvino-omz-face-detection-0205 + name: openvino-omz-intel-face-detection-0205 namespace: cvat annotations: name: Attributed face detection @@ -28,47 +28,13 @@ metadata: spec: description: Detection network finding faces and defining age, gender and emotion attributes - runtime: 'python:3.6' + runtime: 'python:3.8' handler: main:handler eventTimeout: 30000s - env: - - name: NUCLIO_PYTHON_EXE_PATH - value: /opt/nuclio/common/openvino/python3 - - volumes: - - volume: - name: openvino-common - configMap: - name: "cvat-nuclio-openvino-common" - defaultMode: 0750 - volumeMount: - name: openvino-common - mountPath: /opt/nuclio/common/openvino build: image: cvat.openvino.omz.intel.face-detection-0205 - baseImage: openvino/ubuntu18_dev:2021.1 - - directives: - preCopy: - - kind: USER - value: root - - kind: WORKDIR - value: /opt/nuclio - - kind: RUN - value: ln -s /usr/bin/pip3 /usr/bin/pip - - kind: RUN - value: /opt/intel/openvino/deployment_tools/open_model_zoo/tools/downloader/downloader.py --name face-detection-0205 -o /opt/nuclio/open_model_zoo - - kind: RUN - value: /opt/intel/openvino/deployment_tools/open_model_zoo/tools/downloader/downloader.py --name emotions-recognition-retail-0003 -o /opt/nuclio/open_model_zoo - - kind: RUN - value: /opt/intel/openvino/deployment_tools/open_model_zoo/tools/downloader/downloader.py --name age-gender-recognition-retail-0013 -o /opt/nuclio/open_model_zoo - - postCopy: - - kind: RUN - value: apt update && DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends -y python3-skimage - - kind: RUN - value: pip3 install "numpy<1.16.0" # workaround for skimage + baseImage: cvat.openvino.omz.intel.face-detection-0205.base triggers: myHttpTrigger: diff --git a/serverless/openvino/omz/intel/person-reidentification-retail-0277/nuclio/Dockerfile b/serverless/openvino/omz/intel/person-reidentification-retail-0277/nuclio/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b878c46af9e51f43c94f487877fcc8be90f1aaa8 --- /dev/null +++ b/serverless/openvino/omz/intel/person-reidentification-retail-0277/nuclio/Dockerfile @@ -0,0 +1,18 @@ +FROM openvino/ubuntu20_dev:2022.3.0 AS build + +USER root + +RUN omz_downloader \ + --name person-reidentification-retail-0277 \ + --precisions FP32 \ + -o /opt/nuclio/open_model_zoo + +FROM cvat.openvino.base + +USER root + +RUN pip install --no-cache-dir scipy + +COPY --from=build /opt/nuclio/open_model_zoo /opt/nuclio/open_model_zoo + +USER openvino diff --git a/serverless/openvino/omz/intel/person-reidentification-retail-0277/nuclio/function.yaml b/serverless/openvino/omz/intel/person-reidentification-retail-0277/nuclio/function.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f3dbfa00300ae0fbf9aba1b23f297380a5ce290b --- /dev/null +++ b/serverless/openvino/omz/intel/person-reidentification-retail-0277/nuclio/function.yaml @@ -0,0 +1,33 @@ +metadata: + name: openvino-omz-intel-person-reidentification-retail-0277 + namespace: cvat + annotations: + name: Person reidentification + type: reid + framework: openvino + spec: + +spec: + description: Person reidentification model for a general scenario + runtime: 'python:3.8' + handler: main:handler + eventTimeout: 30s + + build: + image: cvat.openvino.omz.intel.person-reidentification-retail-0277 + baseImage: cvat.openvino.omz.intel.person-reidentification-retail-0277.base + + triggers: + myHttpTrigger: + maxWorkers: 2 + kind: 'http' + workerAvailabilityTimeoutMilliseconds: 10000 + attributes: + maxRequestBodySize: 33554432 # 32MB + + platform: + attributes: + restartPolicy: + name: always + maximumRetryCount: 3 + mountMode: volume diff --git a/serverless/openvino/omz/intel/person-reidentification-retail-300/nuclio/main.py b/serverless/openvino/omz/intel/person-reidentification-retail-0277/nuclio/main.py similarity index 93% rename from serverless/openvino/omz/intel/person-reidentification-retail-300/nuclio/main.py rename to serverless/openvino/omz/intel/person-reidentification-retail-0277/nuclio/main.py index ca159e6399116f94b416de9c0f08b364f7161758..3ed43e06a684e833391695e3e244bd4bcca81df7 100644 --- a/serverless/openvino/omz/intel/person-reidentification-retail-300/nuclio/main.py +++ b/serverless/openvino/omz/intel/person-reidentification-retail-0277/nuclio/main.py @@ -13,7 +13,7 @@ def init_context(context): context.logger.info("Init context...100%") def handler(context, event): - context.logger.info("Run person-reidentification-retail-0300 model") + context.logger.info("Run person-reidentification-retail-0277 model") data = event.body buf0 = io.BytesIO(base64.b64decode(data["image0"])) buf1 = io.BytesIO(base64.b64decode(data["image1"])) diff --git a/serverless/openvino/omz/intel/person-reidentification-retail-300/nuclio/model_handler.py b/serverless/openvino/omz/intel/person-reidentification-retail-0277/nuclio/model_handler.py similarity index 97% rename from serverless/openvino/omz/intel/person-reidentification-retail-300/nuclio/model_handler.py rename to serverless/openvino/omz/intel/person-reidentification-retail-0277/nuclio/model_handler.py index ca0be2704e312a735d9aefe78bd79d6bca5e9180..fff370601b018ba0e2bba1fe3a4544d8b6935a77 100644 --- a/serverless/openvino/omz/intel/person-reidentification-retail-300/nuclio/model_handler.py +++ b/serverless/openvino/omz/intel/person-reidentification-retail-0277/nuclio/model_handler.py @@ -13,9 +13,9 @@ from model_loader import ModelLoader class ModelHandler: def __init__(self): base_dir = os.path.abspath(os.environ.get("MODEL_PATH", - "/opt/nuclio/open_model_zoo/intel/person-reidentification-retail-0300/FP32")) - model_xml = os.path.join(base_dir, "person-reidentification-retail-0300.xml") - model_bin = os.path.join(base_dir, "person-reidentification-retail-0300.bin") + "/opt/nuclio/open_model_zoo/intel/person-reidentification-retail-0277/FP32")) + model_xml = os.path.join(base_dir, "person-reidentification-retail-0277.xml") + model_bin = os.path.join(base_dir, "person-reidentification-retail-0277.bin") self.model = ModelLoader(model_xml, model_bin) diff --git a/serverless/openvino/omz/intel/person-reidentification-retail-300/nuclio/function.yaml b/serverless/openvino/omz/intel/person-reidentification-retail-300/nuclio/function.yaml deleted file mode 100644 index 672a695c25f711720b114d74f212ea6524582a51..0000000000000000000000000000000000000000 --- a/serverless/openvino/omz/intel/person-reidentification-retail-300/nuclio/function.yaml +++ /dev/null @@ -1,59 +0,0 @@ -metadata: - name: openvino-omz-intel-person-reidentification-retail-0300 - namespace: cvat - annotations: - name: Person reidentification - type: reid - framework: openvino - spec: - -spec: - description: Person reidentification model for a general scenario - runtime: 'python:3.6' - handler: main:handler - eventTimeout: 30s - env: - - name: NUCLIO_PYTHON_EXE_PATH - value: /opt/nuclio/common/openvino/python3 - - volumes: - - volume: - name: openvino-common - configMap: - name: "cvat-nuclio-openvino-common" - defaultMode: 0750 - volumeMount: - name: openvino-common - mountPath: /opt/nuclio/common/openvino - - build: - image: cvat.openvino.omz.intel.person-reidentification-retail-0300 - baseImage: openvino/ubuntu18_dev:2020.2 - - directives: - preCopy: - - kind: USER - value: root - - kind: WORKDIR - value: /opt/nuclio - - kind: RUN - value: ln -s /usr/bin/pip3 /usr/bin/pip - - kind: RUN - value: /opt/intel/openvino/deployment_tools/open_model_zoo/tools/downloader/downloader.py --name person-reidentification-retail-0300 -o /opt/nuclio/open_model_zoo - - kind: RUN - value: /opt/intel/openvino/deployment_tools/open_model_zoo/tools/downloader/converter.py --name person-reidentification-retail-0300 --precisions FP32 -d /opt/nuclio/open_model_zoo -o /opt/nuclio/open_model_zoo - - triggers: - myHttpTrigger: - maxWorkers: 2 - kind: 'http' - workerAvailabilityTimeoutMilliseconds: 10000 - attributes: - maxRequestBodySize: 33554432 # 32MB - - platform: - attributes: - restartPolicy: - name: always - maximumRetryCount: 3 - mountMode: volume diff --git a/serverless/openvino/omz/intel/semantic-segmentation-adas-0001/nuclio/Dockerfile b/serverless/openvino/omz/intel/semantic-segmentation-adas-0001/nuclio/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6ca2bb6c045877f00c5e2282d512877153732def --- /dev/null +++ b/serverless/openvino/omz/intel/semantic-segmentation-adas-0001/nuclio/Dockerfile @@ -0,0 +1,12 @@ +FROM openvino/ubuntu20_dev:2022.3.0 AS build + +USER root + +RUN omz_downloader \ + --name semantic-segmentation-adas-0001 \ + --precisions FP32 \ + -o /opt/nuclio/open_model_zoo + +FROM cvat.openvino.base + +COPY --from=build --chown=root:root /opt/nuclio/open_model_zoo /opt/nuclio/open_model_zoo diff --git a/serverless/openvino/omz/intel/semantic-segmentation-adas-0001/nuclio/function.yaml b/serverless/openvino/omz/intel/semantic-segmentation-adas-0001/nuclio/function.yaml index 375569044dbffa0a39ee85d812b231a21505a7e7..46b07a6998929bcdcc449a6f4322414eadfb689c 100644 --- a/serverless/openvino/omz/intel/semantic-segmentation-adas-0001/nuclio/function.yaml +++ b/serverless/openvino/omz/intel/semantic-segmentation-adas-0001/nuclio/function.yaml @@ -1,5 +1,5 @@ metadata: - name: openvino-omz-semantic-segmentation-adas-0001 + name: openvino-omz-intel-semantic-segmentation-adas-0001 namespace: cvat annotations: name: Semantic segmentation for ADAS @@ -32,43 +32,13 @@ metadata: spec: description: Segmentation network to classify each pixel into typical 20 classes for ADAS - runtime: 'python:3.6' + runtime: 'python:3.8' handler: main:handler eventTimeout: 30s - env: - - name: NUCLIO_PYTHON_EXE_PATH - value: /opt/nuclio/common/openvino/python3 - - volumes: - - volume: - name: openvino-common - configMap: - name: "cvat-nuclio-openvino-common" - defaultMode: 0750 - volumeMount: - name: openvino-common - mountPath: /opt/nuclio/common/openvino build: image: cvat.openvino.omz.intel.semantic-segmentation-adas-0001 - baseImage: openvino/ubuntu18_dev:2020.2 - - directives: - preCopy: - - kind: USER - value: root - - kind: WORKDIR - value: /opt/nuclio - - kind: RUN - value: ln -s /usr/bin/pip3 /usr/bin/pip - - kind: RUN - value: /opt/intel/openvino/deployment_tools/open_model_zoo/tools/downloader/downloader.py --name semantic-segmentation-adas-0001 -o /opt/nuclio/open_model_zoo - - postCopy: - - kind: RUN - value: apt update && DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends -y python3-skimage - - kind: RUN - value: pip3 install "numpy<1.16.0" # workaround for skimage + baseImage: cvat.openvino.omz.intel.semantic-segmentation-adas-0001.base triggers: myHttpTrigger: diff --git a/serverless/openvino/omz/intel/text-detection-0004/nuclio/Dockerfile b/serverless/openvino/omz/intel/text-detection-0004/nuclio/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d00748400d31ba8dff3f3c331f5d4e5cb6fdd471 --- /dev/null +++ b/serverless/openvino/omz/intel/text-detection-0004/nuclio/Dockerfile @@ -0,0 +1,12 @@ +FROM openvino/ubuntu20_dev:2022.3.0 AS build + +USER root + +RUN omz_downloader \ + --name text-detection-0004 \ + --precisions FP32 \ + -o /opt/nuclio/open_model_zoo + +FROM cvat.openvino.base + +COPY --from=build --chown=root:root /opt/nuclio/open_model_zoo /opt/nuclio/open_model_zoo diff --git a/serverless/openvino/omz/intel/text-detection-0004/nuclio/function.yaml b/serverless/openvino/omz/intel/text-detection-0004/nuclio/function.yaml index 8c2f226f786d6bb545bc15b55f5151529e1aae28..65e750b31f5843f1d9cedafb0ba2ad35b69b5ae3 100644 --- a/serverless/openvino/omz/intel/text-detection-0004/nuclio/function.yaml +++ b/serverless/openvino/omz/intel/text-detection-0004/nuclio/function.yaml @@ -12,37 +12,13 @@ metadata: spec: description: Text detector based on PixelLink architecture with MobileNetV2-like as a backbone for indoor/outdoor scenes. - runtime: 'python:3.6' + runtime: 'python:3.8' handler: main:handler eventTimeout: 30s - env: - - name: NUCLIO_PYTHON_EXE_PATH - value: /opt/nuclio/common/openvino/python3 - - volumes: - - volume: - name: openvino-common - configMap: - name: "cvat-nuclio-openvino-common" - defaultMode: 0750 - volumeMount: - name: openvino-common - mountPath: /opt/nuclio/common/openvino build: image: cvat.openvino.omz.intel.text-detection-0004 - baseImage: openvino/ubuntu18_dev:2020.2 - - directives: - preCopy: - - kind: USER - value: root - - kind: WORKDIR - value: /opt/nuclio - - kind: RUN - value: ln -s /usr/bin/pip3 /usr/bin/pip - - kind: RUN - value: /opt/intel/openvino/deployment_tools/open_model_zoo/tools/downloader/downloader.py --name text-detection-0004 -o /opt/nuclio/open_model_zoo + baseImage: cvat.openvino.omz.intel.text-detection-0004.base triggers: myHttpTrigger: diff --git a/serverless/openvino/omz/public/faster_rcnn_inception_resnet_v2_atrous_coco/nuclio/Dockerfile b/serverless/openvino/omz/public/faster_rcnn_inception_resnet_v2_atrous_coco/nuclio/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..088ce755e98aa991ac6b9fe84eae948ed1ab5d79 --- /dev/null +++ b/serverless/openvino/omz/public/faster_rcnn_inception_resnet_v2_atrous_coco/nuclio/Dockerfile @@ -0,0 +1,17 @@ +FROM openvino/ubuntu20_dev:2022.3.0 AS build + +USER root + +RUN omz_downloader \ + --name faster_rcnn_inception_resnet_v2_atrous_coco \ + -o /opt/nuclio/open_model_zoo.orig + +RUN omz_converter \ + --name faster_rcnn_inception_resnet_v2_atrous_coco \ + --precisions FP32 \ + -d /opt/nuclio/open_model_zoo.orig \ + -o /opt/nuclio/open_model_zoo + +FROM cvat.openvino.base + +COPY --from=build --chown=root:root /opt/nuclio/open_model_zoo /opt/nuclio/open_model_zoo diff --git a/serverless/openvino/omz/public/faster_rcnn_inception_v2_coco/nuclio/function.yaml b/serverless/openvino/omz/public/faster_rcnn_inception_resnet_v2_atrous_coco/nuclio/function.yaml similarity index 75% rename from serverless/openvino/omz/public/faster_rcnn_inception_v2_coco/nuclio/function.yaml rename to serverless/openvino/omz/public/faster_rcnn_inception_resnet_v2_atrous_coco/nuclio/function.yaml index 800d1bb8189cdc762c7484576377861da12c2806..b85e4dc54b5cd276b216fe380790f255360b955b 100644 --- a/serverless/openvino/omz/public/faster_rcnn_inception_v2_coco/nuclio/function.yaml +++ b/serverless/openvino/omz/public/faster_rcnn_inception_resnet_v2_atrous_coco/nuclio/function.yaml @@ -1,5 +1,5 @@ metadata: - name: openvino-omz-public-faster-rcnn-inception-v2-coco + name: openvino-omz-public-faster-rcnn-inception-resnet-v2-atrous-coco namespace: cvat annotations: name: Faster RCNN @@ -90,40 +90,14 @@ metadata: ] spec: - description: Faster RCNN inception v2 COCO via Intel OpenVINO toolkit - runtime: 'python:3.6' + description: Faster R-CNN with Inception ResNet v2 Atrous via Intel OpenVINO toolkit + runtime: 'python:3.8' handler: main:handler eventTimeout: 30s - env: - - name: NUCLIO_PYTHON_EXE_PATH - value: /opt/nuclio/common/openvino/python3 - - volumes: - - volume: - name: openvino-common - configMap: - name: "cvat-nuclio-openvino-common" - defaultMode: 0750 - volumeMount: - name: openvino-common - mountPath: /opt/nuclio/common/openvino build: - image: cvat.openvino.omz.public.faster_rcnn_inception_v2_coco - baseImage: openvino/ubuntu18_dev:2020.2 - - directives: - preCopy: - - kind: USER - value: root - - kind: WORKDIR - value: /opt/nuclio - - kind: RUN - value: ln -s /usr/bin/pip3 /usr/bin/pip - - kind: RUN - value: /opt/intel/openvino/deployment_tools/open_model_zoo/tools/downloader/downloader.py --name faster_rcnn_inception_v2_coco -o /opt/nuclio/open_model_zoo - - kind: RUN - value: /opt/intel/openvino/deployment_tools/open_model_zoo/tools/downloader/converter.py --name faster_rcnn_inception_v2_coco --precisions FP32 -d /opt/nuclio/open_model_zoo -o /opt/nuclio/open_model_zoo + image: cvat.openvino.omz.public.faster_rcnn_inception_resnet_v2_atrous_coco + baseImage: cvat.openvino.omz.public.faster_rcnn_inception_resnet_v2_atrous_coco.base triggers: myHttpTrigger: diff --git a/serverless/openvino/omz/public/faster_rcnn_inception_v2_coco/nuclio/main.py b/serverless/openvino/omz/public/faster_rcnn_inception_resnet_v2_atrous_coco/nuclio/main.py similarity index 92% rename from serverless/openvino/omz/public/faster_rcnn_inception_v2_coco/nuclio/main.py rename to serverless/openvino/omz/public/faster_rcnn_inception_resnet_v2_atrous_coco/nuclio/main.py index 26a9b306f70a00252c2f753ff9008ca5fcb2bcb9..6e397c6ddca22c6b75b3a1736e8821b3904d7d3e 100644 --- a/serverless/openvino/omz/public/faster_rcnn_inception_v2_coco/nuclio/main.py +++ b/serverless/openvino/omz/public/faster_rcnn_inception_resnet_v2_atrous_coco/nuclio/main.py @@ -22,7 +22,7 @@ def init_context(context): context.logger.info("Init context...100%") def handler(context, event): - context.logger.info("Run faster_rcnn_inception_v2_coco model") + context.logger.info("Run faster_rcnn_inception_resnet_v2_atrous_coco model") data = event.body buf = io.BytesIO(base64.b64decode(data["image"])) threshold = float(data.get("threshold", 0.5)) diff --git a/serverless/openvino/omz/public/faster_rcnn_inception_v2_coco/nuclio/model_handler.py b/serverless/openvino/omz/public/faster_rcnn_inception_resnet_v2_atrous_coco/nuclio/model_handler.py similarity index 91% rename from serverless/openvino/omz/public/faster_rcnn_inception_v2_coco/nuclio/model_handler.py rename to serverless/openvino/omz/public/faster_rcnn_inception_resnet_v2_atrous_coco/nuclio/model_handler.py index 1f65e63254e4dd40b1f572c4d1a2628fc4280152..da13555ce616321fdfe3cea2989b5bcd79e0f249 100644 --- a/serverless/openvino/omz/public/faster_rcnn_inception_v2_coco/nuclio/model_handler.py +++ b/serverless/openvino/omz/public/faster_rcnn_inception_resnet_v2_atrous_coco/nuclio/model_handler.py @@ -8,9 +8,9 @@ from model_loader import ModelLoader class ModelHandler: def __init__(self, labels): base_dir = os.path.abspath(os.environ.get("MODEL_PATH", - "/opt/nuclio/open_model_zoo/public/faster_rcnn_inception_v2_coco/FP32")) - model_xml = os.path.join(base_dir, "faster_rcnn_inception_v2_coco.xml") - model_bin = os.path.join(base_dir, "faster_rcnn_inception_v2_coco.bin") + "/opt/nuclio/open_model_zoo/public/faster_rcnn_inception_resnet_v2_atrous_coco/FP32")) + model_xml = os.path.join(base_dir, "faster_rcnn_inception_resnet_v2_atrous_coco.xml") + model_bin = os.path.join(base_dir, "faster_rcnn_inception_resnet_v2_atrous_coco.bin") self.model = ModelLoader(model_xml, model_bin) self.labels = labels @@ -36,4 +36,4 @@ class ModelHandler: "type": "rectangle", }) - return results \ No newline at end of file + return results diff --git a/serverless/openvino/omz/public/mask_rcnn_inception_resnet_v2_atrous_coco/nuclio/Dockerfile b/serverless/openvino/omz/public/mask_rcnn_inception_resnet_v2_atrous_coco/nuclio/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..87af18b83302f2897b323823609ba06ce4cea714 --- /dev/null +++ b/serverless/openvino/omz/public/mask_rcnn_inception_resnet_v2_atrous_coco/nuclio/Dockerfile @@ -0,0 +1,23 @@ +FROM openvino/ubuntu20_dev:2022.3.0 AS build + +USER root + +RUN omz_downloader \ + --name mask_rcnn_inception_resnet_v2_atrous_coco \ + -o /opt/nuclio/open_model_zoo.orig + +RUN omz_converter \ + --name mask_rcnn_inception_resnet_v2_atrous_coco \ + --precisions FP32 \ + -d /opt/nuclio/open_model_zoo.orig \ + -o /opt/nuclio/open_model_zoo + +FROM cvat.openvino.base + +USER root + +RUN pip install --no-cache-dir scikit-image + +COPY --from=build /opt/nuclio/open_model_zoo /opt/nuclio/open_model_zoo + +USER openvino diff --git a/serverless/openvino/omz/public/mask_rcnn_inception_resnet_v2_atrous_coco/nuclio/function.yaml b/serverless/openvino/omz/public/mask_rcnn_inception_resnet_v2_atrous_coco/nuclio/function.yaml index 00c7c0ebe0f77a28e9de3311ad3e4fd176e33395..f4e2b35f13ccc3e510cf74d33abea9c46cfa79da 100644 --- a/serverless/openvino/omz/public/mask_rcnn_inception_resnet_v2_atrous_coco/nuclio/function.yaml +++ b/serverless/openvino/omz/public/mask_rcnn_inception_resnet_v2_atrous_coco/nuclio/function.yaml @@ -2,7 +2,7 @@ # have enough memory (more than 4GB). Look here how to do that # https://stackoverflow.com/questions/44417159/docker-process-killed-with-cryptic-killed-message metadata: - name: openvino-mask-rcnn-inception-resnet-v2-atrous-coco + name: openvino-omz-public-mask-rcnn-inception-resnet-v2-atrous-coco namespace: cvat annotations: name: Mask RCNN @@ -94,45 +94,13 @@ metadata: spec: description: Mask RCNN inception resnet v2 COCO via Intel OpenVINO - runtime: 'python:3.6' + runtime: 'python:3.8' handler: main:handler eventTimeout: 60s - env: - - name: NUCLIO_PYTHON_EXE_PATH - value: /opt/nuclio/common/openvino/python3 - - volumes: - - volume: - name: openvino-common - configMap: - name: "cvat-nuclio-openvino-common" - defaultMode: 0750 - volumeMount: - name: openvino-common - mountPath: /opt/nuclio/common/openvino build: image: cvat.openvino.omz.public.mask_rcnn_inception_resnet_v2_atrous_coco - baseImage: openvino/ubuntu18_dev:2020.2 - - directives: - preCopy: - - kind: USER - value: root - - kind: WORKDIR - value: /opt/nuclio - - kind: RUN - value: ln -s /usr/bin/pip3 /usr/bin/pip - - kind: RUN - value: /opt/intel/openvino/deployment_tools/open_model_zoo/tools/downloader/downloader.py --name mask_rcnn_inception_resnet_v2_atrous_coco -o /opt/nuclio/open_model_zoo - - kind: RUN - value: /opt/intel/openvino/deployment_tools/open_model_zoo/tools/downloader/converter.py --name mask_rcnn_inception_resnet_v2_atrous_coco --precisions FP32 -d /opt/nuclio/open_model_zoo -o /opt/nuclio/open_model_zoo - - postCopy: - - kind: RUN - value: apt update && DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends -y python3-skimage - - kind: RUN - value: pip3 install "numpy<1.16.0" # workaround for skimage + baseImage: cvat.openvino.omz.public.mask_rcnn_inception_resnet_v2_atrous_coco.base triggers: myHttpTrigger: diff --git a/serverless/openvino/omz/public/yolo-v3-tf/nuclio/Dockerfile b/serverless/openvino/omz/public/yolo-v3-tf/nuclio/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ce06d7136933ad0e3a7f53483e342a75674664f5 --- /dev/null +++ b/serverless/openvino/omz/public/yolo-v3-tf/nuclio/Dockerfile @@ -0,0 +1,17 @@ +FROM openvino/ubuntu20_dev:2022.3.0 AS build + +USER root + +RUN omz_downloader \ + --name yolo-v3-tf \ + -o /opt/nuclio/open_model_zoo.orig + +RUN omz_converter \ + --name yolo-v3-tf \ + --precisions FP32 \ + -d /opt/nuclio/open_model_zoo.orig \ + -o /opt/nuclio/open_model_zoo + +FROM cvat.openvino.base + +COPY --from=build --chown=root:root /opt/nuclio/open_model_zoo /opt/nuclio/open_model_zoo diff --git a/serverless/openvino/omz/public/yolo-v3-tf/nuclio/function.yaml b/serverless/openvino/omz/public/yolo-v3-tf/nuclio/function.yaml index f6d6d464c3e5677084b9374f6824fcd16db05e78..f1d85b69b04835b6ba5bf76d3c4873bf257a8a42 100644 --- a/serverless/openvino/omz/public/yolo-v3-tf/nuclio/function.yaml +++ b/serverless/openvino/omz/public/yolo-v3-tf/nuclio/function.yaml @@ -91,39 +91,13 @@ metadata: spec: description: YOLO v3 via Intel OpenVINO - runtime: 'python:3.6' + runtime: 'python:3.8' handler: main:handler eventTimeout: 30s - env: - - name: NUCLIO_PYTHON_EXE_PATH - value: /opt/nuclio/common/openvino/python3 - - volumes: - - volume: - name: openvino-common - configMap: - name: "cvat-nuclio-openvino-common" - defaultMode: 0750 - volumeMount: - name: openvino-common - mountPath: /opt/nuclio/common/openvino build: - image: cvat/openvino.omz.public.yolo-v3-tf - baseImage: openvino/ubuntu18_dev:2020.2 - - directives: - preCopy: - - kind: USER - value: root - - kind: WORKDIR - value: /opt/nuclio - - kind: RUN - value: ln -s /usr/bin/pip3 /usr/bin/pip - - kind: RUN - value: /opt/intel/openvino/deployment_tools/open_model_zoo/tools/downloader/downloader.py --name yolo-v3-tf -o /opt/nuclio/open_model_zoo - - kind: RUN - value: /opt/intel/openvino/deployment_tools/open_model_zoo/tools/downloader/converter.py --name yolo-v3-tf --precisions FP32 -d /opt/nuclio/open_model_zoo -o /opt/nuclio/open_model_zoo + image: cvat.openvino.omz.public.yolo-v3-tf + baseImage: cvat.openvino.omz.public.yolo-v3-tf.base triggers: myHttpTrigger: diff --git a/serverless/openvino/omz/public/yolo-v3-tf/nuclio/model_handler.py b/serverless/openvino/omz/public/yolo-v3-tf/nuclio/model_handler.py index 3df65d0e2c90a76cfbfd45b6d837da0fe5c305f1..ef2777966530ad7934a0d6e8f740faf47a2cc357 100644 --- a/serverless/openvino/omz/public/yolo-v3-tf/nuclio/model_handler.py +++ b/serverless/openvino/omz/public/yolo-v3-tf/nuclio/model_handler.py @@ -4,24 +4,26 @@ import os from math import exp + +import ngraph + from model_loader import ModelLoader class YoloParams: # ------------------------------------------- Extracting layer parameters ------------------------------------------ # Magic numbers are copied from yolo samples def __init__(self, param, side): - self.num = 3 if 'num' not in param else int(param['num']) - self.coords = 4 if 'coords' not in param else int(param['coords']) - self.classes = 80 if 'classes' not in param else int(param['classes']) + self.num = param.get('num', 3) + self.coords = param.get('coords', 4) + self.classes = param.get('classes', 80) self.side = side - self.anchors = [10.0, 13.0, 16.0, 30.0, 33.0, 23.0, 30.0, 61.0, 62.0, 45.0, 59.0, 119.0, 116.0, 90.0, 156.0, - 198.0, - 373.0, 326.0] if 'anchors' not in param else [float(a) for a in param['anchors'].split(',')] + self.anchors = param.get('anchors', [ + 10.0, 13.0, 16.0, 30.0, 33.0, 23.0, 30.0, 61.0, 62.0, 45.0, 59.0, + 119.0, 116.0, 90.0, 156.0, 198.0, 373.0, 326.0]) self.isYoloV3 = False - if param.get('mask'): - mask = [int(idx) for idx in param['mask'].split(',')] + if mask := param.get('mask'): self.num = len(mask) maskedAnchors = [] @@ -119,6 +121,19 @@ class ModelHandler: self.model = ModelLoader(model_xml, model_bin) self.labels = labels + ng_func = ngraph.function_from_cnn(self.model.network) + + self.output_info = {} + + for node in ng_func.get_ordered_ops(): + layer_name = node.get_friendly_name() + if layer_name not in self.model.network.outputs: + continue + parent_node = node.inputs()[0].get_source_output().get_node() + shape = list(parent_node.shape) + yolo_params = YoloParams(node._get_attributes(), shape[2]) + self.output_info[layer_name] = (shape, yolo_params) + def infer(self, image, threshold): output_layer = self.model.infer(image) @@ -126,10 +141,10 @@ class ModelHandler: objects = [] origin_im_size = (image.height, image.width) for layer_name, out_blob in output_layer.items(): - out_blob = out_blob.reshape(self.model.layers[self.model.layers[layer_name].parents[0]].shape) - layer_params = YoloParams(self.model.layers[layer_name].params, out_blob.shape[2]) + shape, yolo_params = self.output_info[layer_name] + out_blob = out_blob.reshape(shape) objects += parse_yolo_region(out_blob, self.model.input_size(), - origin_im_size, layer_params, threshold) + origin_im_size, yolo_params, threshold) # Filtering overlapping boxes (non-maximum suppression) IOU_THRESHOLD = 0.4 @@ -157,4 +172,4 @@ class ModelHandler: "type": "rectangle", }) - return results \ No newline at end of file + return results diff --git a/site/content/en/docs/administration/advanced/installation_automatic_annotation.md b/site/content/en/docs/administration/advanced/installation_automatic_annotation.md index b6c4f2558e1b2269cb2ee791bdec9ddd7d174cc7..635c07a757fc2493a078b1f3b2745ae36aad3ca3 100644 --- a/site/content/en/docs/administration/advanced/installation_automatic_annotation.md +++ b/site/content/en/docs/administration/advanced/installation_automatic_annotation.md @@ -45,33 +45,16 @@ description: 'Information about the installation of components needed for semi-a sudo ln -sf $(pwd)/nuctl--linux-amd64 /usr/local/bin/nuctl ``` -- Create `cvat` project inside nuclio dashboard where you will deploy new serverless functions - and deploy a couple of DL models. Commands below should be run only after CVAT has been installed +- Deploy a couple of functions. + This will automatically create a `cvat` Nuclio project to contain the functions. + Commands below should be run only after CVAT has been installed using `docker compose` because it runs nuclio dashboard which manages all serverless functions. ```bash - nuctl create project cvat + ./serverless/deploy_cpu.sh serverless/openvino/dextr + ./serverless/deploy_cpu.sh serverless/openvino/omz/public/yolo-v3-tf ``` - ```bash - nuctl deploy --project-name cvat \ - --path serverless/openvino/dextr/nuclio \ - --volume `pwd`/serverless/common:/opt/nuclio/common \ - --platform local - ``` - - ```bash - nuctl deploy --project-name cvat \ - --path serverless/openvino/omz/public/yolo-v3-tf/nuclio \ - --volume `pwd`/serverless/common:/opt/nuclio/common \ - --platform local - ``` - - **Note:** - - - See [deploy_cpu.sh](https://github.com/cvat-ai/cvat/blob/develop/serverless/deploy_cpu.sh) - for more examples. - #### GPU Support You will need to install [Nvidia Container Toolkit](https://www.tensorflow.org/install/docker#gpu_support). diff --git a/site/content/en/docs/contributing/setup-additional-components.md b/site/content/en/docs/contributing/setup-additional-components.md index e3ee1b7eecb200791f467a317465758393868f28..5aa3f3861b4167543e4334dd1901000313fe3bd5 100644 --- a/site/content/en/docs/contributing/setup-additional-components.md +++ b/site/content/en/docs/contributing/setup-additional-components.md @@ -15,69 +15,14 @@ Follow this [guide](/docs/administration/advanced/installation_automatic_annotat of the Nuclio dashboard. All you need in order to run the dashboard is Docker. See [nuclio documentation](https://github.com/nuclio/nuclio#quick-start-steps) for more details. -- Create `cvat` project inside nuclio dashboard where you will deploy new - serverless functions and deploy a couple of DL models. +- Deploy a couple of functions. + This will automatically create a `cvat` Nuclio project to contain the functions. ```bash -nuctl create project cvat +./serverless/deploy_cpu.sh serverless/openvino/dextr +./serverless/deploy_cpu.sh serverless/openvino/omz/public/yolo-v3-tf ``` -```bash -nuctl deploy --project-name cvat \ - --path serverless/openvino/dextr/nuclio \ - --volume `pwd`/serverless/common:/opt/nuclio/common \ - --platform local -``` - -
- -``` -20.07.17 12:02:23.247 nuctl (I) Deploying function {"name": ""} -20.07.17 12:02:23.248 nuctl (I) Building {"versionInfo": "Label: 1.4.8, Git commit: 238d4539ac7783896d6c414535d0462b5f4cbcf1, OS: darwin, Arch: amd64, Go version: go1.14.3", "name": ""} -20.07.17 12:02:23.447 nuctl (I) Cleaning up before deployment -20.07.17 12:02:23.535 nuctl (I) Function already exists, deleting -20.07.17 12:02:25.877 nuctl (I) Staging files and preparing base images -20.07.17 12:02:25.891 nuctl (I) Building processor image {"imageName": "cvat/openvino.dextr:latest"} -20.07.17 12:02:25.891 nuctl.platform.docker (I) Pulling image {"imageName": "quay.io/nuclio/handler-builder-python-onbuild:1.4.8-amd64"} -20.07.17 12:02:29.270 nuctl.platform.docker (I) Pulling image {"imageName": "quay.io/nuclio/uhttpc:0.0.1-amd64"} -20.07.17 12:02:33.208 nuctl.platform (I) Building docker image {"image": "cvat/openvino.dextr:latest"} -20.07.17 12:02:34.464 nuctl.platform (I) Pushing docker image into registry {"image": "cvat/openvino.dextr:latest", "registry": ""} -20.07.17 12:02:34.464 nuctl.platform (I) Docker image was successfully built and pushed into docker registry {"image": "cvat/openvino.dextr:latest"} -20.07.17 12:02:34.464 nuctl (I) Build complete {"result": {"Image":"cvat/openvino.dextr:latest","UpdatedFunctionConfig":{"metadata":{"name":"openvino.dextr","namespace":"nuclio","labels":{"nuclio.io/project-name":"cvat"},"annotations":{"framework":"openvino","spec":"","type":"interactor"}},"spec":{"description":"Deep Extreme Cut","handler":"main:handler","runtime":"python:3.6","env":[{"name":"NUCLIO_PYTHON_EXE_PATH","value":"/opt/nuclio/python3"}],"resources":{},"image":"cvat/openvino.dextr:latest","targetCPU":75,"triggers":{"myHttpTrigger":{"class":"","kind":"http","name":"","maxWorkers":2,"workerAvailabilityTimeoutMilliseconds":10000,"attributes":{"maxRequestBodySize":33554432}}},"volumes":[{"volume":{"name":"volume-1","hostPath":{"path":"/Users/nmanovic/Workspace/cvat/serverless/openvino/common"}},"volumeMount":{"name":"volume-1","mountPath":"/opt/nuclio/common"}}],"build":{"image":"cvat/openvino.dextr","baseImage":"openvino/ubuntu18_runtime:2020.2","directives":{"postCopy":[{"kind":"RUN","value":"curl -O https://download.01.org/openvinotoolkit/models_contrib/cvat/dextr_model_v1.zip"},{"kind":"RUN","value":"unzip dextr_model_v1.zip"},{"kind":"RUN","value":"pip3 install Pillow"},{"kind":"USER","value":"openvino"}],"preCopy":[{"kind":"USER","value":"root"},{"kind":"WORKDIR","value":"/opt/nuclio"},{"kind":"RUN","value":"ln -s /usr/bin/pip3 /usr/bin/pip"}]},"codeEntryType":"image"},"platform":{},"readinessTimeoutSeconds":60,"eventTimeout":"30s"}}}} -20.07.17 12:02:35.012 nuctl.platform (I) Waiting for function to be ready {"timeout": 60} -20.07.17 12:02:37.448 nuctl (I) Function deploy complete {"httpPort": 55274} -``` - -
- -```bash -nuctl deploy --project-name cvat \ - --path serverless/openvino/omz/public/yolo-v3-tf/nuclio \ - --volume `pwd`/serverless/common:/opt/nuclio/common \ - --platform local -``` - -
- -``` -20.07.17 12:05:23.377 nuctl (I) Deploying function {"name": ""} -20.07.17 12:05:23.378 nuctl (I) Building {"versionInfo": "Label: 1.4.8, Git commit: 238d4539ac7783896d6c414535d0462b5f4cbcf1, OS: darwin, Arch: amd64, Go version: go1.14.3", "name": ""} -20.07.17 12:05:23.590 nuctl (I) Cleaning up before deployment -20.07.17 12:05:23.694 nuctl (I) Function already exists, deleting -20.07.17 12:05:24.271 nuctl (I) Staging files and preparing base images -20.07.17 12:05:24.274 nuctl (I) Building processor image {"imageName": "cvat/openvino.omz.public.yolo-v3-tf:latest"} -20.07.17 12:05:24.274 nuctl.platform.docker (I) Pulling image {"imageName": "quay.io/nuclio/handler-builder-python-onbuild:1.4.8-amd64"} -20.07.17 12:05:27.432 nuctl.platform.docker (I) Pulling image {"imageName": "quay.io/nuclio/uhttpc:0.0.1-amd64"} -20.07.17 12:05:31.462 nuctl.platform (I) Building docker image {"image": "cvat/openvino.omz.public.yolo-v3-tf:latest"} -20.07.17 12:05:32.798 nuctl.platform (I) Pushing docker image into registry {"image": "cvat/openvino.omz.public.yolo-v3-tf:latest", "registry": ""} -20.07.17 12:05:32.798 nuctl.platform (I) Docker image was successfully built and pushed into docker registry {"image": "cvat/openvino.omz.public.yolo-v3-tf:latest"} -20.07.17 12:05:32.798 nuctl (I) Build complete {"result": {"Image":"cvat/openvino.omz.public.yolo-v3-tf:latest","UpdatedFunctionConfig":{"metadata":{"name":"openvino.omz.public.yolo-v3-tf","namespace":"nuclio","labels":{"nuclio.io/project-name":"cvat"},"annotations":{"framework":"openvino","name":"YOLO v3","spec":"[\n { \"id\": 0, \"name\": \"person\" },\n { \"id\": 1, \"name\": \"bicycle\" },\n { \"id\": 2, \"name\": \"car\" },\n { \"id\": 3, \"name\": \"motorbike\" },\n { \"id\": 4, \"name\": \"aeroplane\" },\n { \"id\": 5, \"name\": \"bus\" },\n { \"id\": 6, \"name\": \"train\" },\n { \"id\": 7, \"name\": \"truck\" },\n { \"id\": 8, \"name\": \"boat\" },\n { \"id\": 9, \"name\": \"traffic light\" },\n { \"id\": 10, \"name\": \"fire hydrant\" },\n { \"id\": 11, \"name\": \"stop sign\" },\n { \"id\": 12, \"name\": \"parking meter\" },\n { \"id\": 13, \"name\": \"bench\" },\n { \"id\": 14, \"name\": \"bird\" },\n { \"id\": 15, \"name\": \"cat\" },\n { \"id\": 16, \"name\": \"dog\" },\n { \"id\": 17, \"name\": \"horse\" },\n { \"id\": 18, \"name\": \"sheep\" },\n { \"id\": 19, \"name\": \"cow\" },\n { \"id\": 20, \"name\": \"elephant\" },\n { \"id\": 21, \"name\": \"bear\" },\n { \"id\": 22, \"name\": \"zebra\" },\n { \"id\": 23, \"name\": \"giraffe\" },\n { \"id\": 24, \"name\": \"backpack\" },\n { \"id\": 25, \"name\": \"umbrella\" },\n { \"id\": 26, \"name\": \"handbag\" },\n { \"id\": 27, \"name\": \"tie\" },\n { \"id\": 28, \"name\": \"suitcase\" },\n { \"id\": 29, \"name\": \"frisbee\" },\n { \"id\": 30, \"name\": \"skis\" },\n { \"id\": 31, \"name\": \"snowboard\" },\n { \"id\": 32, \"name\": \"sports ball\" },\n { \"id\": 33, \"name\": \"kite\" },\n { \"id\": 34, \"name\": \"baseball bat\" },\n { \"id\": 35, \"name\": \"baseball glove\" },\n { \"id\": 36, \"name\": \"skateboard\" },\n { \"id\": 37, \"name\": \"surfboard\" },\n { \"id\": 38, \"name\": \"tennis racket\" },\n { \"id\": 39, \"name\": \"bottle\" },\n { \"id\": 40, \"name\": \"wine glass\" },\n { \"id\": 41, \"name\": \"cup\" },\n { \"id\": 42, \"name\": \"fork\" },\n { \"id\": 43, \"name\": \"knife\" },\n { \"id\": 44, \"name\": \"spoon\" },\n { \"id\": 45, \"name\": \"bowl\" },\n { \"id\": 46, \"name\": \"banana\" },\n { \"id\": 47, \"name\": \"apple\" },\n { \"id\": 48, \"name\": \"sandwich\" },\n { \"id\": 49, \"name\": \"orange\" },\n { \"id\": 50, \"name\": \"broccoli\" },\n { \"id\": 51, \"name\": \"carrot\" },\n { \"id\": 52, \"name\": \"hot dog\" },\n { \"id\": 53, \"name\": \"pizza\" },\n { \"id\": 54, \"name\": \"donut\" },\n { \"id\": 55, \"name\": \"cake\" },\n { \"id\": 56, \"name\": \"chair\" },\n { \"id\": 57, \"name\": \"sofa\" },\n { \"id\": 58, \"name\": \"pottedplant\" },\n { \"id\": 59, \"name\": \"bed\" },\n { \"id\": 60, \"name\": \"diningtable\" },\n { \"id\": 61, \"name\": \"toilet\" },\n { \"id\": 62, \"name\": \"tvmonitor\" },\n { \"id\": 63, \"name\": \"laptop\" },\n { \"id\": 64, \"name\": \"mouse\" },\n { \"id\": 65, \"name\": \"remote\" },\n { \"id\": 66, \"name\": \"keyboard\" },\n { \"id\": 67, \"name\": \"cell phone\" },\n { \"id\": 68, \"name\": \"microwave\" },\n { \"id\": 69, \"name\": \"oven\" },\n { \"id\": 70, \"name\": \"toaster\" },\n { \"id\": 71, \"name\": \"sink\" },\n { \"id\": 72, \"name\": \"refrigerator\" },\n { \"id\": 73, \"name\": \"book\" },\n { \"id\": 74, \"name\": \"clock\" },\n { \"id\": 75, \"name\": \"vase\" },\n { \"id\": 76, \"name\": \"scissors\" },\n { \"id\": 77, \"name\": \"teddy bear\" },\n { \"id\": 78, \"name\": \"hair drier\" },\n { \"id\": 79, \"name\": \"toothbrush\" }\n]\n","type":"detector"}},"spec":{"description":"YOLO v3 via Intel OpenVINO","handler":"main:handler","runtime":"python:3.6","env":[{"name":"NUCLIO_PYTHON_EXE_PATH","value":"/opt/nuclio/common/python3"}],"resources":{},"image":"cvat/openvino.omz.public.yolo-v3-tf:latest","targetCPU":75,"triggers":{"myHttpTrigger":{"class":"","kind":"http","name":"","maxWorkers":2,"workerAvailabilityTimeoutMilliseconds":10000,"attributes":{"maxRequestBodySize":33554432}}},"volumes":[{"volume":{"name":"volume-1","hostPath":{"path":"/Users/nmanovic/Workspace/cvat/serverless/openvino/common"}},"volumeMount":{"name":"volume-1","mountPath":"/opt/nuclio/common"}}],"build":{"image":"cvat/openvino.omz.public.yolo-v3-tf","baseImage":"openvino/ubuntu18_dev:2020.2","directives":{"postCopy":[{"kind":"USER","value":"openvino"}],"preCopy":[{"kind":"USER","value":"root"},{"kind":"WORKDIR","value":"/opt/nuclio"},{"kind":"RUN","value":"ln -s /usr/bin/pip3 /usr/bin/pip"},{"kind":"RUN","value":"/opt/intel/openvino/deployment_tools/open_model_zoo/tools/downloader/downloader.py --name yolo-v3-tf -o /opt/nuclio/open_model_zoo"},{"kind":"RUN","value":"/opt/intel/openvino/deployment_tools/open_model_zoo/tools/downloader/converter.py --name yolo-v3-tf --precisions FP32 -d /opt/nuclio/open_model_zoo -o /opt/nuclio/open_model_zoo"}]},"codeEntryType":"image"},"platform":{},"readinessTimeoutSeconds":60,"eventTimeout":"30s"}}}} -20.07.17 12:05:33.285 nuctl.platform (I) Waiting for function to be ready {"timeout": 60} -20.07.17 12:05:35.452 nuctl (I) Function deploy complete {"httpPort": 57308} -``` - -
- - Display a list of running serverless functions using `nuctl` command or see them in nuclio dashboard: @@ -103,23 +48,23 @@ image=$(curl https://upload.wikimedia.org/wikipedia/en/7/7d/Lenna_%28test_image% cat << EOF > /tmp/input.json {"image": "$image"} EOF -cat /tmp/input.json | nuctl invoke openvino.omz.public.yolo-v3-tf -c 'application/json' +cat /tmp/input.json | nuctl invoke openvino-omz-public-yolo-v3-tf -c 'application/json' ```
``` -20.07.17 12:07:44.519 nuctl.platform.invoker (I) Executing function {"method": "POST", "url": "http://:57308", "headers": {"Content-Type":["application/json"],"X-Nuclio-Log-Level":["info"],"X-Nuclio-Target":["openvino.omz.public.yolo-v3-tf"]}} -20.07.17 12:07:45.275 nuctl.platform.invoker (I) Got response {"status": "200 OK"} -20.07.17 12:07:45.275 nuctl (I) >>> Start of function logs -20.07.17 12:07:45.275 ino.omz.public.yolo-v3-tf (I) Run yolo-v3-tf model {"worker_id": "0", "time": 1594976864570.9353} -20.07.17 12:07:45.275 nuctl (I) <<< End of function logs +23.05.11 22:14:17.275 nuctl.platform.invoker (I) Executing function {"method": "POST", "url": "http://0.0.0.0:32771", "bodyLength": 631790, "headers": {"Content-Type":["application/json"],"X-Nuclio-Log-Level":["info"],"X-Nuclio-Target":["openvino-omz-public-yolo-v3-tf"]}} +23.05.11 22:14:17.788 nuctl.platform.invoker (I) Got response {"status": "200 OK"} +23.05.11 22:14:17.789 nuctl (I) >>> Start of function logs +23.05.11 22:14:17.789 ino-omz-public-yolo-v3-tf (I) Run yolo-v3-tf model {"worker_id": "0", "time": 1683828857301.8765} +23.05.11 22:14:17.789 nuctl (I) <<< End of function logs > Response headers: -Date = Fri, 17 Jul 2020 09:07:45 GMT +Server = nuclio +Date = Thu, 11 May 2023 18:14:17 GMT Content-Type = application/json Content-Length = 100 -Server = nuclio > Response body: [