Update app.py
Browse files
app.py
CHANGED
|
@@ -56,8 +56,8 @@ def process_video(video_path, target, progress=gr.Progress()):
|
|
| 56 |
break
|
| 57 |
|
| 58 |
# Resize the frame
|
| 59 |
-
img_resized = cv2.resize(img, (640, 360))
|
| 60 |
-
pil_img = Image.fromarray(cv2.cvtColor(
|
| 61 |
|
| 62 |
batch_frames.append(pil_img)
|
| 63 |
batch_indices.append(i)
|
|
@@ -89,17 +89,13 @@ def process_video(video_path, target, progress=gr.Progress()):
|
|
| 89 |
draw.rectangle(box, outline="red", width=4)
|
| 90 |
|
| 91 |
# Increase font size and change color to red
|
| 92 |
-
font_size =
|
| 93 |
try:
|
| 94 |
font = ImageFont.truetype("arial.ttf", font_size)
|
| 95 |
except IOError:
|
| 96 |
font = ImageFont.load_default()
|
| 97 |
|
| 98 |
text_position = (box[0], box[1] - font_size - 5)
|
| 99 |
-
|
| 100 |
-
# Add a semi-transparent background for better text visibility
|
| 101 |
-
text_bbox = draw.textbbox(text_position, annotation, font=font)
|
| 102 |
-
draw.rectangle(text_bbox, fill=(0, 0, 0, 128))
|
| 103 |
|
| 104 |
# Draw text in red
|
| 105 |
draw.text(text_position, annotation, fill="red", font=font)
|
|
|
|
| 56 |
break
|
| 57 |
|
| 58 |
# Resize the frame
|
| 59 |
+
#img_resized = cv2.resize(img, (640, 360))
|
| 60 |
+
pil_img = Image.fromarray(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
|
| 61 |
|
| 62 |
batch_frames.append(pil_img)
|
| 63 |
batch_indices.append(i)
|
|
|
|
| 89 |
draw.rectangle(box, outline="red", width=4)
|
| 90 |
|
| 91 |
# Increase font size and change color to red
|
| 92 |
+
font_size = 50
|
| 93 |
try:
|
| 94 |
font = ImageFont.truetype("arial.ttf", font_size)
|
| 95 |
except IOError:
|
| 96 |
font = ImageFont.load_default()
|
| 97 |
|
| 98 |
text_position = (box[0], box[1] - font_size - 5)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
|
| 100 |
# Draw text in red
|
| 101 |
draw.text(text_position, annotation, fill="red", font=font)
|