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_host_pcie_pkg.sh is installed on host for proper communication

  • Follow PCIe setup instructions to configure the PCIe cards 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

"pcie"

source.value

Identifier string for PCIe input

"PCIE"

udp_host

Not used for PCIe setup

""

port

Not used for PCIe setup

""

pipeline

Inference pipeline identifier

"YoloV7-Pcie"

Model Configuration

Parameter

Description

Value

name

Model identifier

"yolov7"

targz

Path to the YOLOv7 model archive

"<targz filepath>"

label_file

Path to the label file

"labels.txt"

normalize

Enable input normalization

true

channel_mean

Per-channel mean values

[0.0, 0.0, 0.0]

channel_stddev

Per-channel stddev values

[1.0, 1.0, 1.0]

padding_type

Padding strategy during preprocessing

"CENTER"

aspect_ratio

Preserve input aspect ratio

true

topk

Maximum number of detections per frame

10

detection_threshold

Confidence threshold for object detection

0.7

decode_type

Postprocessing decode strategy

"yolo"

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:

  1. Loads the configuration from project.yaml

  2. Initializes the PCIe VideoReader and VideoWriter

  3. Sets the expected input and output resolution to 1280Γ—720

  4. Loads and configures the YOLOv7 model session on SiMa’s MLSoC

  5. 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: [0.0, 0.0, 0.0], stddev: [1.0, 1.0, 1.0])

Detection Threshold

0.7

Output

Top 10 detections per frame

Decoding Strategy

YOLO

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:

  1. 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 sima@192.168.1.20
    β„Ή Connecting to sima@192.168.1.20...
    πŸ”— Connection established to 192.168.1.20 .
    β„Ή Fetching Device Plugin Version data file from : 192.168.1.20 ...
    βœ” Successfully fetched and updated Plugin Version Data file from : 192.168.1.20.
    
  2. Prepare project directory:

    sima-user@docker-image-id:/home/docker/sima-cli/workspace$ mkdir pcie_tutorial && cd pcie_tutorial
    sima-user@docker-image-id:/home/docker/sima-cli/workspace/pcie_tutorial$ sima-cli install -v 1.7.0 samples/peppi-tutorials/pcie
    
  3. Update project.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"
    
  4. Create the pipeline package:

    sima-user@docker-image-id:/home/docker/sima-cli/workspace/pcie_tutorial$ 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_tutorial/project.mpk
    
  5. Deploy the pipeline package:

    sima-user@docker-image-id:/home/docker/sima-cli/workspace/pcie_tutorial$ mpk deploy -f project.mpk
    β„Ή Checking if App YoloV7-Pcie Plugin Version Index File
    /home/docker/sima-cli/workspace/pcie_tutorial/YoloV7-Pcie_plugin_version_index.json
    exists...
    ❗ App YoloV7-Pcie : File doesn't exist at
    /home/docker/sima-cli/workspace/pcie_tutorial/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.1.20...
    Transfer Progress for project.mpk:  100.00%
    🏁 MPK sent successfully!
    Installing MPK... ━━━━━━━━━━╺━━━━━━━━━━━━━━━━━━━━━━━━━━━━━  25%
    
    ... ... ...
    
    🏁 MPK sent successfully!
    βœ” MPK Deployed! ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100%
    βœ” MPK Deployment is successful for project.mpk.
    
  6. Visualize the results:

    On the host machine run the following commands card-number parameter in pciehost plugin needs to be set accordingly. 0 if only 1 card is available else β€œi” based on the card to process the input frames/data.

    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
    
  7. 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