Skip to content

Commit a3b9c4b

Browse files
authored
support PaddleOCR-VL (#4609)
* support PaddleOCR-VL * remove confusing number characters, 0, 1, 9 * support PP-DocLayoutV2
1 parent 3d5a7b9 commit a3b9c4b

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

.precommit/check_imports.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
# 1. It is supported only in Python 3.10+.
3131
# 2. It requires the packages to be installed, but we are doing a static check.
3232
MOD_TO_DEP = {
33-
"aistudio-sdk": "aistudio_sdk",
33+
"aistudio_sdk": "aistudio-sdk",
3434
"aiohttp": "aiohttp",
3535
"baidubce": "bce-python-sdk",
3636
"bs4": "beautifulsoup4",

paddlex/inference/pipelines/paddleocr_vl/uilts.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,13 +395,24 @@ def tokenize_figure_of_table(table_block_img, table_box, figures):
395395
- Token-to-img HTML map,
396396
- List of figure paths dropped.
397397
"""
398+
399+
def gen_random_map(num):
400+
exclude_digits = {"0", "1", "9"}
401+
seq = []
402+
i = 0
403+
while len(seq) < num:
404+
if not (set(str(i)) & exclude_digits):
405+
seq.append(i)
406+
i += 1
407+
return seq
408+
398409
import random
399410

400411
random.seed(1024)
401412
token_map = {}
402413
table_x_min, table_y_min, table_x_max, table_y_max = table_box
403414
drop_idxes = []
404-
random_map = list(range(len(figures)))
415+
random_map = gen_random_map(len(figures))
405416
random.shuffle(random_map)
406417
for figure_id, figure in enumerate(figures):
407418
figure_x_min, figure_y_min, figure_x_max, figure_y_max = figure["coordinate"]

paddlex/inference/utils/official_models.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"ResNet152",
4646
"ResNet152_vd",
4747
"ResNet200_vd",
48+
"PaddleOCR-VL-0.9B",
4849
"PP-LCNet_x0_25",
4950
"PP-LCNet_x0_25_textline_ori",
5051
"PP-LCNet_x0_35",
@@ -294,6 +295,7 @@
294295
"GroundingDINO-T",
295296
"SAM-H_box",
296297
"SAM-H_point",
298+
"PP-DocLayoutV2",
297299
"PP-DocLayout-L",
298300
"PP-DocLayout-M",
299301
"PP-DocLayout-S",
@@ -424,7 +426,12 @@ def get_model(self, model_name):
424426
f"Using official model ({model_name}), the model files will be automatically downloaded and saved in `{model_dir}`."
425427
)
426428
self._download(model_name, model_dir)
427-
return model_dir
429+
430+
return (
431+
model_dir / "PaddleOCR-VL-0.9B"
432+
if model_name == "PaddleOCR-VL-0.9B"
433+
else model_dir
434+
)
428435

429436
@abstractmethod
430437
def _download(self):

0 commit comments

Comments
 (0)