Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import cv2
|
| 3 |
from ultralytics import YOLO
|
| 4 |
import tempfile
|
| 5 |
-
import os
|
| 6 |
|
| 7 |
-
# Charger le modèle
|
| 8 |
-
model = YOLO("./yolo12m.pt")
|
| 9 |
|
| 10 |
# Classes à détecter
|
| 11 |
target_classes = ["backpack", "suitcase", "handbag"]
|
|
@@ -26,7 +26,7 @@ def process_video(video_path):
|
|
| 26 |
class_counts = {c: 0 for c in target_classes}
|
| 27 |
total_count = 0
|
| 28 |
|
| 29 |
-
#
|
| 30 |
temp_out = tempfile.NamedTemporaryFile(delete=False, suffix=".mp4")
|
| 31 |
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
|
| 32 |
out = cv2.VideoWriter(temp_out.name, fourcc, 20, (W, H))
|
|
@@ -66,7 +66,7 @@ def process_video(video_path):
|
|
| 66 |
cv2.putText(frame, f"{name}: {class_counts[name]}", (20, y_offset),
|
| 67 |
cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 255, 255), 2)
|
| 68 |
y_offset += 30
|
| 69 |
-
cv2.putText(frame, f"Total: {total_count}", (20, y_offset + 10),
|
| 70 |
cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 0, 0), 2)
|
| 71 |
cv2.line(frame, (0, line_y), (W, line_y), (0, 0, 255), 2)
|
| 72 |
|
|
|
|
| 1 |
+
# app.py
|
| 2 |
import gradio as gr
|
| 3 |
import cv2
|
| 4 |
from ultralytics import YOLO
|
| 5 |
import tempfile
|
|
|
|
| 6 |
|
| 7 |
+
# Charger le modèle YOLO (chemin relatif)
|
| 8 |
+
model = YOLO("./yolo12m.pt")
|
| 9 |
|
| 10 |
# Classes à détecter
|
| 11 |
target_classes = ["backpack", "suitcase", "handbag"]
|
|
|
|
| 26 |
class_counts = {c: 0 for c in target_classes}
|
| 27 |
total_count = 0
|
| 28 |
|
| 29 |
+
# Vidéo temporaire de sortie
|
| 30 |
temp_out = tempfile.NamedTemporaryFile(delete=False, suffix=".mp4")
|
| 31 |
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
|
| 32 |
out = cv2.VideoWriter(temp_out.name, fourcc, 20, (W, H))
|
|
|
|
| 66 |
cv2.putText(frame, f"{name}: {class_counts[name]}", (20, y_offset),
|
| 67 |
cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 255, 255), 2)
|
| 68 |
y_offset += 30
|
| 69 |
+
cv2.putText(frame, f"Total bagages : {total_count}", (20, y_offset + 10),
|
| 70 |
cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 0, 0), 2)
|
| 71 |
cv2.line(frame, (0, line_y), (W, line_y), (0, 0, 255), 2)
|
| 72 |
|