paddlex 3.0.2__py3-none-any.whl → 3.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- paddlex/.version +1 -1
- paddlex/configs/modules/text_recognition/eslav_PP-OCRv5_mobile_rec.yaml +39 -0
- paddlex/configs/modules/text_recognition/korean_PP-OCRv5_mobile_rec.yaml +39 -0
- paddlex/configs/modules/text_recognition/latin_PP-OCRv5_mobile_rec.yaml +39 -0
- paddlex/configs/pipelines/PP-DocTranslation.yaml +261 -0
- paddlex/inference/common/batch_sampler/__init__.py +1 -0
- paddlex/inference/common/batch_sampler/markdown_batch_sampler.py +116 -0
- paddlex/inference/common/result/base_cv_result.py +2 -3
- paddlex/inference/common/result/mixin.py +3 -1
- paddlex/inference/models/base/predictor/base_predictor.py +2 -0
- paddlex/inference/models/common/static_infer.py +2 -0
- paddlex/inference/models/common/vlm/generation/utils.py +2 -2
- paddlex/inference/models/formula_recognition/result.py +2 -2
- paddlex/inference/models/image_classification/result.py +3 -5
- paddlex/inference/models/image_multilabel_classification/result.py +2 -2
- paddlex/inference/models/object_detection/result.py +2 -2
- paddlex/inference/models/open_vocabulary_detection/processors/groundingdino_processors.py +3 -0
- paddlex/inference/models/text_recognition/predictor.py +51 -1
- paddlex/inference/models/text_recognition/result.py +5 -2
- paddlex/inference/models/video_classification/result.py +3 -3
- paddlex/inference/models/video_detection/result.py +2 -4
- paddlex/inference/pipelines/__init__.py +1 -0
- paddlex/inference/pipelines/attribute_recognition/result.py +2 -2
- paddlex/inference/pipelines/components/prompt_engineering/__init__.py +1 -0
- paddlex/inference/pipelines/components/prompt_engineering/generate_translate_prompt.py +179 -0
- paddlex/inference/pipelines/doc_preprocessor/result.py +2 -2
- paddlex/inference/pipelines/formula_recognition/result.py +2 -2
- paddlex/inference/pipelines/layout_parsing/pipeline_v2.py +2 -0
- paddlex/inference/pipelines/layout_parsing/result_v2.py +11 -4
- paddlex/inference/pipelines/ocr/pipeline.py +2 -0
- paddlex/inference/pipelines/ocr/result.py +11 -7
- paddlex/inference/pipelines/pp_doctranslation/__init__.py +15 -0
- paddlex/inference/pipelines/pp_doctranslation/pipeline.py +523 -0
- paddlex/inference/pipelines/pp_doctranslation/result.py +39 -0
- paddlex/inference/pipelines/pp_doctranslation/utils.py +260 -0
- paddlex/inference/pipelines/pp_shitu_v2/result.py +2 -2
- paddlex/inference/serving/basic_serving/_app.py +1 -0
- paddlex/inference/serving/basic_serving/_pipeline_apps/anomaly_detection.py +4 -2
- paddlex/inference/serving/basic_serving/_pipeline_apps/doc_preprocessor.py +5 -1
- paddlex/inference/serving/basic_serving/_pipeline_apps/face_recognition.py +4 -2
- paddlex/inference/serving/basic_serving/_pipeline_apps/formula_recognition.py +4 -2
- paddlex/inference/serving/basic_serving/_pipeline_apps/human_keypoint_detection.py +4 -2
- paddlex/inference/serving/basic_serving/_pipeline_apps/image_classification.py +4 -2
- paddlex/inference/serving/basic_serving/_pipeline_apps/image_multilabel_classification.py +4 -2
- paddlex/inference/serving/basic_serving/_pipeline_apps/instance_segmentation.py +4 -2
- paddlex/inference/serving/basic_serving/_pipeline_apps/layout_parsing.py +4 -2
- paddlex/inference/serving/basic_serving/_pipeline_apps/object_detection.py +4 -2
- paddlex/inference/serving/basic_serving/_pipeline_apps/ocr.py +4 -2
- paddlex/inference/serving/basic_serving/_pipeline_apps/open_vocabulary_detection.py +4 -2
- paddlex/inference/serving/basic_serving/_pipeline_apps/open_vocabulary_segmentation.py +4 -2
- paddlex/inference/serving/basic_serving/_pipeline_apps/pedestrian_attribute_recognition.py +4 -2
- paddlex/inference/serving/basic_serving/_pipeline_apps/pp_chatocrv3_doc.py +14 -24
- paddlex/inference/serving/basic_serving/_pipeline_apps/pp_chatocrv4_doc.py +16 -26
- paddlex/inference/serving/basic_serving/_pipeline_apps/pp_doctranslation.py +203 -0
- paddlex/inference/serving/basic_serving/_pipeline_apps/pp_shituv2.py +4 -2
- paddlex/inference/serving/basic_serving/_pipeline_apps/pp_structurev3.py +4 -2
- paddlex/inference/serving/basic_serving/_pipeline_apps/rotated_object_detection.py +4 -2
- paddlex/inference/serving/basic_serving/_pipeline_apps/seal_recognition.py +4 -2
- paddlex/inference/serving/basic_serving/_pipeline_apps/semantic_segmentation.py +4 -2
- paddlex/inference/serving/basic_serving/_pipeline_apps/small_object_detection.py +4 -2
- paddlex/inference/serving/basic_serving/_pipeline_apps/table_recognition.py +4 -2
- paddlex/inference/serving/basic_serving/_pipeline_apps/table_recognition_v2.py +4 -2
- paddlex/inference/serving/basic_serving/_pipeline_apps/ts_anomaly_detection.py +4 -2
- paddlex/inference/serving/basic_serving/_pipeline_apps/ts_classification.py +4 -2
- paddlex/inference/serving/basic_serving/_pipeline_apps/ts_forecast.py +4 -2
- paddlex/inference/serving/basic_serving/_pipeline_apps/vehicle_attribute_recognition.py +4 -2
- paddlex/inference/serving/infra/utils.py +22 -17
- paddlex/inference/serving/schemas/anomaly_detection.py +1 -0
- paddlex/inference/serving/schemas/doc_preprocessor.py +1 -0
- paddlex/inference/serving/schemas/face_recognition.py +1 -0
- paddlex/inference/serving/schemas/formula_recognition.py +1 -0
- paddlex/inference/serving/schemas/human_keypoint_detection.py +1 -0
- paddlex/inference/serving/schemas/image_classification.py +1 -0
- paddlex/inference/serving/schemas/image_multilabel_classification.py +1 -0
- paddlex/inference/serving/schemas/instance_segmentation.py +1 -0
- paddlex/inference/serving/schemas/layout_parsing.py +1 -0
- paddlex/inference/serving/schemas/object_detection.py +1 -0
- paddlex/inference/serving/schemas/ocr.py +1 -0
- paddlex/inference/serving/schemas/open_vocabulary_detection.py +1 -0
- paddlex/inference/serving/schemas/open_vocabulary_segmentation.py +1 -0
- paddlex/inference/serving/schemas/pedestrian_attribute_recognition.py +1 -0
- paddlex/inference/serving/schemas/pp_chatocrv3_doc.py +5 -4
- paddlex/inference/serving/schemas/pp_chatocrv4_doc.py +6 -5
- paddlex/inference/serving/schemas/pp_doctranslation.py +115 -0
- paddlex/inference/serving/schemas/pp_shituv2.py +1 -0
- paddlex/inference/serving/schemas/pp_structurev3.py +2 -9
- paddlex/inference/serving/schemas/rotated_object_detection.py +1 -0
- paddlex/inference/serving/schemas/seal_recognition.py +1 -0
- paddlex/inference/serving/schemas/semantic_segmentation.py +1 -0
- paddlex/inference/serving/schemas/shared/ocr.py +8 -1
- paddlex/inference/serving/schemas/small_object_detection.py +1 -0
- paddlex/inference/serving/schemas/table_recognition.py +1 -0
- paddlex/inference/serving/schemas/table_recognition_v2.py +1 -0
- paddlex/inference/serving/schemas/ts_anomaly_detection.py +1 -0
- paddlex/inference/serving/schemas/ts_classification.py +1 -0
- paddlex/inference/serving/schemas/ts_forecast.py +1 -0
- paddlex/inference/serving/schemas/vehicle_attribute_recognition.py +1 -0
- paddlex/inference/utils/hpi.py +42 -14
- paddlex/inference/utils/hpi_model_info_collection.json +0 -2
- paddlex/inference/utils/io/__init__.py +1 -0
- paddlex/inference/utils/io/readers.py +46 -0
- paddlex/inference/utils/io/writers.py +2 -0
- paddlex/inference/utils/official_models.py +7 -0
- paddlex/inference/utils/pp_option.py +34 -18
- paddlex/modules/anomaly_detection/dataset_checker/dataset_src/convert_dataset.py +2 -2
- paddlex/modules/face_recognition/dataset_checker/dataset_src/utils/visualizer.py +3 -3
- paddlex/modules/formula_recognition/dataset_checker/dataset_src/analyse_dataset.py +2 -2
- paddlex/modules/general_recognition/dataset_checker/dataset_src/analyse_dataset.py +2 -2
- paddlex/modules/general_recognition/dataset_checker/dataset_src/utils/visualizer.py +3 -3
- paddlex/modules/image_classification/dataset_checker/dataset_src/analyse_dataset.py +2 -2
- paddlex/modules/image_classification/dataset_checker/dataset_src/utils/visualizer.py +3 -3
- paddlex/modules/instance_segmentation/dataset_checker/dataset_src/analyse_dataset.py +2 -2
- paddlex/modules/instance_segmentation/dataset_checker/dataset_src/utils/visualizer.py +2 -2
- paddlex/modules/m_3d_bev_detection/dataset_checker/dataset_src/analyse_dataset.py +2 -2
- paddlex/modules/multilabel_classification/dataset_checker/dataset_src/analyse_dataset.py +2 -2
- paddlex/modules/multilabel_classification/dataset_checker/dataset_src/utils/visualizer.py +2 -2
- paddlex/modules/object_detection/dataset_checker/dataset_src/analyse_dataset.py +2 -2
- paddlex/modules/object_detection/dataset_checker/dataset_src/utils/visualizer.py +2 -2
- paddlex/modules/text_recognition/dataset_checker/dataset_src/analyse_dataset.py +2 -2
- paddlex/modules/text_recognition/model_list.py +3 -0
- paddlex/modules/ts_classification/dataset_checker/dataset_src/analyse_dataset.py +2 -2
- paddlex/modules/video_classification/dataset_checker/dataset_src/analyse_dataset.py +2 -2
- paddlex/modules/video_detection/dataset_checker/dataset_src/analyse_dataset.py +2 -2
- paddlex/repo_apis/PaddleOCR_api/text_rec/register.py +27 -0
- paddlex/repo_manager/meta.py +3 -3
- paddlex/utils/device.py +4 -1
- paddlex/utils/download.py +10 -7
- paddlex/utils/{fonts/__init__.py → fonts.py} +45 -26
- {paddlex-3.0.2.dist-info → paddlex-3.1.0.dist-info}/METADATA +25 -1
- {paddlex-3.0.2.dist-info → paddlex-3.1.0.dist-info}/RECORD +134 -122
- {paddlex-3.0.2.dist-info → paddlex-3.1.0.dist-info}/LICENSE +0 -0
- {paddlex-3.0.2.dist-info → paddlex-3.1.0.dist-info}/WHEEL +0 -0
- {paddlex-3.0.2.dist-info → paddlex-3.1.0.dist-info}/entry_points.txt +0 -0
- {paddlex-3.0.2.dist-info → paddlex-3.1.0.dist-info}/top_level.txt +0 -0
@@ -69,6 +69,7 @@ class PaddlePredictorOption(object):
|
|
69
69
|
|
70
70
|
def __init__(self, model_name=None, **kwargs):
|
71
71
|
super().__init__()
|
72
|
+
self._is_default_run_mode = True
|
72
73
|
self._model_name = model_name
|
73
74
|
self._cfg = {}
|
74
75
|
self._init_option(**kwargs)
|
@@ -106,6 +107,10 @@ class PaddlePredictorOption(object):
|
|
106
107
|
raise Exception(
|
107
108
|
f"{k} is not supported to set! The supported option is: {self._get_settable_attributes()}"
|
108
109
|
)
|
110
|
+
|
111
|
+
if "run_mode" in self._cfg:
|
112
|
+
self._is_default_run_mode = False
|
113
|
+
|
109
114
|
for k, v in self._get_default_config().items():
|
110
115
|
self._cfg.setdefault(k, v)
|
111
116
|
|
@@ -122,12 +127,16 @@ class PaddlePredictorOption(object):
|
|
122
127
|
|
123
128
|
def _get_default_config(self):
|
124
129
|
"""get default config"""
|
125
|
-
device_type
|
130
|
+
if self.device_type is None:
|
131
|
+
device_type, device_ids = parse_device(get_default_device())
|
132
|
+
device_id = None if device_ids is None else device_ids[0]
|
133
|
+
else:
|
134
|
+
device_type, device_id = self.device_type, self.device_id
|
126
135
|
|
127
136
|
default_config = {
|
128
137
|
"run_mode": get_default_run_mode(self.model_name, device_type),
|
129
138
|
"device_type": device_type,
|
130
|
-
"device_id":
|
139
|
+
"device_id": device_id,
|
131
140
|
"cpu_threads": 8,
|
132
141
|
"delete_pass": [],
|
133
142
|
"enable_new_ir": True if self.model_name not in NEWIR_BLOCKLIST else False,
|
@@ -148,9 +157,15 @@ class PaddlePredictorOption(object):
|
|
148
157
|
self._cfg[k] = v
|
149
158
|
self.changed = True
|
150
159
|
|
160
|
+
def reset_run_mode_by_default(self, model_name=None, device_type=None):
|
161
|
+
if self._is_default_run_mode:
|
162
|
+
model_name = model_name or self.model_name
|
163
|
+
device_type = device_type or self.device_type
|
164
|
+
self._update("run_mode", get_default_run_mode(model_name, device_type))
|
165
|
+
|
151
166
|
@property
|
152
167
|
def run_mode(self):
|
153
|
-
return self._cfg
|
168
|
+
return self._cfg.get("run_mode")
|
154
169
|
|
155
170
|
@run_mode.setter
|
156
171
|
def run_mode(self, run_mode: str):
|
@@ -189,11 +204,12 @@ class PaddlePredictorOption(object):
|
|
189
204
|
)
|
190
205
|
run_mode = "paddle"
|
191
206
|
|
207
|
+
self._is_default_run_mode = False
|
192
208
|
self._update("run_mode", run_mode)
|
193
209
|
|
194
210
|
@property
|
195
211
|
def device_type(self):
|
196
|
-
return self._cfg
|
212
|
+
return self._cfg.get("device_type")
|
197
213
|
|
198
214
|
@device_type.setter
|
199
215
|
def device_type(self, device_type):
|
@@ -211,7 +227,7 @@ class PaddlePredictorOption(object):
|
|
211
227
|
|
212
228
|
@property
|
213
229
|
def device_id(self):
|
214
|
-
return self._cfg
|
230
|
+
return self._cfg.get("device_id")
|
215
231
|
|
216
232
|
@device_id.setter
|
217
233
|
def device_id(self, device_id):
|
@@ -219,7 +235,7 @@ class PaddlePredictorOption(object):
|
|
219
235
|
|
220
236
|
@property
|
221
237
|
def cpu_threads(self):
|
222
|
-
return self._cfg
|
238
|
+
return self._cfg.get("cpu_threads")
|
223
239
|
|
224
240
|
@cpu_threads.setter
|
225
241
|
def cpu_threads(self, cpu_threads):
|
@@ -230,7 +246,7 @@ class PaddlePredictorOption(object):
|
|
230
246
|
|
231
247
|
@property
|
232
248
|
def delete_pass(self):
|
233
|
-
return self._cfg
|
249
|
+
return self._cfg.get("delete_pass")
|
234
250
|
|
235
251
|
@delete_pass.setter
|
236
252
|
def delete_pass(self, delete_pass):
|
@@ -238,7 +254,7 @@ class PaddlePredictorOption(object):
|
|
238
254
|
|
239
255
|
@property
|
240
256
|
def enable_new_ir(self):
|
241
|
-
return self._cfg
|
257
|
+
return self._cfg.get("enable_new_ir")
|
242
258
|
|
243
259
|
@enable_new_ir.setter
|
244
260
|
def enable_new_ir(self, enable_new_ir: bool):
|
@@ -247,7 +263,7 @@ class PaddlePredictorOption(object):
|
|
247
263
|
|
248
264
|
@property
|
249
265
|
def enable_cinn(self):
|
250
|
-
return self._cfg
|
266
|
+
return self._cfg.get("enable_cinn")
|
251
267
|
|
252
268
|
@enable_cinn.setter
|
253
269
|
def enable_cinn(self, enable_cinn: bool):
|
@@ -256,7 +272,7 @@ class PaddlePredictorOption(object):
|
|
256
272
|
|
257
273
|
@property
|
258
274
|
def trt_cfg_setting(self):
|
259
|
-
return self._cfg
|
275
|
+
return self._cfg.get("trt_cfg_setting")
|
260
276
|
|
261
277
|
@trt_cfg_setting.setter
|
262
278
|
def trt_cfg_setting(self, config: Dict):
|
@@ -268,7 +284,7 @@ class PaddlePredictorOption(object):
|
|
268
284
|
|
269
285
|
@property
|
270
286
|
def trt_use_dynamic_shapes(self):
|
271
|
-
return self._cfg
|
287
|
+
return self._cfg.get("trt_use_dynamic_shapes")
|
272
288
|
|
273
289
|
@trt_use_dynamic_shapes.setter
|
274
290
|
def trt_use_dynamic_shapes(self, trt_use_dynamic_shapes):
|
@@ -276,7 +292,7 @@ class PaddlePredictorOption(object):
|
|
276
292
|
|
277
293
|
@property
|
278
294
|
def trt_collect_shape_range_info(self):
|
279
|
-
return self._cfg
|
295
|
+
return self._cfg.get("trt_collect_shape_range_info")
|
280
296
|
|
281
297
|
@trt_collect_shape_range_info.setter
|
282
298
|
def trt_collect_shape_range_info(self, trt_collect_shape_range_info):
|
@@ -284,7 +300,7 @@ class PaddlePredictorOption(object):
|
|
284
300
|
|
285
301
|
@property
|
286
302
|
def trt_discard_cached_shape_range_info(self):
|
287
|
-
return self._cfg
|
303
|
+
return self._cfg.get("trt_discard_cached_shape_range_info")
|
288
304
|
|
289
305
|
@trt_discard_cached_shape_range_info.setter
|
290
306
|
def trt_discard_cached_shape_range_info(self, trt_discard_cached_shape_range_info):
|
@@ -294,7 +310,7 @@ class PaddlePredictorOption(object):
|
|
294
310
|
|
295
311
|
@property
|
296
312
|
def trt_dynamic_shapes(self):
|
297
|
-
return self._cfg
|
313
|
+
return self._cfg.get("trt_dynamic_shapes")
|
298
314
|
|
299
315
|
@trt_dynamic_shapes.setter
|
300
316
|
def trt_dynamic_shapes(self, trt_dynamic_shapes: Dict[str, List[List[int]]]):
|
@@ -305,7 +321,7 @@ class PaddlePredictorOption(object):
|
|
305
321
|
|
306
322
|
@property
|
307
323
|
def trt_dynamic_shape_input_data(self):
|
308
|
-
return self._cfg
|
324
|
+
return self._cfg.get("trt_dynamic_shape_input_data")
|
309
325
|
|
310
326
|
@trt_dynamic_shape_input_data.setter
|
311
327
|
def trt_dynamic_shape_input_data(
|
@@ -315,7 +331,7 @@ class PaddlePredictorOption(object):
|
|
315
331
|
|
316
332
|
@property
|
317
333
|
def trt_shape_range_info_path(self):
|
318
|
-
return self._cfg
|
334
|
+
return self._cfg.get("trt_shape_range_info_path")
|
319
335
|
|
320
336
|
@trt_shape_range_info_path.setter
|
321
337
|
def trt_shape_range_info_path(self, trt_shape_range_info_path: str):
|
@@ -324,7 +340,7 @@ class PaddlePredictorOption(object):
|
|
324
340
|
|
325
341
|
@property
|
326
342
|
def trt_allow_rebuild_at_runtime(self):
|
327
|
-
return self._cfg
|
343
|
+
return self._cfg.get("trt_allow_rebuild_at_runtime")
|
328
344
|
|
329
345
|
@trt_allow_rebuild_at_runtime.setter
|
330
346
|
def trt_allow_rebuild_at_runtime(self, trt_allow_rebuild_at_runtime):
|
@@ -332,7 +348,7 @@ class PaddlePredictorOption(object):
|
|
332
348
|
|
333
349
|
@property
|
334
350
|
def mkldnn_cache_capacity(self):
|
335
|
-
return self._cfg
|
351
|
+
return self._cfg.get("mkldnn_cache_capacity")
|
336
352
|
|
337
353
|
@mkldnn_cache_capacity.setter
|
338
354
|
def mkldnn_cache_capacity(self, capacity: int):
|
@@ -100,9 +100,9 @@ def convert_labelme_dataset(input_dir):
|
|
100
100
|
if not os.path.exists(img_path):
|
101
101
|
logging.info("%s is not existed, skip this image" % img_path)
|
102
102
|
continue
|
103
|
-
img_name =
|
103
|
+
img_name = osp.basename(img_path)
|
104
104
|
img_file_list.append(f"images/{img_name}")
|
105
|
-
label_img_name =
|
105
|
+
label_img_name = osp.basename(annotated_img_path)
|
106
106
|
label_file_list.append(f"annotations/{label_img_name}")
|
107
107
|
|
108
108
|
img = np.asarray(cv2.imread(img_path))
|
@@ -16,7 +16,7 @@ import numpy as np
|
|
16
16
|
import PIL
|
17
17
|
from PIL import ImageDraw, ImageFont
|
18
18
|
|
19
|
-
from ......utils.fonts import
|
19
|
+
from ......utils.fonts import PINGFANG_FONT
|
20
20
|
|
21
21
|
|
22
22
|
def colormap(rgb=False):
|
@@ -114,7 +114,7 @@ def draw_label(image, label, label_map_dict):
|
|
114
114
|
min_font_size = int(image_size[0] * 0.02)
|
115
115
|
max_font_size = int(image_size[0] * 0.05)
|
116
116
|
for font_size in range(max_font_size, min_font_size - 1, -1):
|
117
|
-
font = ImageFont.truetype(
|
117
|
+
font = ImageFont.truetype(PINGFANG_FONT.path, font_size, encoding="utf-8")
|
118
118
|
if tuple(map(int, PIL.__version__.split("."))) <= (10, 0, 0):
|
119
119
|
text_width_tmp, text_height_tmp = draw.textsize(
|
120
120
|
label_map_dict[int(label)], font
|
@@ -127,7 +127,7 @@ def draw_label(image, label, label_map_dict):
|
|
127
127
|
if text_width_tmp <= image_size[0]:
|
128
128
|
break
|
129
129
|
else:
|
130
|
-
font = ImageFont.truetype(
|
130
|
+
font = ImageFont.truetype(PINGFANG_FONT.path, min_font_size)
|
131
131
|
color_list = colormap(rgb=True)
|
132
132
|
color = tuple(color_list[0])
|
133
133
|
font_color = tuple(font_colormap(3))
|
@@ -22,7 +22,7 @@ import numpy as np
|
|
22
22
|
|
23
23
|
from .....utils.deps import function_requires_deps, is_dep_available
|
24
24
|
from .....utils.file_interface import custom_open
|
25
|
-
from .....utils.fonts import
|
25
|
+
from .....utils.fonts import PINGFANG_FONT
|
26
26
|
from .....utils.logging import warning
|
27
27
|
|
28
28
|
if is_dep_available("opencv-contrib-python"):
|
@@ -128,7 +128,7 @@ def deep_analyse(dataset_path, output, datatype="FormulaRecDataset"):
|
|
128
128
|
if os_system == "windows":
|
129
129
|
plt.rcParams["font.sans-serif"] = "FangSong"
|
130
130
|
else:
|
131
|
-
font = font_manager.FontProperties(fname=
|
131
|
+
font = font_manager.FontProperties(fname=PINGFANG_FONT.path, size=15)
|
132
132
|
|
133
133
|
fig, ax = plt.subplots(figsize=(15, 9), dpi=120)
|
134
134
|
xlabel_name = "公式长度区间"
|
@@ -19,7 +19,7 @@ import numpy as np
|
|
19
19
|
|
20
20
|
from .....utils.deps import function_requires_deps, is_dep_available
|
21
21
|
from .....utils.file_interface import custom_open
|
22
|
-
from .....utils.fonts import
|
22
|
+
from .....utils.fonts import PINGFANG_FONT
|
23
23
|
|
24
24
|
if is_dep_available("matplotlib"):
|
25
25
|
import matplotlib.pyplot as plt
|
@@ -52,7 +52,7 @@ def deep_analyse(dataset_path, output, dataset_type="ShiTuRec"):
|
|
52
52
|
if os_system == "windows":
|
53
53
|
plt.rcParams["font.sans-serif"] = "FangSong"
|
54
54
|
else:
|
55
|
-
font = font_manager.FontProperties(fname=
|
55
|
+
font = font_manager.FontProperties(fname=PINGFANG_FONT.path, size=10)
|
56
56
|
|
57
57
|
x = np.arange(len(categories)) # 标签位置
|
58
58
|
width = 0.35 # 每个条形的宽度
|
@@ -16,7 +16,7 @@ import numpy as np
|
|
16
16
|
import PIL
|
17
17
|
from PIL import ImageDraw, ImageFont
|
18
18
|
|
19
|
-
from ......utils.fonts import
|
19
|
+
from ......utils.fonts import PINGFANG_FONT
|
20
20
|
|
21
21
|
|
22
22
|
def colormap(rgb=False):
|
@@ -114,7 +114,7 @@ def draw_label(image, label):
|
|
114
114
|
min_font_size = int(image_size[0] * 0.02)
|
115
115
|
max_font_size = int(image_size[0] * 0.05)
|
116
116
|
for font_size in range(max_font_size, min_font_size - 1, -1):
|
117
|
-
font = ImageFont.truetype(
|
117
|
+
font = ImageFont.truetype(PINGFANG_FONT.path, font_size, encoding="utf-8")
|
118
118
|
if tuple(map(int, PIL.__version__.split("."))) <= (10, 0, 0):
|
119
119
|
text_width_tmp, text_height_tmp = draw.textsize(label, font)
|
120
120
|
else:
|
@@ -123,7 +123,7 @@ def draw_label(image, label):
|
|
123
123
|
if text_width_tmp <= image_size[0]:
|
124
124
|
break
|
125
125
|
else:
|
126
|
-
font = ImageFont.truetype(
|
126
|
+
font = ImageFont.truetype(PINGFANG_FONT.path, min_font_size)
|
127
127
|
color_list = colormap(rgb=True)
|
128
128
|
color = tuple(color_list[0])
|
129
129
|
font_color = tuple(font_colormap(3))
|
@@ -20,7 +20,7 @@ import numpy as np
|
|
20
20
|
|
21
21
|
from .....utils.deps import function_requires_deps, is_dep_available
|
22
22
|
from .....utils.file_interface import custom_open
|
23
|
-
from .....utils.fonts import
|
23
|
+
from .....utils.fonts import PINGFANG_FONT
|
24
24
|
|
25
25
|
if is_dep_available("matplotlib"):
|
26
26
|
import matplotlib.pyplot as plt
|
@@ -68,7 +68,7 @@ def deep_analyse(dataset_path, output):
|
|
68
68
|
if os_system == "windows":
|
69
69
|
plt.rcParams["font.sans-serif"] = "FangSong"
|
70
70
|
else:
|
71
|
-
font = font_manager.FontProperties(fname=
|
71
|
+
font = font_manager.FontProperties(fname=PINGFANG_FONT.path, size=10)
|
72
72
|
fig, ax = plt.subplots(figsize=(max(8, int(len(classes) / 5)), 5), dpi=300)
|
73
73
|
ax.bar(x, cnts_train_sorted, width=0.5, label="train")
|
74
74
|
ax.bar(x + width, cnts_val_sorted, width=0.5, label="val")
|
@@ -16,7 +16,7 @@ import numpy as np
|
|
16
16
|
import PIL
|
17
17
|
from PIL import ImageDraw, ImageFont
|
18
18
|
|
19
|
-
from ......utils.fonts import
|
19
|
+
from ......utils.fonts import PINGFANG_FONT
|
20
20
|
|
21
21
|
|
22
22
|
def colormap(rgb=False):
|
@@ -114,7 +114,7 @@ def draw_label(image, label, label_map_dict):
|
|
114
114
|
min_font_size = int(image_size[0] * 0.02)
|
115
115
|
max_font_size = int(image_size[0] * 0.05)
|
116
116
|
for font_size in range(max_font_size, min_font_size - 1, -1):
|
117
|
-
font = ImageFont.truetype(
|
117
|
+
font = ImageFont.truetype(PINGFANG_FONT.path, font_size, encoding="utf-8")
|
118
118
|
if tuple(map(int, PIL.__version__.split("."))) <= (10, 0, 0):
|
119
119
|
text_width_tmp, text_height_tmp = draw.textsize(
|
120
120
|
label_map_dict[int(label)], font
|
@@ -127,7 +127,7 @@ def draw_label(image, label, label_map_dict):
|
|
127
127
|
if text_width_tmp <= image_size[0]:
|
128
128
|
break
|
129
129
|
else:
|
130
|
-
font = ImageFont.truetype(
|
130
|
+
font = ImageFont.truetype(PINGFANG_FONT.path, min_font_size)
|
131
131
|
color_list = colormap(rgb=True)
|
132
132
|
color = tuple(color_list[0])
|
133
133
|
font_color = tuple(font_colormap(3))
|
@@ -20,7 +20,7 @@ from collections import defaultdict
|
|
20
20
|
import numpy as np
|
21
21
|
|
22
22
|
from .....utils.deps import function_requires_deps, is_dep_available
|
23
|
-
from .....utils.fonts import
|
23
|
+
from .....utils.fonts import PINGFANG_FONT
|
24
24
|
|
25
25
|
if is_dep_available("matplotlib"):
|
26
26
|
import matplotlib.pyplot as plt
|
@@ -64,7 +64,7 @@ def deep_analyse(dataset_dir, output):
|
|
64
64
|
if os_system == "windows":
|
65
65
|
plt.rcParams["font.sans-serif"] = "FangSong"
|
66
66
|
else:
|
67
|
-
font = font_manager.FontProperties(fname=
|
67
|
+
font = font_manager.FontProperties(fname=PINGFANG_FONT.path)
|
68
68
|
fig, ax = plt.subplots(figsize=(max(8, int(len(classes) / 5)), 5), dpi=120)
|
69
69
|
ax.bar(x, cnts_train_sorted, width=0.5, label="train")
|
70
70
|
ax.bar(x + width, cnts_val_sorted, width=0.5, label="val")
|
@@ -18,7 +18,7 @@ from PIL import Image, ImageDraw, ImageFont
|
|
18
18
|
|
19
19
|
from ......utils import logging
|
20
20
|
from ......utils.deps import function_requires_deps, is_dep_available
|
21
|
-
from ......utils.fonts import
|
21
|
+
from ......utils.fonts import PINGFANG_FONT
|
22
22
|
|
23
23
|
if is_dep_available("pycocotools"):
|
24
24
|
from pycocotools.coco import COCO
|
@@ -124,7 +124,7 @@ def draw_bbox(image, coco_info: "COCO", img_id):
|
|
124
124
|
font_size = int(0.024 * int(image_info["width"])) + 2
|
125
125
|
except:
|
126
126
|
font_size = 12
|
127
|
-
font = ImageFont.truetype(
|
127
|
+
font = ImageFont.truetype(PINGFANG_FONT.path, font_size, encoding="utf-8")
|
128
128
|
|
129
129
|
image = image.convert("RGB")
|
130
130
|
draw = ImageDraw.Draw(image)
|
@@ -21,7 +21,7 @@ from collections import defaultdict
|
|
21
21
|
import numpy as np
|
22
22
|
|
23
23
|
from paddlex.utils.deps import function_requires_deps, is_dep_available
|
24
|
-
from paddlex.utils.fonts import
|
24
|
+
from paddlex.utils.fonts import PINGFANG_FONT
|
25
25
|
|
26
26
|
if is_dep_available("matplotlib"):
|
27
27
|
import matplotlib.pyplot as plt
|
@@ -88,7 +88,7 @@ def deep_analyse(dataset_dir, output):
|
|
88
88
|
if os_system == "windows":
|
89
89
|
plt.rcParams["font.sans-serif"] = "FangSong"
|
90
90
|
else:
|
91
|
-
font = font_manager.FontProperties(fname=
|
91
|
+
font = font_manager.FontProperties(fname=PINGFANG_FONT.path)
|
92
92
|
fig, ax = plt.subplots(figsize=(max(8, int(len(classes) / 5)), 5), dpi=120)
|
93
93
|
ax.bar(x, cnts_train_sorted, width=0.5, label="train")
|
94
94
|
ax.bar(x + width, cnts_val_sorted, width=0.5, label="val")
|
@@ -20,7 +20,7 @@ import numpy as np
|
|
20
20
|
|
21
21
|
from .....utils.deps import function_requires_deps, is_dep_available
|
22
22
|
from .....utils.file_interface import custom_open
|
23
|
-
from .....utils.fonts import
|
23
|
+
from .....utils.fonts import PINGFANG_FONT
|
24
24
|
|
25
25
|
if is_dep_available("matplotlib"):
|
26
26
|
import matplotlib.pyplot as plt
|
@@ -70,7 +70,7 @@ def deep_analyse(dataset_path, output):
|
|
70
70
|
if os_system == "windows":
|
71
71
|
plt.rcParams["font.sans-serif"] = "FangSong"
|
72
72
|
else:
|
73
|
-
font = font_manager.FontProperties(fname=
|
73
|
+
font = font_manager.FontProperties(fname=PINGFANG_FONT.path, size=10)
|
74
74
|
fig, ax = plt.subplots(figsize=(max(8, int(len(classes) / 5)), 5), dpi=300)
|
75
75
|
ax.bar(x, cnts_train_sorted, width=0.5, label="train")
|
76
76
|
ax.bar(x + width, cnts_val_sorted, width=0.5, label="val")
|
@@ -15,7 +15,7 @@
|
|
15
15
|
import numpy as np
|
16
16
|
from PIL import Image, ImageDraw, ImageFont
|
17
17
|
|
18
|
-
from ......utils.fonts import
|
18
|
+
from ......utils.fonts import PINGFANG_FONT
|
19
19
|
|
20
20
|
|
21
21
|
def colormap(rgb=False):
|
@@ -114,7 +114,7 @@ def draw_multi_label(image, label, label_map_dict):
|
|
114
114
|
image_width, image_height = image.size
|
115
115
|
font_size = int(image_width * 0.06)
|
116
116
|
|
117
|
-
font = ImageFont.truetype(
|
117
|
+
font = ImageFont.truetype(PINGFANG_FONT.path, font_size)
|
118
118
|
text_lines = []
|
119
119
|
row_width = 0
|
120
120
|
row_height = 0
|
@@ -20,7 +20,7 @@ from collections import defaultdict
|
|
20
20
|
import numpy as np
|
21
21
|
|
22
22
|
from .....utils.deps import function_requires_deps, is_dep_available
|
23
|
-
from .....utils.fonts import
|
23
|
+
from .....utils.fonts import PINGFANG_FONT
|
24
24
|
|
25
25
|
if is_dep_available("matplotlib"):
|
26
26
|
import matplotlib.pyplot as plt
|
@@ -64,7 +64,7 @@ def deep_analyse(dataset_dir, output):
|
|
64
64
|
if os_system == "windows":
|
65
65
|
plt.rcParams["font.sans-serif"] = "FangSong"
|
66
66
|
else:
|
67
|
-
font = font_manager.FontProperties(fname=
|
67
|
+
font = font_manager.FontProperties(fname=PINGFANG_FONT.path)
|
68
68
|
fig, ax = plt.subplots(figsize=(max(8, int(len(classes) / 5)), 5), dpi=120)
|
69
69
|
ax.bar(x, cnts_train_sorted, width=0.5, label="train")
|
70
70
|
ax.bar(x + width, cnts_val_sorted, width=0.5, label="val")
|
@@ -18,7 +18,7 @@ from PIL import ImageDraw, ImageFont
|
|
18
18
|
|
19
19
|
from ......utils import logging
|
20
20
|
from ......utils.deps import function_requires_deps, is_dep_available
|
21
|
-
from ......utils.fonts import
|
21
|
+
from ......utils.fonts import PINGFANG_FONT
|
22
22
|
|
23
23
|
if is_dep_available("pycocotools"):
|
24
24
|
from pycocotools.coco import COCO
|
@@ -124,7 +124,7 @@ def draw_bbox(image, coco_info: "COCO", img_id):
|
|
124
124
|
font_size = int(0.024 * int(image_info["width"])) + 2
|
125
125
|
except:
|
126
126
|
font_size = 12
|
127
|
-
font = ImageFont.truetype(
|
127
|
+
font = ImageFont.truetype(PINGFANG_FONT.path, font_size, encoding="utf-8")
|
128
128
|
|
129
129
|
image = image.convert("RGB")
|
130
130
|
draw = ImageDraw.Draw(image)
|
@@ -22,7 +22,7 @@ import numpy as np
|
|
22
22
|
|
23
23
|
from .....utils.deps import function_requires_deps, is_dep_available
|
24
24
|
from .....utils.file_interface import custom_open
|
25
|
-
from .....utils.fonts import
|
25
|
+
from .....utils.fonts import PINGFANG_FONT
|
26
26
|
from .....utils.logging import warning
|
27
27
|
|
28
28
|
if is_dep_available("opencv-contrib-python"):
|
@@ -130,7 +130,7 @@ def deep_analyse(dataset_path, output, datatype="MSTextRecDataset"):
|
|
130
130
|
if os_system == "windows":
|
131
131
|
plt.rcParams["font.sans-serif"] = "FangSong"
|
132
132
|
else:
|
133
|
-
font = font_manager.FontProperties(fname=
|
133
|
+
font = font_manager.FontProperties(fname=PINGFANG_FONT.path, size=15)
|
134
134
|
if datatype == "LaTeXOCRDataset":
|
135
135
|
fig, ax = plt.subplots(figsize=(15, 9), dpi=120)
|
136
136
|
xlabel_name = "公式长度区间"
|
@@ -20,7 +20,7 @@ import numpy as np
|
|
20
20
|
import pandas as pd
|
21
21
|
|
22
22
|
from .....utils.deps import function_requires_deps, is_dep_available
|
23
|
-
from .....utils.fonts import
|
23
|
+
from .....utils.fonts import PINGFANG_FONT
|
24
24
|
|
25
25
|
if is_dep_available("matplotlib"):
|
26
26
|
import matplotlib.pyplot as plt
|
@@ -59,7 +59,7 @@ def deep_analyse(dataset_dir, output, label_col="label"):
|
|
59
59
|
if os_system == "windows":
|
60
60
|
plt.rcParams["font.sans-serif"] = "FangSong"
|
61
61
|
else:
|
62
|
-
font = font_manager.FontProperties(fname=
|
62
|
+
font = font_manager.FontProperties(fname=PINGFANG_FONT.path)
|
63
63
|
fig, ax = plt.subplots(figsize=(max(8, int(len(label_unique) / 5)), 5), dpi=120)
|
64
64
|
ax.bar(x, cls_train_sorted, width=0.5, label="train")
|
65
65
|
ax.bar(x + width, cls_val_sorted, width=0.5, label="val")
|
@@ -25,7 +25,7 @@ if is_dep_available("matplotlib"):
|
|
25
25
|
from matplotlib import font_manager
|
26
26
|
|
27
27
|
from .....utils.file_interface import custom_open
|
28
|
-
from .....utils.fonts import
|
28
|
+
from .....utils.fonts import PINGFANG_FONT
|
29
29
|
|
30
30
|
|
31
31
|
@function_requires_deps("matplotlib")
|
@@ -69,7 +69,7 @@ def deep_analyse(dataset_path, output):
|
|
69
69
|
if os_system == "windows":
|
70
70
|
plt.rcParams["font.sans-serif"] = "FangSong"
|
71
71
|
else:
|
72
|
-
font = font_manager.FontProperties(fname=
|
72
|
+
font = font_manager.FontProperties(fname=PINGFANG_FONT.path, size=10)
|
73
73
|
fig, ax = plt.subplots(figsize=(max(8, int(len(classes) / 5)), 5), dpi=300)
|
74
74
|
ax.bar(x, cnts_train_sorted, width=0.5, label="train")
|
75
75
|
ax.bar(x + width, cnts_val_sorted, width=0.5, label="val")
|
@@ -20,7 +20,7 @@ import numpy as np
|
|
20
20
|
|
21
21
|
from .....utils.deps import function_requires_deps, is_dep_available
|
22
22
|
from .....utils.file_interface import custom_open
|
23
|
-
from .....utils.fonts import
|
23
|
+
from .....utils.fonts import PINGFANG_FONT
|
24
24
|
|
25
25
|
if is_dep_available("matplotlib"):
|
26
26
|
import matplotlib.pyplot as plt
|
@@ -74,7 +74,7 @@ def deep_analyse(dataset_path, output):
|
|
74
74
|
if os_system == "windows":
|
75
75
|
plt.rcParams["font.sans-serif"] = "FangSong"
|
76
76
|
else:
|
77
|
-
font = font_manager.FontProperties(fname=
|
77
|
+
font = font_manager.FontProperties(fname=PINGFANG_FONT.path, size=10)
|
78
78
|
fig, ax = plt.subplots(figsize=(max(8, int(len(classes) / 5)), 5), dpi=300)
|
79
79
|
ax.bar(x, cnts_train_sorted, width=0.5, label="train")
|
80
80
|
ax.bar(x + width, cnts_val_sorted, width=0.5, label="val")
|
@@ -214,3 +214,30 @@ register_model_info(
|
|
214
214
|
"supported_apis": ["train", "evaluate", "predict", "export"],
|
215
215
|
}
|
216
216
|
)
|
217
|
+
|
218
|
+
register_model_info(
|
219
|
+
{
|
220
|
+
"model_name": "latin_PP-OCRv5_mobile_rec",
|
221
|
+
"suite": "TextRec",
|
222
|
+
"config_path": osp.join(PDX_CONFIG_DIR, "latin_PP-OCRv5_mobile_rec.yaml"),
|
223
|
+
"supported_apis": ["train", "evaluate", "predict", "export"],
|
224
|
+
}
|
225
|
+
)
|
226
|
+
|
227
|
+
register_model_info(
|
228
|
+
{
|
229
|
+
"model_name": "eslav_PP-OCRv5_mobile_rec",
|
230
|
+
"suite": "TextRec",
|
231
|
+
"config_path": osp.join(PDX_CONFIG_DIR, "eslav_PP-OCRv5_mobile_rec.yaml"),
|
232
|
+
"supported_apis": ["train", "evaluate", "predict", "export"],
|
233
|
+
}
|
234
|
+
)
|
235
|
+
|
236
|
+
register_model_info(
|
237
|
+
{
|
238
|
+
"model_name": "korean_PP-OCRv5_mobile_rec",
|
239
|
+
"suite": "TextRec",
|
240
|
+
"config_path": osp.join(PDX_CONFIG_DIR, "korean_PP-OCRv5_mobile_rec.yaml"),
|
241
|
+
"supported_apis": ["train", "evaluate", "predict", "export"],
|
242
|
+
}
|
243
|
+
)
|
paddlex/repo_manager/meta.py
CHANGED
@@ -33,7 +33,7 @@ REPO_META = {
|
|
33
33
|
"PaddleSeg": {
|
34
34
|
"git_path": "/PaddlePaddle/PaddleSeg.git",
|
35
35
|
"platform": "github",
|
36
|
-
"branch": "
|
36
|
+
"branch": "develop",
|
37
37
|
"install_pkg": True,
|
38
38
|
"dist_name": "paddleseg",
|
39
39
|
"import_name": "paddleseg",
|
@@ -45,7 +45,7 @@ REPO_META = {
|
|
45
45
|
"PaddleClas": {
|
46
46
|
"git_path": "/PaddlePaddle/PaddleClas.git",
|
47
47
|
"platform": "github",
|
48
|
-
"branch": "
|
48
|
+
"branch": "develop",
|
49
49
|
"install_pkg": True,
|
50
50
|
"dist_name": "paddleclas",
|
51
51
|
"import_name": "paddleclas",
|
@@ -58,7 +58,7 @@ REPO_META = {
|
|
58
58
|
"PaddleDetection": {
|
59
59
|
"git_path": "/PaddlePaddle/PaddleDetection.git",
|
60
60
|
"platform": "github",
|
61
|
-
"branch": "
|
61
|
+
"branch": "develop",
|
62
62
|
"install_pkg": True,
|
63
63
|
"dist_name": "paddledet",
|
64
64
|
"import_name": "ppdet",
|
paddlex/utils/device.py
CHANGED
@@ -117,7 +117,10 @@ def set_env_for_device_type(device_type):
|
|
117
117
|
}
|
118
118
|
_set(envs)
|
119
119
|
if device_type.lower() == "mlu":
|
120
|
-
envs = {
|
120
|
+
envs = {
|
121
|
+
"FLAGS_use_stride_kernel": "0",
|
122
|
+
"FLAGS_use_stream_safe_cuda_allocator": "0",
|
123
|
+
}
|
121
124
|
_set(envs)
|
122
125
|
if device_type.lower() == "gcu":
|
123
126
|
envs = {"FLAGS_use_stride_kernel": "0"}
|