How to use an AI Model and Video File of your own#
You can bring your own model and run this sample application the same way as how we bring in the Worker Safety Gear Detection model. You can also bring your own video file source. Please see below for details:
Important If you have previously run the setup for the sample app using
setup.sh
, default sample model and video are downloaded underresource/<app_name>
in your repo directory. You can manually add the model and video of your choice and keep it in this structure. For compose based deployment, the entire resources directory is volume mounted and made available to pipeline server. However for helm, you need to manually copy those to the container.
For docker compose based deployment#
The worker safety gear detection model is placed in the repository under
resources/worker-safety-gear-detection/models
. You can also find the input video file source for inference underresources/worker-safety-gear-detection/videos
. /home/pipeline-server/resources/models/worker-safety-gear-detection/deployment/Detection/model/model.xml
resources/
worker-safety-gear-detection/
models/
worker-safety-gear-detection/
deployment/
Detection/
model/
model.bin
model.xml
videos/
Safety_Full_Hat_and_Vest.avi
Note You can organize the directory structure for models for different use cases.
The
resources
folder containing both the model and video file is volume mounted into DL Streamer Pipeline Server indocker-compose.yml
(present in the repository) file as follows.volumes: - ./resources/${SAMPLE_APP}/:/home/pipeline-server/resources/
The value of
${SAMPLE_APP}
is fetched from the.env
file specifying the particular sample app you are running.Since this is a detection model, ensure to use gvadetect in the pipeline. For example: See the
worker_safety_gear_detection
pipeline inpipeline-server-config.json
(present in the repository) where gvadetect is used.The
pipeline-server-config.json
is volume mounted into DL Streamer Pipeline Server indocker-compose.yml
as follows:volumes: - ./apps/${SAMPLE_APP}/configs/pipeline-server-config.json:/home/pipeline-server/config.json
Provide the model path and video file path in the REST/curl command for starting an inferencing workload. Example:
curl http://<HOST_IP>:8080/pipelines/user_defined_pipelines/worker_safety_gear_detection -X POST -H 'Content-Type: application/json' -d '{ "source": { "uri": "file:///home/pipeline-server/resources/videos/Safety_Full_Hat_and_Vest.avi", "type": "uri" }, "destination": { "frame": { "type": "webrtc", "peer-id": "worker_safety" } }, "parameters": { "detection-properties": { "model": "/home/pipeline-server/resources/models/worker-safety-gear-detection/deployment/Detection/model/model.xml", "device": "CPU" } } }'
For helm chart based deployment#
You can bring your own model and run this sample application the same way as how we bring in the worker safety gear detection model as follows:
The worker safety gear detection model is placed in the repository under
resources/worker-safety-gear-detection/models
. You can also find the input video file source for inference underresources/worker-safety-gear-detection/videos
.
resources/
worker-safety-gear-detection/
models/
worker-safety-gear-detection/
deployment/
Detection/
model/
model.bin
model.xml
videos/
Safety_Full_Hat_and_Vest.avi
Note You can organize the directory structure for models for different use cases.
Copy the resources such as video and model from local directory to the to the
dlstreamer-pipeline-server
pod to make them available for application while launching pipelines.NOTE It is assumed that the sample app is already deployed in the cluster
# Below is an example for Worker Safety gear detection. Please adjust the source path of models and videos appropriately for other sample applications. POD_NAME=$(kubectl get pods -n apps -o jsonpath='{.items[*].metadata.name}' | tr ' ' '\n' | grep deployment-dlstreamer-pipeline-server | head -n 1) kubectl cp resources/worker-safety-gear-detection/videos/Safety_Full_Hat_and_Vest.avi $POD_NAME:/home/pipeline-server/resources/videos/ -c dlstreamer-pipeline-server -n apps kubectl cp resources/worker-safety-gear-detection/models/* $POD_NAME:/home/pipeline-server/resources/models/ -c dlstreamer-pipeline-server -n apps
Please update
imagePullPolicy
asimagePullPolicy: IfNotPresent
invalues.yaml
in order to use the above built image.
Since this is a detection model, ensure to use gvadetect in the pipeline. For example: See the
worker_safety_gear_detection
pipeline inpipeline-server-config.json
(present in the repository) where gvadetect is used.The
pipeline-server-config.json
is volume mounted into DL Streamer Pipeline Server inprovision-configmap.yaml
as follows:apiVersion: v1 kind: ConfigMap metadata: namespace: {{ .Values.namespace }} name: dlstreamer-pipeline-server-config-input data: config.json: |- {{ .Files.Get "config.json" | indent 4 }}
Provide the model path and video file path in the REST/curl command for starting an inferencing workload. Example:
curl http://<HOST_IP>:30107/pipelines/user_defined_pipelines/worker_safety_gear_detection -X POST -H 'Content-Type: application/json' -d '{ "source": { "uri": "file:///home/pipeline-server/resources/videos/Safety_Full_Hat_and_Vest.avi", "type": "uri" }, "destination": { "frame": { "type": "webrtc", "peer-id": "worker_safety" } }, "parameters": { "detection-properties": { "model": "/home/pipeline-server/resources/models/worker-safety-gear-detection/deployment/Detection/model/model.xml", "device": "CPU" } } }'