Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -55,7 +55,7 @@ def inference(filepath, lang, labels):
|
|
| 55 |
reader = easyocr.Reader(lang)
|
| 56 |
bounds = reader.readtext(filepath)
|
| 57 |
new_bounds=[]
|
| 58 |
-
|
| 59 |
for (bbox, text, prob) in bounds:
|
| 60 |
(tl, tr, br, bl) = bbox
|
| 61 |
tl = (int(tl[0]), int(tl[1]))
|
|
@@ -76,8 +76,8 @@ def inference(filepath, lang, labels):
|
|
| 76 |
cropped_image = img[min_y:max_y,min_x:max_x] # crop the image
|
| 77 |
cropped_image = Image.fromarray(cropped_image)
|
| 78 |
out = recognitor.predict(cropped_image)
|
| 79 |
-
|
| 80 |
-
result = query(
|
| 81 |
jsonText = json.dumps(result)
|
| 82 |
im = PIL.Image.open(filepath)
|
| 83 |
draw_boxes(im, bounds)
|
|
|
|
| 55 |
reader = easyocr.Reader(lang)
|
| 56 |
bounds = reader.readtext(filepath)
|
| 57 |
new_bounds=[]
|
| 58 |
+
texts=''
|
| 59 |
for (bbox, text, prob) in bounds:
|
| 60 |
(tl, tr, br, bl) = bbox
|
| 61 |
tl = (int(tl[0]), int(tl[1]))
|
|
|
|
| 76 |
cropped_image = img[min_y:max_y,min_x:max_x] # crop the image
|
| 77 |
cropped_image = Image.fromarray(cropped_image)
|
| 78 |
out = recognitor.predict(cropped_image)
|
| 79 |
+
texts = texts + '\t' + out
|
| 80 |
+
result = query(texts, labels)
|
| 81 |
jsonText = json.dumps(result)
|
| 82 |
im = PIL.Image.open(filepath)
|
| 83 |
draw_boxes(im, bounds)
|