# Run Multiple AI Pipelines in Vision AI Detection Apps In a typical deployment, multiple cameras deliver video streams that are connected to AI pipelines to improve the detection and recognition accuracy. The DL Streamer Pipeline Server config supports multiple pipelines that you can use to launch pipeline instances. The sample application has been provided with such a config, i.e., `pipeline-server-config.json`. This guide demonstrates using the config to launch multiple AI pipelines. ## Steps The following demonstrates running two AI pipelines. > **Note** This guide assumes that the model and sample video are already available in the application directory under `resources/`. > **Note:** If you are running multiple instances of the applications, ensure to provide `NGINX_HTTPS_PORT` number in the URL for the app instance, i.e., replace `` with `:`. > If you are running a single instance and using an `NGINX_HTTPS_PORT` other than the default 443, replace `` with `:`. 1. Bring up the containers. > **Note:** If you are running multiple instances of the applications, start the services using `./run.sh up` instead. ```sh docker compose up -d ``` 2. Start the selected pipeline with the following Client URL (cURL) command, replacing `` with the system IP and setting the `peer-id` parameter with an appropriate string id (e.g., `pdd`, or `anomaly1`; these are pre-filled in the examples below). This pipeline is configured to run in a loop forever. This REST/cURL request will return a pipeline instance ID, which can be used as an identifier to later query the pipeline status or stop the pipeline instance (the instance-ID will look like this: a6d67224eacc11ec9f360242c0a86003, for example). ::::{tab-set} :::{tab-item} **Pallet Defect Detection** :sync: pallet-detect ```sh curl -k https:///api/pipelines/user_defined_pipelines/pallet_defect_detection_mlops -X POST -H 'Content-Type: application/json' -d '{ "destination": { "frame": { "type": "webrtc", "peer-id": "pdd" } }, "parameters": { "detection-properties": { "model": "/home/pipeline-server/resources/models/pallet-defect-detection/deployment/Detection/model/model.xml", "device": "CPU" } } }' ``` ::: :::{tab-item} **PCB Anomaly Detection** :sync: pcb-detect ```sh curl -k https:///api/pipelines/user_defined_pipelines/pcb_anomaly_detection_mlops -X POST -H 'Content-Type: application/json' -d '{ "destination": { "frame": { "type": "webrtc", "peer-id": "anomaly1" } }, "parameters": { "classification-properties": { "model": "/home/pipeline-server/resources/models/pcb-anomaly-detection/deployment/Anomaly classification/model/model.xml", "device": "CPU" } } }' ``` ::: :::: 3. Start another pipeline with the following Client URL (cURL) command, replacing `` with the system IP and setting the `peer-id` parameter with a different string id than the one in the above step (e.g., `pddstream` and `anomaly2`; these are pre-filled in the examples below). This pipeline is **not** configured to run in a loop forever. This REST/cURL request will also return a pipeline instance ID, which can be used as an identifier to later query the pipeline status or stop the pipeline instance. ::::{tab-set} :::{tab-item} **Pallet Defect Detection** :sync: pallet-detect ```sh curl -k https:///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": "pddstream" } }, "parameters": { "detection-properties": { "model": "/home/pipeline-server/resources/models/pallet-defect-detection/deployment/Detection/model/model.xml", "device": "CPU" } } }' ``` ::: :::{tab-item} **PCB Anomaly Detection** :sync: pcb-detect ```sh curl -k https:///api/pipelines/user_defined_pipelines/pcb_anomaly_detection_mlops -X POST -H 'Content-Type: application/json' -d '{ "destination": { "frame": { "type": "webrtc", "peer-id": "anomaly2" } }, "parameters": { "classification-properties": { "model": "/home/pipeline-server/resources/models/pcb-anomaly-detection/deployment/Anomaly classification/model/model.xml", "device": "CPU" } } }' ``` ::: :::: **Note the instance ID of this pipeline** 4. View the WebRTC streaming on `https:///mediamtx//` and `https:///mediamtx//`. ::::{tab-set} :::{tab-item} **Pallet Defect Detection** :sync: pallet-detect ![Example of WebRTC streaming using mediamtx](../_assets/pdd-webrtc-streaming.png) *WebRTC streaming for Pallet Defect Detection* You can see boxes, shipping labels, and defects being detected. You have successfully run the sample application. ::: :::{tab-item} **PCB Anomaly Detection** :sync: pcb-detect ![Example of WebRTC streaming using mediamtx](../_assets/pcb-webrtc-streaming.png) *WebRTC streaming for PCB Anomaly Detection* ::: :::: > **Note:** You can also observe telemetry data from the Prometheus UI. Refer to the [View Open Telemetry Data document](./view-telemetry-data.md) to learn more. 5. Stop the 2nd pipeline using the instance ID noted in point #3 above, before proceeding with this documentation. ```sh curl -k --location -X DELETE https:///api/pipelines/{instance_id} ```