import gradio as gr from ultralytics import YOLO import cv2 import numpy as np # charger le modèle model = YOLO("yolov8n-seg.pt") # Fonction pour la détection sur image def detect_objects_image(img): results = model(img) # Détection annotated_frame = results[0].plot() # Annoter les résultats return annotated_frame demo = gr.Blocks() #Interface Gradio image_input = gr.Image(type="numpy", label="Image à analyser") image_output = gr.Image(type="numpy", label="Image annotée") interface = gr.Interface(fn=detect_objects_image, inputs=image_input, outputs=image_output, title="Détection sur Image") interface.launch()