Spaces:
Sleeping
Sleeping
Download interface/detect_interface_methods.py from Cippppy/YOLOv8_Interface: direct link, hf CLI and curl.
- Browser
- Download file 439 Bytes
-
https://huggingface.co/spaces/Cippppy/YOLOv8_Interface/resolve/main/interface/detect_interface_methods.py
- Command line
-
hf download hf://spaces/Cippppy/YOLOv8_Interface/interface/detect_interface_methods.py
-
curl -L -o detect_interface_methods.py https://huggingface.co/spaces/Cippppy/YOLOv8_Interface/resolve/main/interface/detect_interface_methods.py
439 Bytes
| import gradio as gr | |
| from ultralytics import YOLO | |
| import numpy as np | |
| def interface_detect(source): | |
| # Load a pretrained YOLOv8n model | |
| model = YOLO('yolov8n.pt') # Load an official Detect model | |
| if isinstance(source, gr.Video): | |
| print("To be added") | |
| elif isinstance(source, np.ndarray): | |
| results = model.predict(source) | |
| return results[0].plot() | |
| else: | |
| raise ValueError("Invalid source type") |