Varun
Refactor object detection in app.py to use YOLOv8 model from Hugging Face, removing DiffusionPipeline. Update requirements.txt to include ultralytics and numpy, and adjust Gradio output type.
63bef64
raw
history blame
587 Bytes
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()