Spaces:
Runtime error
Runtime error
stupidog04
commited on
Commit
•
0c84457
1
Parent(s):
a0df3d9
Update app.py
Browse files
app.py
CHANGED
@@ -9,7 +9,7 @@ from pathlib import Path
|
|
9 |
import cv2
|
10 |
import pandas as pd
|
11 |
from transformers import TrOCRProcessor, VisionEncoderDecoderModel
|
12 |
-
|
13 |
|
14 |
#torch.hub.download_url_to_file('https://github.com/AaronCWacker/Yggdrasil/blob/main/images/BeautyIsTruthTruthisBeauty.JPG', 'BeautyIsTruthTruthisBeauty.JPG')
|
15 |
#torch.hub.download_url_to_file('https://github.com/AaronCWacker/Yggdrasil/blob/main/images/PleaseRepeatLouder.jpg', 'PleaseRepeatLouder.jpg')
|
@@ -22,17 +22,6 @@ torch.hub.download_url_to_file('https://github.com/JaidedAI/EasyOCR/raw/master/e
|
|
22 |
torch.hub.download_url_to_file('https://i.imgur.com/mwQFd7G.jpeg', 'Hindi.jpeg')
|
23 |
|
24 |
|
25 |
-
def plot_temporal_profile(temporal_profile):
|
26 |
-
fig = plt.figure()
|
27 |
-
for i, profile in enumerate(temporal_profile):
|
28 |
-
x, y = zip(*profile)
|
29 |
-
plt.plot(x, y, label=f"Box {i+1}")
|
30 |
-
plt.title("Temporal Profiles")
|
31 |
-
plt.xlabel("Time (s)")
|
32 |
-
plt.ylabel("Value")
|
33 |
-
plt.legend()
|
34 |
-
return fig
|
35 |
-
|
36 |
def draw_boxes(image, bounds, color='yellow', width=2):
|
37 |
draw = ImageDraw.Draw(image)
|
38 |
for bound in bounds:
|
@@ -187,10 +176,7 @@ def inference(video, lang, time_step, full_scan, number_filter, use_trocr, perio
|
|
187 |
df_list.append({"Box": f"Box {i+1}", "Time (s)": t, "Text": text})
|
188 |
df_list.append({"Box": f"", "Time (s)": "", "Text": ""})
|
189 |
df = pd.concat([pd.DataFrame(df_list)])
|
190 |
-
|
191 |
-
# generate the plot of temporal profile
|
192 |
-
plot_fig = plot_temporal_profile(temporal_profiles)
|
193 |
-
return output, im, plot_fig, df
|
194 |
|
195 |
|
196 |
title = '🖼️Video to Multilingual OCR👁️Gradio'
|
@@ -228,8 +214,7 @@ gr.Interface(
|
|
228 |
[
|
229 |
gr.outputs.Video(label='Output Video'),
|
230 |
gr.outputs.Image(label='Output Preview', type='numpy'),
|
231 |
-
gr.
|
232 |
-
gr.outputs.Dataframe(headers=['Box', 'Time (s)', 'Text'], type='pandas')
|
233 |
],
|
234 |
title=title,
|
235 |
description=description,
|
@@ -237,4 +222,4 @@ gr.Interface(
|
|
237 |
examples=examples,
|
238 |
css=css,
|
239 |
enable_queue=True
|
240 |
-
).launch(debug=True
|
|
|
9 |
import cv2
|
10 |
import pandas as pd
|
11 |
from transformers import TrOCRProcessor, VisionEncoderDecoderModel
|
12 |
+
|
13 |
|
14 |
#torch.hub.download_url_to_file('https://github.com/AaronCWacker/Yggdrasil/blob/main/images/BeautyIsTruthTruthisBeauty.JPG', 'BeautyIsTruthTruthisBeauty.JPG')
|
15 |
#torch.hub.download_url_to_file('https://github.com/AaronCWacker/Yggdrasil/blob/main/images/PleaseRepeatLouder.jpg', 'PleaseRepeatLouder.jpg')
|
|
|
22 |
torch.hub.download_url_to_file('https://i.imgur.com/mwQFd7G.jpeg', 'Hindi.jpeg')
|
23 |
|
24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
def draw_boxes(image, bounds, color='yellow', width=2):
|
26 |
draw = ImageDraw.Draw(image)
|
27 |
for bound in bounds:
|
|
|
176 |
df_list.append({"Box": f"Box {i+1}", "Time (s)": t, "Text": text})
|
177 |
df_list.append({"Box": f"", "Time (s)": "", "Text": ""})
|
178 |
df = pd.concat([pd.DataFrame(df_list)])
|
179 |
+
return output, im, df
|
|
|
|
|
|
|
180 |
|
181 |
|
182 |
title = '🖼️Video to Multilingual OCR👁️Gradio'
|
|
|
214 |
[
|
215 |
gr.outputs.Video(label='Output Video'),
|
216 |
gr.outputs.Image(label='Output Preview', type='numpy'),
|
217 |
+
gr.outputs.Dataframe(headers=['Box', 'Time (s)', 'Text'], type='pandas'),
|
|
|
218 |
],
|
219 |
title=title,
|
220 |
description=description,
|
|
|
222 |
examples=examples,
|
223 |
css=css,
|
224 |
enable_queue=True
|
225 |
+
).launch(debug=True)
|