File size: 645 Bytes
827fb6c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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()