Omnibus commited on
Commit
3d87288
Β·
1 Parent(s): a7c6ed3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -13
app.py CHANGED
@@ -234,21 +234,13 @@ def detect(img, target_lang,trans_lang,target_lang2=None):
234
  else:
235
  lang=[f"{ocr_id[target_lang]}"]
236
  pass
237
- img=cv2.imread(img)
238
- im_h = img.shape[0]
239
- im_w = img.shape[1]
240
- if im_w > im_h:
241
- rato=im_h/im_w
242
- img = cv2.resize(img, (1000,(int(1000*float(rato)))))
243
- elif im_w < im_h:
244
- rato=im_w/im_h
245
- img = cv2.resize(img, (int(1000*float(rato)),1000))
246
- elif im_w == im_h:
247
- img = cv2.resize(img,(1000,1000))
248
-
249
- img = Image.fromarray(img)
250
  reader = easyocr.Reader(lang)
251
  bounds = reader.readtext(img)
 
252
  im = PIL.Image.open(img)
253
  im_out=draw_boxes(im, bounds)
254
  #im.save('result.jpg')
 
234
  else:
235
  lang=[f"{ocr_id[target_lang]}"]
236
  pass
237
+ img = Image.open(img)
238
+
239
+ img = Image.thumbnail((1000,1000))
240
+
 
 
 
 
 
 
 
 
 
241
  reader = easyocr.Reader(lang)
242
  bounds = reader.readtext(img)
243
+
244
  im = PIL.Image.open(img)
245
  im_out=draw_boxes(im, bounds)
246
  #im.save('result.jpg')