paddlex 3.0.3__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.
Files changed (126) hide show
  1. paddlex/.version +1 -1
  2. paddlex/configs/modules/text_recognition/eslav_PP-OCRv5_mobile_rec.yaml +39 -0
  3. paddlex/configs/modules/text_recognition/korean_PP-OCRv5_mobile_rec.yaml +39 -0
  4. paddlex/configs/modules/text_recognition/latin_PP-OCRv5_mobile_rec.yaml +39 -0
  5. paddlex/configs/pipelines/PP-DocTranslation.yaml +261 -0
  6. paddlex/inference/common/batch_sampler/__init__.py +1 -0
  7. paddlex/inference/common/batch_sampler/markdown_batch_sampler.py +116 -0
  8. paddlex/inference/common/result/base_cv_result.py +2 -3
  9. paddlex/inference/common/result/mixin.py +3 -1
  10. paddlex/inference/models/common/vlm/generation/utils.py +2 -2
  11. paddlex/inference/models/formula_recognition/result.py +2 -2
  12. paddlex/inference/models/image_classification/result.py +3 -5
  13. paddlex/inference/models/image_multilabel_classification/result.py +2 -2
  14. paddlex/inference/models/object_detection/result.py +2 -2
  15. paddlex/inference/models/open_vocabulary_detection/processors/groundingdino_processors.py +3 -0
  16. paddlex/inference/models/text_recognition/predictor.py +51 -1
  17. paddlex/inference/models/text_recognition/result.py +5 -2
  18. paddlex/inference/models/video_classification/result.py +3 -3
  19. paddlex/inference/models/video_detection/result.py +2 -4
  20. paddlex/inference/pipelines/__init__.py +1 -0
  21. paddlex/inference/pipelines/attribute_recognition/result.py +2 -2
  22. paddlex/inference/pipelines/components/prompt_engineering/__init__.py +1 -0
  23. paddlex/inference/pipelines/components/prompt_engineering/generate_translate_prompt.py +179 -0
  24. paddlex/inference/pipelines/doc_preprocessor/result.py +2 -2
  25. paddlex/inference/pipelines/formula_recognition/result.py +2 -2
  26. paddlex/inference/pipelines/layout_parsing/pipeline_v2.py +2 -0
  27. paddlex/inference/pipelines/layout_parsing/result_v2.py +4 -2
  28. paddlex/inference/pipelines/ocr/pipeline.py +2 -0
  29. paddlex/inference/pipelines/ocr/result.py +11 -7
  30. paddlex/inference/pipelines/pp_doctranslation/__init__.py +15 -0
  31. paddlex/inference/pipelines/pp_doctranslation/pipeline.py +523 -0
  32. paddlex/inference/pipelines/pp_doctranslation/result.py +39 -0
  33. paddlex/inference/pipelines/pp_doctranslation/utils.py +260 -0
  34. paddlex/inference/pipelines/pp_shitu_v2/result.py +2 -2
  35. paddlex/inference/serving/basic_serving/_pipeline_apps/anomaly_detection.py +4 -2
  36. paddlex/inference/serving/basic_serving/_pipeline_apps/doc_preprocessor.py +5 -1
  37. paddlex/inference/serving/basic_serving/_pipeline_apps/face_recognition.py +4 -2
  38. paddlex/inference/serving/basic_serving/_pipeline_apps/formula_recognition.py +4 -2
  39. paddlex/inference/serving/basic_serving/_pipeline_apps/human_keypoint_detection.py +4 -2
  40. paddlex/inference/serving/basic_serving/_pipeline_apps/image_classification.py +4 -2
  41. paddlex/inference/serving/basic_serving/_pipeline_apps/image_multilabel_classification.py +4 -2
  42. paddlex/inference/serving/basic_serving/_pipeline_apps/instance_segmentation.py +4 -2
  43. paddlex/inference/serving/basic_serving/_pipeline_apps/layout_parsing.py +4 -2
  44. paddlex/inference/serving/basic_serving/_pipeline_apps/object_detection.py +4 -2
  45. paddlex/inference/serving/basic_serving/_pipeline_apps/ocr.py +4 -2
  46. paddlex/inference/serving/basic_serving/_pipeline_apps/open_vocabulary_detection.py +4 -2
  47. paddlex/inference/serving/basic_serving/_pipeline_apps/open_vocabulary_segmentation.py +4 -2
  48. paddlex/inference/serving/basic_serving/_pipeline_apps/pedestrian_attribute_recognition.py +4 -2
  49. paddlex/inference/serving/basic_serving/_pipeline_apps/pp_chatocrv3_doc.py +14 -24
  50. paddlex/inference/serving/basic_serving/_pipeline_apps/pp_chatocrv4_doc.py +16 -26
  51. paddlex/inference/serving/basic_serving/_pipeline_apps/pp_doctranslation.py +203 -0
  52. paddlex/inference/serving/basic_serving/_pipeline_apps/pp_shituv2.py +4 -2
  53. paddlex/inference/serving/basic_serving/_pipeline_apps/pp_structurev3.py +4 -2
  54. paddlex/inference/serving/basic_serving/_pipeline_apps/rotated_object_detection.py +4 -2
  55. paddlex/inference/serving/basic_serving/_pipeline_apps/seal_recognition.py +4 -2
  56. paddlex/inference/serving/basic_serving/_pipeline_apps/semantic_segmentation.py +4 -2
  57. paddlex/inference/serving/basic_serving/_pipeline_apps/small_object_detection.py +4 -2
  58. paddlex/inference/serving/basic_serving/_pipeline_apps/table_recognition.py +4 -2
  59. paddlex/inference/serving/basic_serving/_pipeline_apps/table_recognition_v2.py +4 -2
  60. paddlex/inference/serving/basic_serving/_pipeline_apps/ts_anomaly_detection.py +4 -2
  61. paddlex/inference/serving/basic_serving/_pipeline_apps/ts_classification.py +4 -2
  62. paddlex/inference/serving/basic_serving/_pipeline_apps/ts_forecast.py +4 -2
  63. paddlex/inference/serving/basic_serving/_pipeline_apps/vehicle_attribute_recognition.py +4 -2
  64. paddlex/inference/serving/schemas/anomaly_detection.py +1 -0
  65. paddlex/inference/serving/schemas/doc_preprocessor.py +1 -0
  66. paddlex/inference/serving/schemas/face_recognition.py +1 -0
  67. paddlex/inference/serving/schemas/formula_recognition.py +1 -0
  68. paddlex/inference/serving/schemas/human_keypoint_detection.py +1 -0
  69. paddlex/inference/serving/schemas/image_classification.py +1 -0
  70. paddlex/inference/serving/schemas/image_multilabel_classification.py +1 -0
  71. paddlex/inference/serving/schemas/instance_segmentation.py +1 -0
  72. paddlex/inference/serving/schemas/layout_parsing.py +1 -0
  73. paddlex/inference/serving/schemas/object_detection.py +1 -0
  74. paddlex/inference/serving/schemas/ocr.py +1 -0
  75. paddlex/inference/serving/schemas/open_vocabulary_detection.py +1 -0
  76. paddlex/inference/serving/schemas/open_vocabulary_segmentation.py +1 -0
  77. paddlex/inference/serving/schemas/pedestrian_attribute_recognition.py +1 -0
  78. paddlex/inference/serving/schemas/pp_chatocrv3_doc.py +5 -4
  79. paddlex/inference/serving/schemas/pp_chatocrv4_doc.py +6 -5
  80. paddlex/inference/serving/schemas/pp_doctranslation.py +115 -0
  81. paddlex/inference/serving/schemas/pp_shituv2.py +1 -0
  82. paddlex/inference/serving/schemas/pp_structurev3.py +2 -9
  83. paddlex/inference/serving/schemas/rotated_object_detection.py +1 -0
  84. paddlex/inference/serving/schemas/seal_recognition.py +1 -0
  85. paddlex/inference/serving/schemas/semantic_segmentation.py +1 -0
  86. paddlex/inference/serving/schemas/shared/ocr.py +8 -1
  87. paddlex/inference/serving/schemas/small_object_detection.py +1 -0
  88. paddlex/inference/serving/schemas/table_recognition.py +1 -0
  89. paddlex/inference/serving/schemas/table_recognition_v2.py +1 -0
  90. paddlex/inference/serving/schemas/ts_anomaly_detection.py +1 -0
  91. paddlex/inference/serving/schemas/ts_classification.py +1 -0
  92. paddlex/inference/serving/schemas/ts_forecast.py +1 -0
  93. paddlex/inference/serving/schemas/vehicle_attribute_recognition.py +1 -0
  94. paddlex/inference/utils/io/__init__.py +1 -0
  95. paddlex/inference/utils/io/readers.py +46 -0
  96. paddlex/inference/utils/io/writers.py +2 -0
  97. paddlex/inference/utils/official_models.py +7 -0
  98. paddlex/modules/anomaly_detection/dataset_checker/dataset_src/convert_dataset.py +2 -2
  99. paddlex/modules/face_recognition/dataset_checker/dataset_src/utils/visualizer.py +3 -3
  100. paddlex/modules/formula_recognition/dataset_checker/dataset_src/analyse_dataset.py +2 -2
  101. paddlex/modules/general_recognition/dataset_checker/dataset_src/analyse_dataset.py +2 -2
  102. paddlex/modules/general_recognition/dataset_checker/dataset_src/utils/visualizer.py +3 -3
  103. paddlex/modules/image_classification/dataset_checker/dataset_src/analyse_dataset.py +2 -2
  104. paddlex/modules/image_classification/dataset_checker/dataset_src/utils/visualizer.py +3 -3
  105. paddlex/modules/instance_segmentation/dataset_checker/dataset_src/analyse_dataset.py +2 -2
  106. paddlex/modules/instance_segmentation/dataset_checker/dataset_src/utils/visualizer.py +2 -2
  107. paddlex/modules/m_3d_bev_detection/dataset_checker/dataset_src/analyse_dataset.py +2 -2
  108. paddlex/modules/multilabel_classification/dataset_checker/dataset_src/analyse_dataset.py +2 -2
  109. paddlex/modules/multilabel_classification/dataset_checker/dataset_src/utils/visualizer.py +2 -2
  110. paddlex/modules/object_detection/dataset_checker/dataset_src/analyse_dataset.py +2 -2
  111. paddlex/modules/object_detection/dataset_checker/dataset_src/utils/visualizer.py +2 -2
  112. paddlex/modules/text_recognition/dataset_checker/dataset_src/analyse_dataset.py +2 -2
  113. paddlex/modules/text_recognition/model_list.py +3 -0
  114. paddlex/modules/ts_classification/dataset_checker/dataset_src/analyse_dataset.py +2 -2
  115. paddlex/modules/video_classification/dataset_checker/dataset_src/analyse_dataset.py +2 -2
  116. paddlex/modules/video_detection/dataset_checker/dataset_src/analyse_dataset.py +2 -2
  117. paddlex/repo_apis/PaddleOCR_api/text_rec/register.py +27 -0
  118. paddlex/repo_manager/meta.py +3 -3
  119. paddlex/utils/device.py +4 -1
  120. paddlex/utils/{fonts/__init__.py → fonts.py} +45 -26
  121. {paddlex-3.0.3.dist-info → paddlex-3.1.0.dist-info}/METADATA +25 -1
  122. {paddlex-3.0.3.dist-info → paddlex-3.1.0.dist-info}/RECORD +126 -114
  123. {paddlex-3.0.3.dist-info → paddlex-3.1.0.dist-info}/LICENSE +0 -0
  124. {paddlex-3.0.3.dist-info → paddlex-3.1.0.dist-info}/WHEEL +0 -0
  125. {paddlex-3.0.3.dist-info → paddlex-3.1.0.dist-info}/entry_points.txt +0 -0
  126. {paddlex-3.0.3.dist-info → paddlex-3.1.0.dist-info}/top_level.txt +0 -0
