Use Your AI Model and Video#

You can use your own model and run it with the sample applications provided. You can also bring your own video file source. This article will show you how to do it.

Important

If you have previously run the setup for the sample app using setup.sh, the default sample model and video are downloaded under resource/<app_name> in your repo. You can manually add your files next to them.

For compose-based deployment, the entire resources directory is volume mounted and made available to pipeline server.

File Location#

The model and the input video file are placed in the resources/<app name>/ folder, under the model and video directories:

- resources/
  - pallet-defect-detection/
    - models/
        - pallet_defect_detection/
            - deployment/
                - Detection/
                    - model/
                        - model.bin
                        - model.xml
    - videos/
        - warehouse.avi
- resources/
 - pcb-anomaly-detection/
   - models/
     - pcb-anomaly-detection/
       - deployment/
         - Anomaly classification/
           - model/
             - model.bin
             - model.xml
   - videos/
     - anomalib_pcb_test.avi

Note

You can customize the directory structure for different resources and use cases.

Docker compose deployment#

  1. The resources folder containing both the model and video file is a volume mounted into DL Streamer Pipeline Server in docker-compose.yml (included in the repository), like so:

    volumes:
    - ./resources/${SAMPLE_APP}/:/home/pipeline-server/resources/
    

    Note

    The value of ${SAMPLE_APP} is fetched from the .env file specifying the particular sample app you are running.

  2. Make sure to adjust the pipeline to the model you are using. See the pipeline-server-config.json included in the repository.

    • for a detection model, use gvadetect - as used in the pallet_defect_detection pipeline.

    • for a classification model, use gvaclassify - as used in the pcb_anomaly_detection pipeline.

  3. The pipeline-server-config.json is a volume mounted into DL Streamer Pipeline Server in docker-compose.yml (included in the repository), like so:

    volumes:
    - ${APP_DIR}/configs/pipeline-server-config.json:/home/pipeline-server/config.json
    
  4. Provide the model path and video file path in the REST/curl command to start an inference workload. For example:

    Note

    If you are running multiple instances of the application, make sure to provide NGINX_HTTPS_PORT number in the URL for the application instance, i.e., replace <HOST_IP> with <HOST_IP>:<NGINX_HTTPS_PORT>

    If you are running a single instance and using an NGINX_HTTPS_PORT other than the default 443, replace <HOST_IP> with <HOST_IP>:<NGINX_HTTPS_PORT>.

        curl -k https://<HOST_IP>/api/pipelines/user_defined_pipelines/pallet_defect_detection -X POST -H 'Content-Type: application/json' -d '{
            "source": {
                "uri": "file:///home/pipeline-server/resources/videos/warehouse.avi",
                "type": "uri"
            },
            "destination": {
                "frame": {
                    "type": "webrtc",
                    "peer-id": "samplestream",
                    "overlay-properties": {
                        "font-scale": 1.0,
                        "draw-txt-bg": false
                    }
                }
            },
            "parameters": {
                "detection-properties": {
                    "model": "/home/pipeline-server/resources/models/pallet-defect-detection/deployment/Detection/model/model.xml",
                    "device": "CPU"
                }
            }
        }'
    
       curl -k https://<HOST_IP>/api/pipelines/user_defined_pipelines/pcb_anomaly_detection -X POST -H 'Content-Type: application/json' -d '{
           "source": {
               "uri": "file:///home/pipeline-server/resources/videos/anomalib_pcb_test.avi",
               "type": "uri"
           },
           "destination": {
               "frame": {
                   "type": "webrtc",
                   "peer-id": "anomaly",
                   "overlay-properties": {
                       "font-scale": 1.0,
                       "draw-txt-bg": false
                   }
               }
           },
           "parameters": {
               "classification-properties": {
                   "model": "/home/pipeline-server/resources/models/pcb-anomaly-detection/deployment/Anomaly classification/model/model.xml",
                   "device": "CPU"
               }
           }
       }'