Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,14 +4,18 @@ import numpy as np
|
|
| 4 |
from PIL import Image
|
| 5 |
|
| 6 |
def detect_lang_ocr(img,lang):
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
return out
|
| 16 |
|
| 17 |
with gr.Blocks() as app:
|
|
|
|
| 4 |
from PIL import Image
|
| 5 |
|
| 6 |
def detect_lang_ocr(img,lang):
|
| 7 |
+
try:
|
| 8 |
+
reader = easyocr.Reader(lang)
|
| 9 |
+
bounds = reader.readtext(img)
|
| 10 |
+
tot_b = len(bounds)
|
| 11 |
+
tot_num = 0
|
| 12 |
+
for i,bound in enumerate(bounds):
|
| 13 |
+
#idx = (int(i) - 1)
|
| 14 |
+
tot_num = tot_num + bound[2]
|
| 15 |
+
out = tot_num / tot_b
|
| 16 |
+
except Exception as e:
|
| 17 |
+
out = e
|
| 18 |
+
|
| 19 |
return out
|
| 20 |
|
| 21 |
with gr.Blocks() as app:
|