Spaces:
Runtime error
Runtime error
ww
commited on
Commit
Β·
d3b92fb
1
Parent(s):
087a322
app.py
CHANGED
@@ -6,8 +6,24 @@ from PIL import Image
|
|
6 |
import gradio as gr
|
7 |
import torch
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
def greet(name):
|
10 |
return "Hello " + name + "!!"
|
11 |
|
12 |
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
13 |
-
iface.launch()
|
|
|
6 |
import gradio as gr
|
7 |
import torch
|
8 |
|
9 |
+
torch.hub.download_url_to_file('https://i.imgur.com/aqMBT0i.jpg', 'example.jpg')
|
10 |
+
|
11 |
+
def inference(img, lang):
|
12 |
+
ocr = PaddleOCR(use_angle_cls=True, lang=lang, use_gpu=False)
|
13 |
+
img_path = img.name
|
14 |
+
result = ocr.ocr(img_path, cls=True)[0]
|
15 |
+
image = Image.open(img_path).convert('RGB')
|
16 |
+
boxes = [line[0] for line in result]
|
17 |
+
txts = [line[1][0] for line in result]
|
18 |
+
scores = [line[1][1] for line in result]
|
19 |
+
im_show = draw_ocr(image, boxes, txts, scores,
|
20 |
+
font_path='simfang.ttf')
|
21 |
+
im_show = Image.fromarray(im_show)
|
22 |
+
im_show.save('result.jpg')
|
23 |
+
return 'result.jpg'
|
24 |
+
|
25 |
def greet(name):
|
26 |
return "Hello " + name + "!!"
|
27 |
|
28 |
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
29 |
+
iface.launch(share=True)
|