Spaces:
Sleeping
Sleeping
File size: 684 Bytes
c3d5a86 803b87c 63bef64 c3d5a86 644c203 c3d5a86 63bef64 803b87c c3d5a86 803b87c 2932b3e 63bef64 c3d5a86 2932b3e 63bef64 2932b3e c3d5a86 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 27 28 29 30 31 |
import os
import gradio as gr
from ultralytics import YOLO
from huggingface_hub import hf_hub_download
# Download private model using HF token from secret
hf_token = os.environ.get("HF_TOKEN")
model_path = hf_hub_download(
repo_id="Lookingsoft-team/object_detection", filename="yolov8n.pt", token=hf_token
)
# Load model
model = YOLO(model_path)
def detect_objects(image):
results = model(image)
return results[0].plot()
demo = gr.Interface(
fn=detect_objects,
inputs=gr.Image(type="pil"),
outputs=gr.Image(type="numpy"),
title="Object Detection",
description="Upload an image to detect objects.",
)
if __name__ == "__main__":
demo.launch()
|