Spaces:
Running
on
Zero
Running
on
Zero
Upload 2 files
Browse files
app.py
CHANGED
|
@@ -7,10 +7,8 @@ import numpy as np
|
|
| 7 |
|
| 8 |
# Modèles optimisés pour le temps réel
|
| 9 |
REALTIME_MODELS = {
|
| 10 |
-
"YOLOS
|
| 11 |
-
"
|
| 12 |
-
"DETR ResNet-50": "facebook/detr-resnet-50",
|
| 13 |
-
"Conditional DETR (optimisé)": "microsoft/conditional-detr-resnet-50"
|
| 14 |
}
|
| 15 |
|
| 16 |
# Variables globales
|
|
@@ -28,6 +26,7 @@ def load_detector(model_name):
|
|
| 28 |
current_detector = pipeline(
|
| 29 |
"object-detection",
|
| 30 |
model=model_id,
|
|
|
|
| 31 |
device=0 if torch.cuda.is_available() else -1
|
| 32 |
)
|
| 33 |
current_model_name = model_name
|
|
@@ -87,11 +86,6 @@ def process_webcam(image, model_choice, confidence_threshold):
|
|
| 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
|
|
@@ -170,7 +164,7 @@ demo = gr.Interface(
|
|
| 170 |
),
|
| 171 |
gr.Dropdown(
|
| 172 |
choices=list(REALTIME_MODELS.keys()),
|
| 173 |
-
value="YOLOS
|
| 174 |
label="Modèle"
|
| 175 |
),
|
| 176 |
gr.Slider(0.1, 1.0, 0.1, step=0.1, label="Confiance")
|
|
|
|
| 7 |
|
| 8 |
# Modèles optimisés pour le temps réel
|
| 9 |
REALTIME_MODELS = {
|
| 10 |
+
"YOLOS (tiny-sized) model": "hustvl/yolos-tiny",
|
| 11 |
+
"RT-DETR": "PekingU/rtdetr_r18vd"
|
|
|
|
|
|
|
| 12 |
}
|
| 13 |
|
| 14 |
# Variables globales
|
|
|
|
| 26 |
current_detector = pipeline(
|
| 27 |
"object-detection",
|
| 28 |
model=model_id,
|
| 29 |
+
verbose=False,
|
| 30 |
device=0 if torch.cuda.is_available() else -1
|
| 31 |
)
|
| 32 |
current_model_name = model_name
|
|
|
|
| 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
|
|
|
|
| 164 |
),
|
| 165 |
gr.Dropdown(
|
| 166 |
choices=list(REALTIME_MODELS.keys()),
|
| 167 |
+
value="YOLOS (tiny-sized) model",
|
| 168 |
label="Modèle"
|
| 169 |
),
|
| 170 |
gr.Slider(0.1, 1.0, 0.1, step=0.1, label="Confiance")
|