Ahsen Khaliq
commited on
Commit
·
0cd0b01
1
Parent(s):
511af04
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,16 +2,13 @@ from paddleocr import PaddleOCR,draw_ocr
|
|
| 2 |
from PIL import Image
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
-
# Paddleocr supports Chinese, English, French, German, Korean and Japanese.
|
| 6 |
-
# You can set the parameter `lang` as `ch`, `en`, `fr`, `german`, `korean`, `japan`
|
| 7 |
-
# to switch the language model in order.
|
| 8 |
ocr = PaddleOCR(use_angle_cls=True, lang='en') # need to run only once to download and load model into memory
|
| 9 |
def inference(img):
|
| 10 |
img_path = img.name
|
| 11 |
result = ocr.ocr(img_path, cls=True)
|
| 12 |
for line in result:
|
| 13 |
print(line)
|
| 14 |
-
|
| 15 |
# draw result
|
| 16 |
image = Image.open(img_path).convert('RGB')
|
| 17 |
boxes = [line[0] for line in result]
|
|
@@ -32,5 +29,4 @@ gr.Interface(
|
|
| 32 |
gr.outputs.Image(type="file", label="Output"),
|
| 33 |
title=title,
|
| 34 |
description=description,
|
| 35 |
-
article=article
|
| 36 |
-
).launch(debug=True)
|
|
|
|
| 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]
|
|
|
|
| 29 |
gr.outputs.Image(type="file", label="Output"),
|
| 30 |
title=title,
|
| 31 |
description=description,
|
| 32 |
+
article=article).launch(debug=True)
|
|
|