@@ -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 PINGFANG_FONT_FILE_PATH
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=PINGFANG_FONT_FILE_PATH, size=10)
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 PINGFANG_FONT_FILE_PATH
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(PINGFANG_FONT_FILE_PATH, font_size)
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 PINGFANG_FONT_FILE_PATH
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=PINGFANG_FONT_FILE_PATH)
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 PINGFANG_FONT_FILE_PATH
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(PINGFANG_FONT_FILE_PATH, font_size, encoding="utf-8")
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 PINGFANG_FONT_FILE_PATH
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=PINGFANG_FONT_FILE_PATH, size=15)
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 = "公式长度区间"
@@ -33,4 +33,7 @@ MODELS = [
33
33
  "ch_RepSVTR_rec",
34
34
  "PP-OCRv5_server_rec",
35
35
  "PP-OCRv5_mobile_rec",
36
+ "latin_PP-OCRv5_mobile_rec",
37
+ "eslav_PP-OCRv5_mobile_rec",
38
+ "korean_PP-OCRv5_mobile_rec",
36
39
  ]
@@ -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 PINGFANG_FONT_FILE_PATH
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=PINGFANG_FONT_FILE_PATH)
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 PINGFANG_FONT_FILE_PATH
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=PINGFANG_FONT_FILE_PATH, size=10)
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 PINGFANG_FONT_FILE_PATH
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=PINGFANG_FONT_FILE_PATH, size=10)
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
+ )
@@ -33,7 +33,7 @@ REPO_META = {
33
33
  "PaddleSeg": {
34
34
  "git_path": "/PaddlePaddle/PaddleSeg.git",
35
35
  "platform": "github",
36
- "branch": "release/2.10",
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": "release/2.6",
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": "release/2.8.1",
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 = {"FLAGS_use_stride_kernel": "0"}
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"}
@@ -17,27 +17,10 @@ from pathlib import Path
17
17
  import PIL
18
18
  from PIL import ImageFont
19
19
 
20
- from .. import logging
21
- from ..cache import CACHE_DIR
22
- from ..download import download
23
- from ..flags import LOCAL_FONT_FILE_PATH
24
-
25
-
26
- def get_font_file_path(file_name: str) -> str:
27
- """
28
- Get the path of the font file.
29
-
30
- Returns:
31
- str: The path to the font file.
32
- """
33
- font_path = (Path(CACHE_DIR) / "fonts" / file_name).resolve().as_posix()
34
- if not Path(font_path).is_file():
35
- download(
36
- url=f"https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/fonts/{file_name}",
37
- save_path=font_path,
38
- )
39
-
40
- return font_path
20
+ from . import logging
21
+ from .cache import CACHE_DIR
22
+ from .download import download
23
+ from .flags import LOCAL_FONT_FILE_PATH
41
24
 
42
25
 
43
26
  def create_font(txt: str, sz: tuple, font_path: str) -> ImageFont:
@@ -87,12 +70,48 @@ def create_font_vertical(
87
70
  return font
88
71
 
89
72
 
73
+ class Font:
74
+ def __init__(self, font_name=None, local_path=None):
75
+ if local_path is None:
76
+ if Path(str(LOCAL_FONT_FILE_PATH)).is_file():
77
+ local_path = str(LOCAL_FONT_FILE_PATH)
78
+ self._local_path = local_path
79
+ if not local_path:
80
+ assert font_name is not None
81
+ self._font_name = font_name
82
+
83
+ @property
84
+ def path(self):
85
+ # HACK: download font file when needed only
86
+ if not self._local_path:
87
+ self._get_offical_font()
88
+ return self._local_path
89
+
90
+ def _get_offical_font(self):
91
+ """
92
+ Download the official font file.
93
+ """
94
+ font_path = (Path(CACHE_DIR) / "fonts" / self._font_name).resolve().as_posix()
95
+ if not Path(font_path).is_file():
96
+ download(
97
+ url=f"https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/fonts/{self._font_name}",
98
+ save_path=font_path,
99
+ )
100
+ self._local_path = font_path
101
+
102
+
90
103
  if Path(str(LOCAL_FONT_FILE_PATH)).is_file():
91
104
  logging.warning(
92
105
  f"Using the local font file(`{LOCAL_FONT_FILE_PATH}`) specified by `LOCAL_FONT_FILE_PATH`!"
93
106
  )
94
- PINGFANG_FONT_FILE_PATH = LOCAL_FONT_FILE_PATH
95
- SIMFANG_FONT_FILE_PATH = LOCAL_FONT_FILE_PATH
96
- else:
97
- PINGFANG_FONT_FILE_PATH = get_font_file_path("PingFang-SC-Regular.ttf")
98
- SIMFANG_FONT_FILE_PATH = get_font_file_path("simfang.ttf")
107
+
108
+ PINGFANG_FONT = Font(font_name="PingFang-SC-Regular.ttf")
109
+ SIMFANG_FONT = Font(font_name="simfang.ttf")
110
+ LATIN_FONT = Font(font_name="latin.ttf")
111
+ KOREAN_FONT = Font(font_name="korean.ttf")
112
+ ARABIC_FONT = Font(font_name="arabic.ttf")
113
+ CYRILLIC_FONT = Font(font_name="cyrillic.ttf")
114
+ KANNADA_FONT = Font(font_name="kannada.ttf")
115
+ TELUGU_FONT = Font(font_name="telugu.ttf")
116
+ TAMIL_FONT = Font(font_name="tamil.ttf")
117
+ DEVANAGARI_FONT = Font(font_name="devanagari.ttf")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: paddlex
3
- Version: 3.0.3
3
+ Version: 3.1.0
4
4
  Summary: Low-code development tool based on PaddlePaddle.
5
5
  Home-page: UNKNOWN
6
6
  Author: PaddlePaddle Authors
@@ -45,6 +45,7 @@ Requires-Dist: ujson
45
45
  Provides-Extra: all
46
46
  Requires-Dist: aiohttp>=3.9; extra == "all"
47
47
  Requires-Dist: bce-python-sdk>=0.9; extra == "all"
48
+ Requires-Dist: beautifulsoup4; extra == "all"
48
49
  Requires-Dist: chinese-calendar; extra == "all"
49
50
  Requires-Dist: einops; extra == "all"
50
51
  Requires-Dist: faiss-cpu; extra == "all"
@@ -81,6 +82,7 @@ Requires-Dist: uvicorn>=0.16; extra == "all"
81
82
  Requires-Dist: yarl>=1.9; extra == "all"
82
83
  Requires-Dist: decord==0.6.0; ((platform_machine == "x86_64" or platform_machine == "AMD64") and sys_platform != "darwin") and extra == "all"
83
84
  Provides-Extra: base
85
+ Requires-Dist: beautifulsoup4; extra == "base"
84
86
  Requires-Dist: chinese-calendar; extra == "base"
85
87
  Requires-Dist: einops; extra == "base"
86
88
  Requires-Dist: faiss-cpu; extra == "base"
@@ -182,6 +184,20 @@ Requires-Dist: Jinja2; extra == "speech"
182
184
  Requires-Dist: regex; extra == "speech"
183
185
  Requires-Dist: soundfile; extra == "speech"
184
186
  Requires-Dist: tqdm; extra == "speech"
187
+ Provides-Extra: trans
188
+ Requires-Dist: beautifulsoup4; extra == "trans"
189
+ Requires-Dist: ftfy; extra == "trans"
190
+ Requires-Dist: imagesize; extra == "trans"
191
+ Requires-Dist: lxml; extra == "trans"
192
+ Requires-Dist: openai>=1.63; extra == "trans"
193
+ Requires-Dist: opencv-contrib-python==4.10.0.84; extra == "trans"
194
+ Requires-Dist: openpyxl; extra == "trans"
195
+ Requires-Dist: premailer; extra == "trans"
196
+ Requires-Dist: pyclipper; extra == "trans"
197
+ Requires-Dist: pypdfium2>=4; extra == "trans"
198
+ Requires-Dist: scikit-learn; extra == "trans"
199
+ Requires-Dist: shapely; extra == "trans"
200
+ Requires-Dist: tokenizers>=0.19; extra == "trans"
185
201
  Provides-Extra: ts
186
202
  Requires-Dist: chinese-calendar; extra == "ts"
187
203
  Requires-Dist: joblib; extra == "ts"
@@ -228,6 +244,14 @@ PaddleX 3.0 是基于飞桨框架构建的低代码开发工具,它集成了
228
244
 
229
245
  ## 📣 近期更新
230
246
 
247
+ 🔥🔥 **2025.6.28,发布 PaddleX v3.1.0**,新增能力如下:
248
+
249
+ - **重要模型:**
250
+ - **新增PP-OCRv5多语种文本识别模型**,支持法语、西班牙语、葡萄牙语、俄语、韩语等37种语言的文字识别模型的训推流程。**平均精度涨幅超30%。**
251
+ - 升级PP-StructureV3中的**PP-Chart2Table模型**,图表转表能力进一步升级,在内部自建测评集合上指标(RMS-F1)**提升9.36个百分点(71.24% -> 80.60%)**
252
+ - **重要产线:**
253
+ - 新增基于PP-StructureV3和ERNIE 4.5 Turbo的**文档翻译产线PP-DocTranslation,支持翻译Markdown文档、各种复杂版式的PDF文档和文档图像,结果保存为Markdown格式文档。**
254
+
231
255
 
232
256
  🔥🔥 **2025.5.20,发布 PaddleX v3.0.0**,相比PaddleX v2.x,核心升级如下:
233
257