asalhi85 commited on
Commit
929c9f9
1 Parent(s): 200ac55

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -9
app.py CHANGED
@@ -6,15 +6,8 @@ import gradio as gr
6
  import torch
7
  import easyocr
8
 
9
- # torch.hub.download_url_to_file('https://github.com/JaidedAI/EasyOCR/raw/master/examples/english.png', 'english.png')
10
- # torch.hub.download_url_to_file('https://github.com/JaidedAI/EasyOCR/raw/master/examples/thai.jpg', 'thai.jpg')
11
- # torch.hub.download_url_to_file('https://github.com/JaidedAI/EasyOCR/raw/master/examples/french.jpg', 'french.jpg')
12
- # torch.hub.download_url_to_file('https://github.com/JaidedAI/EasyOCR/raw/master/examples/chinese.jpg', 'chinese.jpg')
13
- # torch.hub.download_url_to_file('https://github.com/JaidedAI/EasyOCR/raw/master/examples/japanese.jpg', 'japanese.jpg')
14
- # torch.hub.download_url_to_file('https://github.com/JaidedAI/EasyOCR/raw/master/examples/korean.png', 'korean.png')
15
- # torch.hub.download_url_to_file('https://i.imgur.com/mwQFd7G.jpeg', 'Hindi.jpeg')
16
 
17
- def draw_boxes(image, bounds, color='yellow', width=2):
18
  draw = ImageDraw.Draw(image)
19
  for bound in bounds:
20
  p0, p1, p2, p3 = bound[0]
@@ -23,7 +16,7 @@ def draw_boxes(image, bounds, color='yellow', width=2):
23
 
24
  def inference(img, lang):
25
  reader = easyocr.Reader(lang)
26
- bounds = reader.readtext(img)
27
  im = PIL.Image.open(img)
28
  draw_boxes(im, bounds)
29
  im.save('result.jpg')
 
6
  import torch
7
  import easyocr
8
 
 
 
 
 
 
 
 
9
 
10
+ def draw_boxes(image, bounds, color='green', width=2):
11
  draw = ImageDraw.Draw(image)
12
  for bound in bounds:
13
  p0, p1, p2, p3 = bound[0]
 
16
 
17
  def inference(img, lang):
18
  reader = easyocr.Reader(lang)
19
+ bounds = reader.readtext(img, paragraph = True)
20
  im = PIL.Image.open(img)
21
  draw_boxes(im, bounds)
22
  im.save('result.jpg')