Skip to main content

GStreamer Python ML

CI

Run any model with ease inside any GStreamer pipeline.

Pure Python ML elements for upstream GStreamer 1.24 or later: one element per task, or bring your own model and run it with the base classes and matching engine.

Write the pipeline in gst-launch format and run it with pyml-launch, with media backend set to either GStreamer or glass2glass.

Features

  • Video
    • object detection and zero-shot detection
    • tracking
    • pose estimation
    • depth estimation
    • zero-shot classification with CLIP or SigLIP
    • segmentation with SAM2
    • OCR
    • face detection and recognition
    • optical flow
    • super-resolution
    • action recognition
    • anomaly detection
    • captioning and vision-language models
    • embeddings and video search
  • Audio
    • voice activity detection
    • transcription and translation
    • speech separation
    • text to speech
    • audio classification with CLAP
  • Text
    • local and remote LLMs
    • incident digests
    • text to image
  • Around them
    • alerts over webhooks and MQTT
    • clip recording
    • metadata sink and replay
    • Kafka sink
    • MCP server for agents
  • Engines
    • PyTorch by default
    • ONNX Runtime, TensorRT through ONNX Runtime, OpenVINO, LiteRT, TensorFlow
    • Apache TVM, tinygrad, Apple MLX, ExecuTorch, llama.cpp, JAX
    • MiGraphX, IREE, NCNN, Renesas DRP-AI
    • CI runs every engine that installs from PyPI on the CPU and checks its output against PyTorch

Install

Ubuntu 24.04 or later:

sudo apt install -y python3-pip python3-venv \
    gstreamer1.0-plugins-base gstreamer1.0-plugins-base-apps \
    gstreamer1.0-plugins-good gstreamer1.0-plugins-bad \
    gir1.2-gst-plugins-bad-1.0 python3-gst-1.0 gstreamer1.0-python3-plugin-loader \
    libcairo2 libcairo2-dev git

Then a venv on the system Python, which is the one GStreamer's plugin loader embeds. uv sync installs PyTorch, with CUDA on Linux, and the yolo extra adds the YOLO models the quick start uses.

curl -LsSf https://astral.sh/uv/install.sh | sh
git clone https://github.com/collabora/gst-python-ml.git && cd gst-python-ml
uv venv --python /usr/bin/python3 --system-site-packages
uv sync --extra yolo
export GST_PLUGIN_PATH=$PWD/plugins:$GST_PLUGIN_PATH
gst-inspect-1.0 python

The last line lists the pyml_* elements. INSTALL.md covers Fedora, Windows, Docker, the feature extras, the other engines and custom plugins.

Quick start

Paths are relative to the checkout directory. Change device=cuda to device=cpu on a machine without a GPU.

Track people with YOLO:

python pyml-launch.py filesrc location=data/soccer_tracking.mp4 ! decodebin ! videoconvertscale ! video/x-raw,width=640,height=480 ! pyml_yolo model-name=yolo11m device=cuda track=True ! pyml_overlay ! videoconvert ! autovideosink

Estimate depth with Depth Anything V2:

python pyml-launch.py filesrc location=data/people.mp4 ! decodebin ! videoconvert ! videoscale ! video/x-raw,width=640,height=480 ! pyml_depth model-name=depth-anything/Depth-Anything-V2-Small-hf device=cuda ! videoconvert ! autovideosink sync=false

Transcribe Korean speech and translate it to English. Transcripts are logged at GStreamer info level:

GST_DEBUG=python:4 python pyml-launch.py filesrc location=data/air_traffic_korean_with_english.wav ! decodebin ! audioconvert ! pyml_whispertranscribe device=cuda language=ko translate=yes ! fakesink

Record a clip around every person detection:

python pyml-launch.py filesrc location=data/people.mp4 ! decodebin ! videoconvert ! videoscale ! video/x-raw,width=640,height=480 ! pyml_yolo model-name=yolo11m device=cuda ! pyml_alert rules='{"class":"person","min_score":0.7}' cooldown=8 draw-alert=false ! pyml_alertrecorder location=alert-%s.webm seconds-before=2 seconds-after=3 ! pyml_overlay ! videoconvert ! autovideosink sync=false

Replay a recorded detection stream through the tracker and overlay, with no model and no GPU:

python pyml-launch.py filesrc location=data/people.mp4 ! decodebin ! videoconvert ! videoscale ! video/x-raw,width=640,height=480 ! pyml_metareplay location=data/people.jsonl ! pyml_tracker tracker-type=sort ! pyml_overlay ! videoconvert ! autovideosink sync=false

PIPELINES.md describes every pipeline, one or two per element, how to run them under glass2glass, and how to run the MCP server.

Blog post

Unleashing gst-python-ml

Unleashing gst-python-ml: Python-powered ML analytics for GStreamer pipelines

Combining GStreamer with machine learning frameworks into video analytics pipelines, from object detection to video captioning.

Metadata

Release files for gst-python-ml 1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gst-python-ml 1.2.1
File Size Uploaded
gst_python_ml-1.2.1.tar.gz 236.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gst-python-ml 1.2.1
File Interpreter ABI Platform
gst_python_ml-1.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 642.6 kB

Release files / gst_python_ml-1.2.1.tar.gz

Download URL gst_python_ml-1.2.1.tar.gz
Size 236.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b411086b42cd5df00330e19a43dea2776d3b07624dc08d7f243cacd8bb66b9a6
BLAKE2b-256 checksum
How to use checksums
a15f0637e032eb6f46339abf31eb2446dfff931ebd02c2eb1551aabab67c491c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Release files / gst_python_ml-1.2.1-py3-none-any.whl

Download URL gst_python_ml-1.2.1-py3-none-any.whl
Size 405.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8db61a82ab90c8b6ef2266684b74e8ddd0cfa1d4fb8789723877df8968598ffd
BLAKE2b-256 checksum
How to use checksums
3d70af50976f4151f8937e2bf2a7e457abcc74e19d7e0b4e8b5c0d3d7853f41d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Release history Release notifications | RSS feed

1.3.0

2 release files

This release

1.2.1 This release

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page