Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -9,6 +9,7 @@ os.system('pip install paddleocr')
|
|
9 |
from paddleocr import PaddleOCR, draw_ocr
|
10 |
from PIL import Image
|
11 |
import torch
|
|
|
12 |
|
13 |
w_style="""
|
14 |
<style>
|
@@ -68,6 +69,10 @@ def fx6(img, lang):
|
|
68 |
im_show.save('result.jpg')
|
69 |
return 'result.jpg'
|
70 |
|
|
|
|
|
|
|
|
|
71 |
|
72 |
with demo:
|
73 |
gr.Markdown(
|
@@ -101,6 +106,11 @@ with demo:
|
|
101 |
ocr_input=[gr.Image(type='file', label='请提供你需要识别的照片'),gr.Dropdown(choices=['中文','英文','法文','德文','韩文','日文'], type="value", default='中文', label='请选择需要识别的语言')]
|
102 |
ocr_output=gr.Image(type='file', label='识别结果')
|
103 |
ocr_button = gr.Button("开始ocr识别")
|
|
|
|
|
|
|
|
|
|
|
104 |
|
105 |
tj_button.click(fx1, inputs=text_input, outputs=text_output)
|
106 |
cs_button.click(fx2, inputs=val_input, outputs=json_output,api_name="ghqj")
|
@@ -108,5 +118,6 @@ with demo:
|
|
108 |
tts_button.click(fx4, inputs=TS_input, outputs=audio_output)
|
109 |
pva_button.click(fx5, inputs=[],outputs=pva_output)
|
110 |
ocr_button.click(fx6,inputs=ocr_input,outputs=ocr_output)
|
|
|
111 |
|
112 |
demo.launch(enable_queue=True)
|
|
|
9 |
from paddleocr import PaddleOCR, draw_ocr
|
10 |
from PIL import Image
|
11 |
import torch
|
12 |
+
import re
|
13 |
|
14 |
w_style="""
|
15 |
<style>
|
|
|
69 |
im_show.save('result.jpg')
|
70 |
return 'result.jpg'
|
71 |
|
72 |
+
def fx7(x,y):
|
73 |
+
res=re.findall(r'{0}'.format(y),x)
|
74 |
+
return res
|
75 |
+
|
76 |
|
77 |
with demo:
|
78 |
gr.Markdown(
|
|
|
106 |
ocr_input=[gr.Image(type='file', label='请提供你需要识别的照片'),gr.Dropdown(choices=['中文','英文','法文','德文','韩文','日文'], type="value", default='中文', label='请选择需要识别的语言')]
|
107 |
ocr_output=gr.Image(type='file', label='识别结果')
|
108 |
ocr_button = gr.Button("开始ocr识别")
|
109 |
+
with gr.TabItem("正则处理"):
|
110 |
+
with gr.Column():
|
111 |
+
zz1_input = [gr.TextBox(placeholder='请输入测试字符串,如"畅心语文100,数学666,英语95.7"',label="请输入测试内容"),gr.TextBox(placeholder='请输入正则表达式,如"\d+"',label="请输入正则表达式")]
|
112 |
+
zz1_output = gr.Dataframe(label="输出正则匹配数据",show_label=True)
|
113 |
+
zz1_button = gr.Button("开始正则处理>>")
|
114 |
|
115 |
tj_button.click(fx1, inputs=text_input, outputs=text_output)
|
116 |
cs_button.click(fx2, inputs=val_input, outputs=json_output,api_name="ghqj")
|
|
|
118 |
tts_button.click(fx4, inputs=TS_input, outputs=audio_output)
|
119 |
pva_button.click(fx5, inputs=[],outputs=pva_output)
|
120 |
ocr_button.click(fx6,inputs=ocr_input,outputs=ocr_output)
|
121 |
+
zz1_button.click(fx7,inputs=zz1_input,outputs=zz1_output)
|
122 |
|
123 |
demo.launch(enable_queue=True)
|