Spaces:
Build error
Build error
import cv2 | |
import numpy as np | |
import gradio as gr | |
from ultralytics import YOLO | |
video_path = [['files/a.mp4']] | |
inputs = [gr.components.Video(type="filepath", label="Input ")] | |
outputs = [gr.components.Image(type="numpy", label="Output ")] | |
model = YOLO("files/yolov8n.pt") | |
def show_preds_video(video_file): | |
cap = cv2.VideoCapture(video_file) | |
while cap.isOpened(): | |
success, frame = cap.read() | |
if success: | |
results = model.track(frame, persist=True) | |
annotated_frame = results[0].plot() | |
yield cv2.cvtColor(annotated_frame, cv2.COLOR_BGR2RGB) | |
video_processing = gr.Interface( | |
fn=show_preds_video, | |
inputs=inputs, | |
outputs=outputs, | |
examples=video_path, | |
cache_examples=False, | |
title="Video Multi Objects tracking", | |
) |