hantech commited on
Commit
75f9e87
β€’
1 Parent(s): 56cdfa2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
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
- y0 = min(bbox[0])
46
- y1 = max(bbox[0])
47
- x0 = min(bbox[1])
48
- x1 = max(bbox[1])
49
 
50
  # crop the region of interest (ROI)
51
  img = Image.open(filepath)
52
  #img = img[y0:y1, x0:x1]
53
- img = img.crop((x0, y0, x1, y1)) # 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()
 
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()