Spaces:
Runtime error
Runtime error
chenjian
commited on
Commit
·
72a603f
1
Parent(s):
7dec53a
add module files
Browse files- app.py +22 -0
- requirements.txt +3 -0
- test.png +0 -0
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import tempfile
|
2 |
+
import os
|
3 |
+
|
4 |
+
import gradio as gr
|
5 |
+
import paddlehub as hub
|
6 |
+
from PIL import Image
|
7 |
+
|
8 |
+
pp_ocrv3 = hub.Module(name="ch_pp-ocrv3")
|
9 |
+
|
10 |
+
def inference(img):
|
11 |
+
with tempfile.TemporaryDirectory() as tempdir_name:
|
12 |
+
pp_ocrv3.recognize_text(paths=[img],use_gpu=False,output_dir=tempdir_name,visualization=True)
|
13 |
+
result_names = os.listdir(tempdir_name)
|
14 |
+
output_image = Image.open(os.path.join(tempdir_name, result_names[0]))
|
15 |
+
return [output_image]
|
16 |
+
|
17 |
+
title="ch_pp-ocrv3"
|
18 |
+
description="ch_pp-ocrv3 is a practical ultra-lightweight OCR system developed by PaddleOCR."
|
19 |
+
|
20 |
+
examples=[['test.png']]
|
21 |
+
|
22 |
+
gr.Interface(inference,gr.inputs.Image(type="filepath"),outputs=[gr.Gallery(label="Result", show_label=False).style(grid=[1, 1], height="auto")],title=title,description=description,examples=examples).launch(enable_queue=True)
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
paddlepaddle
|
2 |
+
paddlehub
|
3 |
+
|
test.png
ADDED