Spaces:
Runtime error
Runtime error
File size: 929 Bytes
2d27b0e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
import os
import gradio as gr
import numpy as np
import supervision as sv
from ultralytics import YOLO
def detect(image, weights):
model = YOLO(weights)
result = model(image, verbose=False)[0]
detections = sv.Detections.from_ultralytics(result)
box_annotator = sv.BoxAnnotator()
annotated_image = box_annotator.annotate(image.copy(), detections=detections)
return annotated_image
if __name__ == '__main__':
gr.Interface(
detect, [gr.Image(type="numpy"), gr.Dropdown(choices=["yolov5s", "yolov5s6"])],
gr.Image(type="numpy"),
title="Yolov5",
examples=[["https://media.roboflow.com/notebooks/examples/dog.jpeg", "yolov5s"]],
description=
"Gradio based demo for <a href='https://github.com/roboflow/supervision' style='text-decoration: underline' target='_blank'>roboflow/supervision</a>, We write your reusable computer vision tools."
).launch()
|