Inference Pipeline
Run models on video streams with InferencePipeline: video sources, custom inference logic, Workflows, and sinks.
Quickstart
export ROBOFLOW_API_KEY=<your api key>pip install inferencepip install --extra-index-url https://download.pytorch.org/whl/cu124 inference-gpu
# please adjust the --extra-index-url to the CUDA version installed in your OS# import the InferencePipeline interface
from inference import InferencePipeline
# import a built-in sink called render_boxes (sinks are the logic that happens after inference)
from inference.core.interfaces.stream.sinks import render_boxes
api_key = "YOUR_ROBOFLOW_API_KEY"
# Create an inference pipeline object
pipeline = InferencePipeline.init(
# set the model id to an rfdetr model (pre-trained on COCO)
model_id="rfdetr-large",
# set the video reference (source of video), it can be a link/path to a video file, an RTSP stream url,
# or an integer representing a device id (usually 0 for built in webcams)
video_reference="https://storage.googleapis.com/com-roboflow-marketing/inference/people-walking.mp4",
# tell the pipeline what to do with inference results. render_boxes is a built-in sink that renders boxes on top of the video
on_prediction=render_boxes,
# provide your roboflow api key for loading models from the roboflow api
api_key=api_key,
)
# Start the pipeline and join the thread that processes the video stream.
pipeline.start()
pipeline.join()What is a video reference?
How InferencePipeline works

Custom inference logic
InferencePipeline with Workflows
Sinks
Usage
Custom sink tutorial
Custom sinks (advanced)
Why is there Optional in List[Optional[dict]] and List[Optional[VideoFrame]]?
Built-in sinks
render_boxes(...)
UDPSink(...)
multi_sink(...)
VideoFileSink(...)
Model weights download
Other pipeline configuration
Last updated
Was this helpful?