Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -7,7 +7,9 @@ import pandas as pd
|
|
7 |
from transformers import pipeline
|
8 |
|
9 |
# Load the YOLOv5 model
|
10 |
-
|
|
|
|
|
11 |
|
12 |
# Load the translation model
|
13 |
translator = pipeline("translation_en_to_ar", model="Helsinki-NLP/opus-mt-en-ar")
|
@@ -73,7 +75,7 @@ def detect_and_draw_video(video_path):
|
|
73 |
overall_counts[label] = overall_counts.get(label, 0) + 1
|
74 |
|
75 |
cv2.rectangle(frame, (int(xmin), int(ymin)), (int(xmax), int(ymax)), (255, 0, 0), 2)
|
76 |
-
cv2.putText(frame, f"{model.names[int(class_id)]}: {conf:.2f}", (int(xmin), int(ymin) - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.
|
77 |
|
78 |
frames.append(frame)
|
79 |
|
|
|
7 |
from transformers import pipeline
|
8 |
|
9 |
# Load the YOLOv5 model
|
10 |
+
# Use a local clone of YOLOv5
|
11 |
+
yolo_repo = 'ultralytics/yolov5'
|
12 |
+
model = torch.hub.load(yolo_repo, 'yolov5s', source='github')
|
13 |
|
14 |
# Load the translation model
|
15 |
translator = pipeline("translation_en_to_ar", model="Helsinki-NLP/opus-mt-en-ar")
|
|
|
75 |
overall_counts[label] = overall_counts.get(label, 0) + 1
|
76 |
|
77 |
cv2.rectangle(frame, (int(xmin), int(ymin)), (int(xmax), int(ymax)), (255, 0, 0), 2)
|
78 |
+
cv2.putText(frame, f"{model.names[int(class_id)]}: {conf:.2f}", (int(xmin), int(ymin) - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.75, (255, 255, 255), 2)
|
79 |
|
80 |
frames.append(frame)
|
81 |
|