How to broadcast predictions from YOLO-NAS Over UDP

You can broadcast predictions from


. This is useful for sending the results of a model to a central system for further processing or logging.

In this guide, we will demonstrate how to broadcast predictions from



‍In this guide, we will demonstrate how to broadcast predictions fromWe will:

1. Install supervision
2. Load data
3. Plot predictions with a supervision Annotator

Without further ado, let's get started!

Step #1: Install supervision

First, install the supervision pip package:

pip install supervision

Once you have installed supervision, you are ready to load your data and start writing logic to filter detections.

Step #2: Load Model and Send Data

For this guide, you will need to have a broker set up that can accept predictions. Once you have a broker, you can stream predictions from your model that is running on a video, camera feed, or RTSP stream feed.

You can load the model and send data using the following code:

First, you need to configure a script that runs inference. You can use the Inference UDPSink:

import cv2
from import InferencePipeline
from import UDPSink

udp_sink = UDPSink.init(ip_address="", port=9090)

pipeline = InferencePipeline.init(
Above, replace `` and `9090` with the host address on which your UDP server is running and the port on which the model is running. You will then need to start a UDP server that can receive predictions. Here is an example of a UDP server:

import json
import os
import socket

HOST = os.getenv("HOST", "")
PORT = int(os.getenv("PORT", "9090"))

def main() -> None:
    udp_socket = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM)
    udp_socket.bind((HOST, PORT))
        while True:
            message, _ = udp_socket.recvfrom(BUFFER_SIZE)
            decoded_message = message.decode("utf-8")
            parsed_message = json.loads(decoded_message)

if __name__ == '__main__':

Once you make the necessary substitutions above and run the script, you should see data being received by your broker for any further processing you implement.

Next steps

supervision provides an extensive range of functionalities for working with computer vision models. With supervision, you can:

1. Process and filter detections and segmentation masks from a range of popular models (YOLOv5, Ultralytics YOLOv8, MMDetection, and more).
2. Process and filter classifications.
3. Compute confusion matrices.

And more! To learn about the full range of functionality in supervision, check out the supervision documentation.