Spaces:
Runtime error
Runtime error
Commit
·
22849cc
1
Parent(s):
c139569
Update app.py
Browse files
app.py
CHANGED
@@ -64,21 +64,19 @@ def inference(video, lang, time_step):
|
|
64 |
while success:
|
65 |
if count % (int(frame_rate * time_step)) == 0:
|
66 |
for i, box in enumerate(largest_boxes):
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
if text:
|
81 |
-
temporal_profiles[i].append((count / frame_rate, text[0][1]))
|
82 |
im = PIL.Image.fromarray(frame)
|
83 |
im_with_boxes = draw_boxes(im, bounds)
|
84 |
output_frames.append(np.array(im_with_boxes))
|
|
|
64 |
while success:
|
65 |
if count % (int(frame_rate * time_step)) == 0:
|
66 |
for i, box in enumerate(largest_boxes):
|
67 |
+
x1, y1 = box[0][0]
|
68 |
+
x2, y2 = box[0][2]
|
69 |
+
box_width = x2 - x1
|
70 |
+
box_height = y2 - y1
|
71 |
+
ratio = 0.2
|
72 |
+
x1 = max(0, int(x1 - ratio * box_width))
|
73 |
+
x2 = min(frame.shape[1], int(x2 + ratio * box_width))
|
74 |
+
y1 = max(0, int(y1 - ratio * box_height))
|
75 |
+
y2 = min(frame.shape[0], int(y2 + ratio * box_height))
|
76 |
+
cropped_frame = frame[y1:y2, x1:x2]
|
77 |
+
text = reader.readtext(cropped_frame)
|
78 |
+
if text:
|
79 |
+
temporal_profiles[i].append((count / frame_rate, text[0][1]))
|
|
|
|
|
80 |
im = PIL.Image.fromarray(frame)
|
81 |
im_with_boxes = draw_boxes(im, bounds)
|
82 |
output_frames.append(np.array(im_with_boxes))
|