Spaces:
Runtime error
Runtime error
Commit
•
03e24f2
0
Parent(s):
Duplicate from StarCore/PaddleOCR
Browse filesCo-authored-by: StarSpace <StarCore@users.noreply.huggingface.co>
- .gitattributes +35 -0
- README.md +13 -0
- app.py +34 -0
- pp_ocr.py +18 -0
- requirements.txt +3 -0
.gitattributes
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: PaddleOCR
|
3 |
+
emoji: 😻
|
4 |
+
colorFrom: purple
|
5 |
+
colorTo: indigo
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 3.40.1
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
duplicated_from: StarCore/PaddleOCR
|
11 |
+
---
|
12 |
+
|
13 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
from pp_ocr import inference_img, inference_json
|
4 |
+
|
5 |
+
title = "基于PP-OCRv3文本识别"
|
6 |
+
description = """
|
7 |
+
PaddleOCR是百度开源的超轻量级OCR模型库,提供了数十种文本检测、识别模型,旨在打造一套丰富、领先、实用的文字检测、识别模型/工具库。
|
8 |
+
> 项目地址:PaddleOCR github 地址: https://github.com/PaddlePaddle/PaddleOCR
|
9 |
+
"""
|
10 |
+
|
11 |
+
with gr.Blocks() as app:
|
12 |
+
gr.Markdown("<h1 style='text-align: center; margin-bottom: 1rem'>"
|
13 |
+
+ title
|
14 |
+
+ "</h1>")
|
15 |
+
gr.Markdown(description)
|
16 |
+
with gr.Tab("图片"):
|
17 |
+
with gr.Row():
|
18 |
+
with gr.Column():
|
19 |
+
img_input = gr.Image()
|
20 |
+
img_btn = gr.Button("识别")
|
21 |
+
with gr.Column():
|
22 |
+
img_output = gr.Image(label="Result")
|
23 |
+
with gr.Tab("JSON"):
|
24 |
+
with gr.Row():
|
25 |
+
with gr.Column():
|
26 |
+
json_input = gr.Image()
|
27 |
+
json_btn = gr.Button("识别")
|
28 |
+
with gr.Column():
|
29 |
+
json_output = gr.Json(label="Result")
|
30 |
+
|
31 |
+
img_btn.click(inference_img, inputs=img_input, outputs=img_output)
|
32 |
+
json_btn.click(inference_json, inputs=json_input, outputs=json_output)
|
33 |
+
|
34 |
+
app.launch()
|
pp_ocr.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import tempfile
|
2 |
+
import os
|
3 |
+
|
4 |
+
import paddlehub as hub
|
5 |
+
from PIL import Image
|
6 |
+
|
7 |
+
pp_ocrv3 = hub.Module(name="ch_pp-ocrv3")
|
8 |
+
|
9 |
+
def inference_img(img):
|
10 |
+
with tempfile.TemporaryDirectory() as tempdir_name:
|
11 |
+
pp_ocrv3.recognize_text(images=[img], use_gpu=False, output_dir=tempdir_name, visualization=True)
|
12 |
+
result_names = os.listdir(tempdir_name)
|
13 |
+
result_image = Image.open(os.path.join(tempdir_name, result_names[0]))
|
14 |
+
return result_image
|
15 |
+
|
16 |
+
def inference_json(img):
|
17 |
+
results = pp_ocrv3.recognize_text(images=[img], use_gpu=False, visualization=False)
|
18 |
+
return results
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
paddlepaddle==2.4.2
|
2 |
+
paddlehub
|
3 |
+
gradio
|