Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import cv2 | |
| from ultralytics import YOLO | |
| import numpy as np | |
| # Load Advanced YOLOv8 Model (medium version) | |
| model = YOLO('yolov8m.pt') # You can switch to yolov8l.pt or yolov8x.pt for even more accuracy | |
| def detect_objects(image): | |
| image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR) | |
| results = model(image) | |
| annotated = results[0].plot() | |
| annotated = cv2.cvtColor(annotated, cv2.COLOR_BGR2RGB) | |
| return annotated | |
| gr.Interface( | |
| fn=detect_objects, | |
| inputs=gr.Image(type="numpy", label="Upload an Image"), | |
| outputs="image", | |
| title="Advanced Object Detection with YOLOv8m", | |
| description="Upload an image to detect objects using YOLOv8 Medium Model (YOLOv8m.pt)." | |
| ).launch() | |