Ahsen Khaliq
commited on
Commit
·
6a0c8d4
1
Parent(s):
9705015
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,15 +1,12 @@
|
|
| 1 |
from paddleocr import PaddleOCR,draw_ocr
|
| 2 |
from PIL import Image
|
| 3 |
import gradio as gr
|
| 4 |
-
|
| 5 |
-
ocr = PaddleOCR(use_angle_cls=True, lang='en') # need to run only once to download and load model into memory
|
| 6 |
def inference(img):
|
| 7 |
img_path = img.name
|
| 8 |
result = ocr.ocr(img_path, cls=True)
|
| 9 |
for line in result:
|
| 10 |
print(line)
|
| 11 |
-
|
| 12 |
-
# draw result
|
| 13 |
image = Image.open(img_path).convert('RGB')
|
| 14 |
boxes = [line[0] for line in result]
|
| 15 |
txts = [line[1][0] for line in result]
|
|
@@ -25,7 +22,7 @@ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2104.057
|
|
| 25 |
|
| 26 |
gr.Interface(
|
| 27 |
inference,
|
| 28 |
-
|
| 29 |
gr.outputs.Image(type="file", label="Output"),
|
| 30 |
title=title,
|
| 31 |
description=description,
|
|
|
|
| 1 |
from paddleocr import PaddleOCR,draw_ocr
|
| 2 |
from PIL import Image
|
| 3 |
import gradio as gr
|
| 4 |
+
ocr = PaddleOCR(use_angle_cls=True, lang='en')
|
|
|
|
| 5 |
def inference(img):
|
| 6 |
img_path = img.name
|
| 7 |
result = ocr.ocr(img_path, cls=True)
|
| 8 |
for line in result:
|
| 9 |
print(line)
|
|
|
|
|
|
|
| 10 |
image = Image.open(img_path).convert('RGB')
|
| 11 |
boxes = [line[0] for line in result]
|
| 12 |
txts = [line[1][0] for line in result]
|
|
|
|
| 22 |
|
| 23 |
gr.Interface(
|
| 24 |
inference,
|
| 25 |
+
gr.inputs.Image(type="file", label="Input"),
|
| 26 |
gr.outputs.Image(type="file", label="Output"),
|
| 27 |
title=title,
|
| 28 |
description=description,
|