ballatraore commited on
Commit
827fb6c
·
verified ·
1 Parent(s): ed3eaa3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py CHANGED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from ultralytics import YOLO
3
+ import cv2
4
+ import numpy as np
5
+ # charger le modèle
6
+ model = YOLO("yolov8n-seg.pt")
7
+
8
+ # Fonction pour la détection sur image
9
+ def detect_objects_image(img):
10
+ results = model(img) # Détection
11
+ annotated_frame = results[0].plot() # Annoter les résultats
12
+ return annotated_frame
13
+
14
+
15
+ demo = gr.Blocks()
16
+
17
+ #Interface Gradio
18
+ image_input = gr.Image(type="numpy", label="Image à analyser")
19
+
20
+ image_output = gr.Image(type="numpy", label="Image annotée")
21
+
22
+
23
+ interface = gr.Interface(fn=detect_objects_image, inputs=image_input, outputs=image_output, title="Détection sur Image")
24
+
25
+ interface.launch()