JustKiddo commited on
Commit
e9c88a9
·
verified ·
1 Parent(s): 32427ff

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -2
app.py CHANGED
@@ -5,6 +5,8 @@ from PIL import ImageDraw
5
  import gradio as gr
6
  import torch
7
  import easyocr
 
 
8
 
9
  def draw_boxes(image, bounds, color='red', width=2):
10
  draw = ImageDraw.Draw(image)
@@ -19,14 +21,24 @@ def inference(img, lang):
19
  im = PIL.Image.open(img.name)
20
  draw_boxes(im, bounds)
21
  im.save('result.jpg')
 
 
 
22
  return ['result.jpg', pd.DataFrame(bounds).iloc[: , 1:]]
23
 
24
  choices = ["en", "vi"]
25
 
 
 
 
 
 
 
 
 
26
  gr.Interface(
27
  inference,
28
  inputs=[gr.Image(label='Input'),
29
  gr.CheckboxGroup(choices, type="value", label='language')],
30
- outputs=[gr.Image(label='Output'),
31
- gr.Dataframe(headers=['text', 'confidence'])]
32
  ).launch(debug=True)
 
5
  import gradio as gr
6
  import torch
7
  import easyocr
8
+ import io
9
+ import base64
10
 
11
  def draw_boxes(image, bounds, color='red', width=2):
12
  draw = ImageDraw.Draw(image)
 
21
  im = PIL.Image.open(img.name)
22
  draw_boxes(im, bounds)
23
  im.save('result.jpg')
24
+
25
+ #result_buffer = io.BytesIO()
26
+
27
  return ['result.jpg', pd.DataFrame(bounds).iloc[: , 1:]]
28
 
29
  choices = ["en", "vi"]
30
 
31
+ #gr.Interface(
32
+ # inference,
33
+ # inputs=[gr.Image(label='Input'),
34
+ # gr.CheckboxGroup(choices, type="value", label='language')],
35
+ # outputs=[gr.Image(label='Output'),
36
+ # gr.Dataframe(headers=['text', 'confidence'])]
37
+ # ).launch(debug=True)
38
+
39
  gr.Interface(
40
  inference,
41
  inputs=[gr.Image(label='Input'),
42
  gr.CheckboxGroup(choices, type="value", label='language')],
43
+ outputs=gr.Image(label='Output')
 
44
  ).launch(debug=True)