Spaces:
Running
on
Zero
Running
on
Zero
Upload app.py
Browse files
app.py
CHANGED
@@ -8,8 +8,9 @@ import numpy as np
|
|
8 |
# Modèles optimisés pour le temps réel
|
9 |
REALTIME_MODELS = {
|
10 |
"YOLOS Tiny (ultra-rapide)": "hustvl/yolos-tiny",
|
|
|
11 |
"DETR ResNet-50": "facebook/detr-resnet-50",
|
12 |
-
"
|
13 |
}
|
14 |
|
15 |
# Variables globales
|
@@ -86,10 +87,15 @@ def process_webcam(image, model_choice, confidence_threshold):
|
|
86 |
detections = detector(resized_image)
|
87 |
print(f"🎯 Détections brutes: {len(detections)}")
|
88 |
|
|
|
|
|
|
|
|
|
|
|
89 |
# Filtrer par confiance
|
90 |
filtered_detections = [
|
91 |
det for det in detections
|
92 |
-
if det
|
93 |
]
|
94 |
|
95 |
print(f"✅ Détections filtrées: {len(filtered_detections)}")
|
@@ -151,7 +157,7 @@ def draw_detections(image, detections):
|
|
151 |
|
152 |
return img_copy
|
153 |
|
154 |
-
# Interface avec
|
155 |
demo = gr.Interface(
|
156 |
fn=process_webcam,
|
157 |
inputs=[
|
@@ -159,8 +165,8 @@ demo = gr.Interface(
|
|
159 |
sources=["webcam"],
|
160 |
streaming=True,
|
161 |
type="pil",
|
162 |
-
|
163 |
-
|
164 |
),
|
165 |
gr.Dropdown(
|
166 |
choices=list(REALTIME_MODELS.keys()),
|
@@ -172,8 +178,7 @@ demo = gr.Interface(
|
|
172 |
outputs=gr.Image(streaming=True, type="pil", show_download_button=False),
|
173 |
live=True,
|
174 |
title="🎥 Détection Live",
|
175 |
-
description="
|
176 |
-
allow_flagging="never",
|
177 |
flagging_mode="never"
|
178 |
)
|
179 |
|
|
|
8 |
# Modèles optimisés pour le temps réel
|
9 |
REALTIME_MODELS = {
|
10 |
"YOLOS Tiny (ultra-rapide)": "hustvl/yolos-tiny",
|
11 |
+
"YOLOS Small": "hustvl/yolos-small",
|
12 |
"DETR ResNet-50": "facebook/detr-resnet-50",
|
13 |
+
"Conditional DETR (optimisé)": "microsoft/conditional-detr-resnet-50"
|
14 |
}
|
15 |
|
16 |
# Variables globales
|
|
|
87 |
detections = detector(resized_image)
|
88 |
print(f"🎯 Détections brutes: {len(detections)}")
|
89 |
|
90 |
+
# Debug: afficher le format des détections pour DETR
|
91 |
+
if detections and model_choice == "DETR ResNet-50":
|
92 |
+
print(f"🔧 Debug DETR - Première détection: {detections[0]}")
|
93 |
+
print(f"🔧 Keys disponibles: {list(detections[0].keys())}")
|
94 |
+
|
95 |
# Filtrer par confiance
|
96 |
filtered_detections = [
|
97 |
det for det in detections
|
98 |
+
if det.get('score', 0) >= confidence_threshold
|
99 |
]
|
100 |
|
101 |
print(f"✅ Détections filtrées: {len(filtered_detections)}")
|
|
|
157 |
|
158 |
return img_copy
|
159 |
|
160 |
+
# Interface avec activation webcam forcée
|
161 |
demo = gr.Interface(
|
162 |
fn=process_webcam,
|
163 |
inputs=[
|
|
|
165 |
sources=["webcam"],
|
166 |
streaming=True,
|
167 |
type="pil",
|
168 |
+
show_download_button=False,
|
169 |
+
interactive=True
|
170 |
),
|
171 |
gr.Dropdown(
|
172 |
choices=list(REALTIME_MODELS.keys()),
|
|
|
178 |
outputs=gr.Image(streaming=True, type="pil", show_download_button=False),
|
179 |
live=True,
|
180 |
title="🎥 Détection Live",
|
181 |
+
description="🚨 IMPORTANT: Activez la webcam en cliquant sur l'icône caméra dans la zone Image",
|
|
|
182 |
flagging_mode="never"
|
183 |
)
|
184 |
|