import gradio as gr import supervision as sv from ultralytics import YOLO import numpy as np import cv2 # for video to image conversion model = YOLO('yolov8s.pt') byte_tracker = sv.ByteTrack() annotator = sv.BoxAnnotator() def process_video(frame): results = model(frame)[0] detections = sv.Detections.from_ultralytics(results) detections = byte_tracker.update_with_detections(detections) labels = [ f"#{tracker_id} {model.model.names[class_id]} {confidence:0.2f}" for _, _, confidence, class_id, tracker_id in detections ] yield annotator.annotate(scene=frame.copy(), detections=detections, labels=labels) title = "Object Tracking (w/ YOLOv8)" with gr.Blocks() as io: gr.Markdown(f"