How to broadcast predictions from YOLOv7 Over Webhook

You can broadcast predictions from

YOLOv7 Over Webhook

. 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

YOLOv7 Over Webhook

.

‍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:


import json
import requests

from inference import InferencePipeline
from inference.core.interfaces.stream.sinks import render_boxes

def on_prediction(predictions, video_frame):
    render_boxes(predictions=predictions, video_frame=video_frame)
    requests.post("URL", json=predictions)


pipeline = InferencePipeline.init(
    model_id="bottle-cap-integrity/7", # add your Roboflow YOLOv5 model ID here
    video_reference=0,
    on_prediction=on_prediction,
    confidence=0.3,
)

pipeline.start()
pipeline.join()


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.