PCIe Tutorialο
This tutorial walks you through using the PCIe Pipeline to enable high-performance video processing over the PCIe interface. You will learn how to run real-time object detection with YOLOv7 models on the SiMa.ai MLSoC platform.
Note
This section covers building PCIe pipelines with PePPi (Python).
Prerequisites:
Make sure
sima_hos_pcie_pkg
is installed on host for proper communicationFollow PCIe setup instructions to configure PCIe on the host machine
PCIe pipeline is not supported on Modalix Early Access Kit and Modalix DevKit as they donβt have PCIe interface
Purposeο
This application is designed to:
Ingest video input over PCIe from a host or connected capture device
Run YOLOv7-based object detection on each frame
Annotate frames with bounding boxes and labels
Stream the output back to the host or a connected interface (e.g., display, recording module)
This setup targets integration and benchmarking scenarios for PCIe-connected systems.
Configuration Overviewο
The runtime parameters are defined in project.yaml
. The following tables provide a detailed breakdown of the configuration.
Input Configurationο
Parameter |
Description |
Example |
---|---|---|
source.name |
Input type used |
|
source.value |
Identifier string for PCIe input |
|
udp_host |
Not used for PCIe setup |
|
port |
Not used for PCIe setup |
|
pipeline |
Inference pipeline identifier |
|
Model Configurationο
Parameter |
Description |
Value |
---|---|---|
name |
Model identifier |
|
targz |
Path to the YOLOv7 model archive |
|
label_file |
Path to the label file |
|
normalize |
Enable input normalization |
|
channel_mean |
Per-channel mean values |
|
channel_stddev |
Per-channel stddev values |
|
padding_type |
Padding strategy during preprocessing |
|
aspect_ratio |
Preserve input aspect ratio |
|
topk |
Maximum number of detections per frame |
|
detection_threshold |
Confidence threshold for object detection |
|
decode_type |
Postprocessing decode strategy |
|
Project Configurationο
project.yamlο
1source:
2 name: "pcie"
3 value: "PCIE"
4udp_host: ""
5port: ""
6pipeline: "YoloV7-Pcie"
7
8Models:
9 - name: "yolov7"
10 targz: "<targz filepath>"
11 label_file: "labels.txt"
12 normalize: true
13 channel_mean: [0.0, 0.0, 0.0]
14 channel_stddev: [1.0, 1.0, 1.0]
15 padding_type: "CENTER"
16 aspect_ratio: true
17 topk: 10
18 detection_threshold: 0.7
19 decode_type: "yolo"
Script Behaviorο
The main script performs the following:
Loads the configuration from
project.yaml
Initializes the PCIe
VideoReader
andVideoWriter
Sets the expected input and output resolution to 1280Γ720
Loads and configures the YOLOv7 model session on SiMaβs MLSoC
Continuously: - Reads frames from PCIe input - Runs detection inference - Annotates the output frame - Writes the result using PCIe streaming with metadata passthrough
Warning
Make sure the PCIe input source delivers frames at 1280x720 resolution, or update the script accordingly.
Model Detailsο
Property |
Details |
---|---|
Model File |
Tiny YoloV7 optimzied for SiMa devices |
Model Type |
YOLOv7 Tiny |
Normalization |
Yes (mean: |
Detection Threshold |
0.7 |
Output |
Top 10 detections per frame |
Decoding Strategy |
YOLO |
Download Modelο
Host Pipeline Setupο
Run the Host side pipeline with the following command:
GST_DEBUG=3 gst-launch-1.0 -v rtspsrc location=<rtsp_url> ! rtph264depay ! h264parse ! avdec_h264 ! videoconvert ! video/x-raw,format=NV12 ! pciehost queuedepth=30 fps=30 showfps=1 card-number=1 ! queue ! videoparse format=nv12 width=1280 height=720 ! videoconvert ! autovideosink
Build and Deployο
Follow the standard PePPi build and deploy process:
Prerequisite:
1. Make sure the device is connected via SDK for deployment of project to device. Please follow the setup device section and follow the same. sima-user@docker-image-id:/home/docker/sima-cli/workspace/pcie_pipeline/YoloV7_pcie$ mpk device connect -t root@192.168.135.104 βΉ Connecting to root@192.168.135.104... π Connection established to 192.168.135.104 . βΉ Fetching Device Plugin Version data file from : 192.168.135.104 ... β Successfully fetched and updated Plugin Version Data file from : 192.168.135.104.
Create project directory:
sima-user@docker-image-id:/home/docker/sima-cli/workspace$ mkdir pcie_pipeline sima-user@docker-image-id:/home/docker/sima-cli/workspace$ cd pcie_pipeline/
Copy the PCIe pipeline from SDK to workspace project directory:
sima-user@docker-image-id:/home/docker/sima-cli/workspace/pcie_pipeline$ cp -r /usr/local/simaai/app_zoo/Peppi/YoloV7_pcie/ . sima-user@docker-image-id:/home/docker/sima-cli/workspace/pcie_pipeline$ cd YoloV7_pcie/ sima-user@docker-image-id:/home/docker/sima-cli/workspace/pcie_pipeline/YoloV7_pcie$ ls labels.txt main.py project.yaml README.md
Copy downloaded model tar.gz file to project directory:
sima-user@docker-image-id:/home/docker/sima-cli/workspace/pcie_pipeline/YoloV7_pcie$ cp path/to/yolov7-tiny-opt_mpk.tar.gz . sima-user@docker-image-id:/home/docker/sima-cli/workspace/pcie_pipeline/YoloV7_pcie$ ls labels.txt main.py project.yaml README.md yolov7-tiny-opt_mpk.tar.gz
Update Config parameters and Yaml:
source: name: "pcie" value: "PCIE" udp_host: "" port: "" pipeline: "YoloV7-Pcie" Models: - name: "yolov7" targz: "yolov7-tiny-opt_mpk.tar.gz" label_file: labels.txt normalize: true channel_mean: [0.0, 0.0, 0.0] channel_stddev: [1.0, 1.0, 1.0] padding_type: "CENTER" aspect_ratio: true topk: 10 detection_threshold: 0.7 decode_type: "yolo"
Create the pipeline package:
sima-user@docker-image-id:/home/docker/sima-cli/workspace/pcie_pipeline/YoloV7_pcie$ mpk create --peppi -s . -d . --main-file=main.py --yaml-file=project.yaml βΉ Generating requirements.txt file... β Generated requirements.txt. βΉ Dowloading required packages... β Dowloaded required packages. βΉ Building Rpm... β Rpm built successfully. βΉ Creating mpk file... β Mpk file created successfully at /home/docker/sima-cli/workspace/pcie_pipeline/YoloV7_pcie/project.mpk
Deploy the pipeline package:
sima-user@docker-image-id:/home/docker/sima-cli/workspace/pcie_pipeline/YoloV7_pcie$ mpk deploy -f project.mpk βΉ Checking if App YoloV7-Pcie Plugin Version Index File /home/docker/sima-cli/workspace/pcie_pipeline/YoloV7_pcie/YoloV7-Pcie_plugin_version_index.json exists... β App YoloV7-Pcie : File doesn't exist at /home/docker/sima-cli/workspace/pcie_pipeline/YoloV7_pcie/YoloV7-Pcie_plugin_version_index.json. Please check the path/file. β Proceed by Skipping Plugin Version Check? [y/n]: y βΌ User chose to proceed with App YoloV7-Pcie deployment, Skipping Plugin Version Check! Performance could be sub-optimal! π Sending MPK to 192.168.135.104... Transfer Progress for project.mpk: 100.00% π MPK sent successfully! Installing MPK... βββββββββββΊβββββββββββββββββββββββββββββ 25% After Deployment - STATUS --> sima-user@docker-image-id:/home/docker/sima-cli/workspace/pcie_pipeline/YoloV7_pcie$ mpk deploy -f project.mpk βΉ Checking if App YoloV7-Pcie Plugin Version Index File /home/docker/sima-cli/workspace/pcie_pipeline/YoloV7_pcie/YoloV7-Pcie_plugin_version_index.json exists... β App YoloV7-Pcie : File doesn't exist at /home/docker/sima-cli/workspace/pcie_pipeline/YoloV7_pcie/YoloV7-Pcie_plugin_version_index.json. Please check the path/file. β Proceed by Skipping Plugin Version Check? [y/n]: y βΌ User chose to proceed with App YoloV7-Pcie deployment, Skipping Plugin Version Check! Performance could be sub-optimal! π Sending MPK to 192.168.135.104... Transfer Progress for project.mpk: 100.00% π MPK sent successfully! β MPK Deployed! ββββββββββββββββββββββββββββββββββββββββ 100% β MPK Deployment is successful for project.mpk.
Visualize the results:
On Host machine below commands need to be run - GST_DEBUG=3 gst-launch-1.0 -v rtspsrc location=<rtsp_url> ! rtph264depay ! h264parse ! avdec_h264 ! videoconvert ! video/x-raw,format=NV12 ! pciehost queuedepth=30 fps=30 showfps=1 card-number=1 ! queue ! videoparse format=nv12 width=1280 height=720 ! videoconvert ! autovideosink ** card-number parameter in pciehost plugin needs to be set accordingly. 0 if only 1 card is available ese "i" based on the card to process the input frames/data. **
To create a rtsp stream - Use the below commands:
1. docker run --rm -it --network=host bluenviron/mediamt 2. ffmpeg -re -stream_loop -1 -i <input_video_feed>.mp4 -c copy -f rtsp rtsp://<host_ip>:8554/mystream