Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -42,15 +42,15 @@ def inference(filepath, lang):
|
|
| 42 |
bounds = reader.readtext(filepath)
|
| 43 |
new_bounds=[]
|
| 44 |
for (bbox, text, prob) in bounds:
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
|
| 50 |
# crop the region of interest (ROI)
|
| 51 |
img = Image.open(filepath)
|
| 52 |
#img = img[y0:y1, x0:x1]
|
| 53 |
-
img = img.crop((
|
| 54 |
img = process_input(img, config['dataset']['image_height'],
|
| 55 |
config['dataset']['image_min_width'], config['dataset']['image_max_width'])
|
| 56 |
out = translate(img, model)[0].tolist()
|
|
|
|
| 42 |
bounds = reader.readtext(filepath)
|
| 43 |
new_bounds=[]
|
| 44 |
for (bbox, text, prob) in bounds:
|
| 45 |
+
x1,y1 = bbox[0]
|
| 46 |
+
x2,y2 = bbox[1]
|
| 47 |
+
x3,y3 = bbox[2]
|
| 48 |
+
x4,y4 = bbox[3]
|
| 49 |
|
| 50 |
# crop the region of interest (ROI)
|
| 51 |
img = Image.open(filepath)
|
| 52 |
#img = img[y0:y1, x0:x1]
|
| 53 |
+
img = img.crop((x1, y1, x3, y3)) # crop the image
|
| 54 |
img = process_input(img, config['dataset']['image_height'],
|
| 55 |
config['dataset']['image_min_width'], config['dataset']['image_max_width'])
|
| 56 |
out = translate(img, model)[0].tolist()
|