Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
import easyocr
|
| 3 |
import torch
|
| 4 |
import PIL
|
|
@@ -6,7 +7,7 @@ from PIL import Image
|
|
| 6 |
from PIL import ImageDraw
|
| 7 |
|
| 8 |
|
| 9 |
-
def draw_boxes(image, bounds, color='blue', width=
|
| 10 |
draw = ImageDraw.Draw(image)
|
| 11 |
for bound in bounds:
|
| 12 |
p0, p1, p2, p3 = bound[0]
|
|
@@ -18,12 +19,14 @@ def detect(img, lang=['en']):
|
|
| 18 |
bounds = reader.readtext(img)
|
| 19 |
im = PIL.Image.open(img)
|
| 20 |
im_out=draw_boxes(im, bounds)
|
| 21 |
-
return im_out
|
| 22 |
|
| 23 |
with gr.Blocks() as robot:
|
| 24 |
im=gr.Image(type="filepath")
|
| 25 |
go_btn=gr.Button()
|
| 26 |
out_im=gr.Image()
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
| 29 |
robot.queue(concurrency_count=10).launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import pandas as pd
|
| 3 |
import easyocr
|
| 4 |
import torch
|
| 5 |
import PIL
|
|
|
|
| 7 |
from PIL import ImageDraw
|
| 8 |
|
| 9 |
|
| 10 |
+
def draw_boxes(image, bounds, color='blue', width=1):
|
| 11 |
draw = ImageDraw.Draw(image)
|
| 12 |
for bound in bounds:
|
| 13 |
p0, p1, p2, p3 = bound[0]
|
|
|
|
| 19 |
bounds = reader.readtext(img)
|
| 20 |
im = PIL.Image.open(img)
|
| 21 |
im_out=draw_boxes(im, bounds)
|
| 22 |
+
return im_out,pd.DataFrame(bounds).iloc[: , 1:],pd.DataFrame(bounds).iloc[: , 1:]
|
| 23 |
|
| 24 |
with gr.Blocks() as robot:
|
| 25 |
im=gr.Image(type="filepath")
|
| 26 |
go_btn=gr.Button()
|
| 27 |
out_im=gr.Image()
|
| 28 |
+
with gr.Row():
|
| 29 |
+
out_txt=gr.Textbox(lines=8)
|
| 30 |
+
data_f=gr.outputs.Dataframe(headers=['text', 'confidence'])]
|
| 31 |
+
go_btn.click(detect,im,[out_im,out_txt,data_f])
|
| 32 |
robot.queue(concurrency_count=10).launch()
|