File size: 587 Bytes
803b87c
63bef64
644c203
63bef64
 
 
 
803b87c
 
2932b3e
63bef64
 
 
2932b3e
 
 
 
 
63bef64
2932b3e
63bef64
2932b3e
 
 
 
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
import gradio as gr
from ultralytics import YOLO

# Load YOLOv8 model from Hugging Face
model = YOLO(
    "https://huggingface.co/Lookingsoft-team/object_detection/resolve/main/yolov8n.pt"
)


def detect_objects(image):
    results = model(image)
    annotated_image = results[0].plot()  # Draw bounding boxes
    return annotated_image


demo = gr.Interface(
    fn=detect_objects,
    inputs=gr.Image(type="pil"),
    outputs=gr.Image(type="numpy"),
    title="Object Detection",
    description="Upload an image for object detection!",
)

if __name__ == "__main__":
    demo.launch()