Omnibus commited on
Commit
841b400
·
1 Parent(s): dc5ee09

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -8
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
- reader = easyocr.Reader(lang)
8
- bounds = reader.readtext(img)
9
- tot_b = len(bounds)
10
- tot_num = 0
11
- for i,bound in enumerate(bounds):
12
- #idx = (int(i) - 1)
13
- tot_num = tot_num + bound[2]
14
- out = tot_num / tot_b
 
 
 
 
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: