Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -5,8 +5,9 @@ from pathlib import Path
|
|
5 |
from typing import List, Union
|
6 |
|
7 |
import gradio as gr
|
8 |
-
import rapidocr
|
9 |
from omegaconf import OmegaConf
|
|
|
|
|
10 |
from rapidocr import (
|
11 |
EngineType,
|
12 |
LangCls,
|
@@ -23,6 +24,7 @@ def get_ocr_result(
|
|
23 |
text_score,
|
24 |
box_thresh,
|
25 |
unclip_ratio,
|
|
|
26 |
det_engine,
|
27 |
lang_det,
|
28 |
det_model_type,
|
@@ -46,6 +48,7 @@ def get_ocr_result(
|
|
46 |
|
47 |
ocr_engine = RapidOCR(
|
48 |
params={
|
|
|
49 |
"Det.engine_type": EngineType(det_engine),
|
50 |
"Det.lang_type": LangDet(lang_det),
|
51 |
"Det.model_type": ModelType(det_model_type),
|
@@ -95,6 +98,7 @@ def create_examples() -> List[List[Union[str, float]]]:
|
|
95 |
0.5,
|
96 |
0.5,
|
97 |
1.6,
|
|
|
98 |
EngineType.ONNXRUNTIME,
|
99 |
LangDet.CH,
|
100 |
ModelType.MOBILE,
|
@@ -115,6 +119,7 @@ def create_examples() -> List[List[Union[str, float]]]:
|
|
115 |
0.5,
|
116 |
0.5,
|
117 |
1.6,
|
|
|
118 |
EngineType.ONNXRUNTIME,
|
119 |
LangDet.CH,
|
120 |
ModelType.MOBILE,
|
@@ -135,6 +140,7 @@ def create_examples() -> List[List[Union[str, float]]]:
|
|
135 |
0.5,
|
136 |
0.5,
|
137 |
1.6,
|
|
|
138 |
EngineType.ONNXRUNTIME,
|
139 |
LangDet.CH,
|
140 |
ModelType.MOBILE,
|
@@ -155,6 +161,7 @@ def create_examples() -> List[List[Union[str, float]]]:
|
|
155 |
0.5,
|
156 |
0.5,
|
157 |
1.6,
|
|
|
158 |
EngineType.ONNXRUNTIME,
|
159 |
LangDet.MULTI,
|
160 |
ModelType.MOBILE,
|
@@ -175,6 +182,7 @@ def create_examples() -> List[List[Union[str, float]]]:
|
|
175 |
0.5,
|
176 |
0.5,
|
177 |
1.6,
|
|
|
178 |
EngineType.ONNXRUNTIME,
|
179 |
LangDet.MULTI,
|
180 |
ModelType.MOBILE,
|
@@ -199,6 +207,7 @@ def export_yaml(
|
|
199 |
text_score,
|
200 |
box_thresh,
|
201 |
unclip_ratio,
|
|
|
202 |
det_engine,
|
203 |
lang_det,
|
204 |
det_model_type,
|
@@ -219,6 +228,7 @@ def export_yaml(
|
|
219 |
|
220 |
params = {
|
221 |
"Global": {
|
|
|
222 |
"use_det": "use_det" in use_module,
|
223 |
"use_cls": "use_cls" in use_module,
|
224 |
"use_rec": "use_rec" in use_module,
|
@@ -311,6 +321,13 @@ with gr.Blocks(
|
|
311 |
step=0.1,
|
312 |
info="控制文本检测框的大小,值越大,检测框整体越大。在出现框截断文字的情况,调大该值。取值范围:[1.5, 2.0],默认值为1.6",
|
313 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
314 |
|
315 |
with gr.Row():
|
316 |
with gr.Row():
|
@@ -429,6 +446,7 @@ with gr.Blocks(
|
|
429 |
text_score,
|
430 |
box_thresh,
|
431 |
unclip_ratio,
|
|
|
432 |
det_engine,
|
433 |
lang_det,
|
434 |
det_model_type,
|
|
|
5 |
from typing import List, Union
|
6 |
|
7 |
import gradio as gr
|
|
|
8 |
from omegaconf import OmegaConf
|
9 |
+
|
10 |
+
import rapidocr
|
11 |
from rapidocr import (
|
12 |
EngineType,
|
13 |
LangCls,
|
|
|
24 |
text_score,
|
25 |
box_thresh,
|
26 |
unclip_ratio,
|
27 |
+
max_side_len,
|
28 |
det_engine,
|
29 |
lang_det,
|
30 |
det_model_type,
|
|
|
48 |
|
49 |
ocr_engine = RapidOCR(
|
50 |
params={
|
51 |
+
"Global.max_side_len": max_side_len,
|
52 |
"Det.engine_type": EngineType(det_engine),
|
53 |
"Det.lang_type": LangDet(lang_det),
|
54 |
"Det.model_type": ModelType(det_model_type),
|
|
|
98 |
0.5,
|
99 |
0.5,
|
100 |
1.6,
|
101 |
+
2000,
|
102 |
EngineType.ONNXRUNTIME,
|
103 |
LangDet.CH,
|
104 |
ModelType.MOBILE,
|
|
|
119 |
0.5,
|
120 |
0.5,
|
121 |
1.6,
|
122 |
+
2000,
|
123 |
EngineType.ONNXRUNTIME,
|
124 |
LangDet.CH,
|
125 |
ModelType.MOBILE,
|
|
|
140 |
0.5,
|
141 |
0.5,
|
142 |
1.6,
|
143 |
+
2000,
|
144 |
EngineType.ONNXRUNTIME,
|
145 |
LangDet.CH,
|
146 |
ModelType.MOBILE,
|
|
|
161 |
0.5,
|
162 |
0.5,
|
163 |
1.6,
|
164 |
+
2000,
|
165 |
EngineType.ONNXRUNTIME,
|
166 |
LangDet.MULTI,
|
167 |
ModelType.MOBILE,
|
|
|
182 |
0.5,
|
183 |
0.5,
|
184 |
1.6,
|
185 |
+
2000,
|
186 |
EngineType.ONNXRUNTIME,
|
187 |
LangDet.MULTI,
|
188 |
ModelType.MOBILE,
|
|
|
207 |
text_score,
|
208 |
box_thresh,
|
209 |
unclip_ratio,
|
210 |
+
max_side_len,
|
211 |
det_engine,
|
212 |
lang_det,
|
213 |
det_model_type,
|
|
|
228 |
|
229 |
params = {
|
230 |
"Global": {
|
231 |
+
"max_side_len": max_side_len,
|
232 |
"use_det": "use_det" in use_module,
|
233 |
"use_cls": "use_cls" in use_module,
|
234 |
"use_rec": "use_rec" in use_module,
|
|
|
321 |
step=0.1,
|
322 |
info="控制文本检测框的大小,值越大,检测框整体越大。在出现框截断文字的情况,调大该值。取值范围:[1.5, 2.0],默认值为1.6",
|
323 |
)
|
324 |
+
max_side_len = gr.Number(
|
325 |
+
value=2000,
|
326 |
+
label="max_side_len",
|
327 |
+
info="如果输入图像的最大边大于`max_side_len`,则会按宽高比,将最大边缩放到`max_side_len`。默认为2000px",
|
328 |
+
interactive=True,
|
329 |
+
minimum=20,
|
330 |
+
)
|
331 |
|
332 |
with gr.Row():
|
333 |
with gr.Row():
|
|
|
446 |
text_score,
|
447 |
box_thresh,
|
448 |
unclip_ratio,
|
449 |
+
max_side_len,
|
450 |
det_engine,
|
451 |
lang_det,
|
452 |
det_model_type,
|