Spaces:
Sleeping
Sleeping
File size: 804 Bytes
ae7a7b7 |
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 |
import gradio as gr
import torch
from ultralytics import YOLO
from PIL import Image
import numpy as np
import os
# Charger le modèle localement pour éviter les problèmes SSL
def detect_objects(image):
model_path = "best.pt" # Assurez-vous que le modèle est bien téléchargé
model = YOLO(model_path) # Charger le modèle entraîné
results = model(image) # Exécuter la détection
result_image = results[0].plot() # Générer l'image annotée
return Image.fromarray(result_image)
# Interface Gradio
demo = gr.Interface(
fn=detect_objects,
inputs=gr.Image(type="pil"),
outputs=gr.Image(type="pil"),
title="Détection d'objets avec YOLOv8",
description="Uploader une image pour détecter les objets."
)
if __name__ == "__main__":
demo.launch()
|