Skip to content

Commit edbabfc

Browse files
authored
fix: add missing font download in the rapidocr artifacts (#2735)
add font in the rapidocr downloads Signed-off-by: Michele Dolfi <[email protected]>
1 parent 609069d commit edbabfc

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

docling/models/rapid_ocr_model.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
_ModelPathEngines = Literal["onnxruntime", "torch"]
2626
_ModelPathTypes = Literal[
27-
"det_model_path", "cls_model_path", "rec_model_path", "rec_keys_path"
27+
"det_model_path", "cls_model_path", "rec_model_path", "rec_keys_path", "font_path"
2828
]
2929

3030

@@ -58,6 +58,10 @@ class RapidOcrModel(BaseOcrModel):
5858
"url": "https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/v2.0.7/paddle/PP-OCRv4/rec/ch_PP-OCRv4_rec_infer/ppocr_keys_v1.txt",
5959
"path": "paddle/PP-OCRv4/rec/ch_PP-OCRv4_rec_infer/ppocr_keys_v1.txt",
6060
},
61+
"font_path": {
62+
"url": "https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/v3.4.0/resources/fonts/FZYTK.TTF",
63+
"path": "fonts/FZYTK.TTF",
64+
},
6165
},
6266
"torch": {
6367
"det_model_path": {
@@ -76,6 +80,10 @@ class RapidOcrModel(BaseOcrModel):
7680
"url": "https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/v3.4.0/paddle/PP-OCRv4/rec/ch_PP-OCRv4_rec_infer/ppocr_keys_v1.txt",
7781
"path": "paddle/PP-OCRv4/rec/ch_PP-OCRv4_rec_infer/ppocr_keys_v1.txt",
7882
},
83+
"font_path": {
84+
"url": "https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/v3.4.0/resources/fonts/FZYTK.TTF",
85+
"path": "fonts/FZYTK.TTF",
86+
},
7987
},
8088
}
8189

@@ -125,6 +133,7 @@ def __init__(
125133
cls_model_path = self.options.cls_model_path
126134
rec_model_path = self.options.rec_model_path
127135
rec_keys_path = self.options.rec_keys_path
136+
font_path = self.options.font_path
128137
if artifacts_path is not None:
129138
det_model_path = (
130139
det_model_path
@@ -150,12 +159,19 @@ def __init__(
150159
/ self._model_repo_folder
151160
/ self._default_models[backend_enum.value]["rec_keys_path"]["path"]
152161
)
162+
font_path = (
163+
font_path
164+
or artifacts_path
165+
/ self._model_repo_folder
166+
/ self._default_models[backend_enum.value]["font_path"]["path"]
167+
)
153168

154169
for model_path in (
155170
rec_keys_path,
156171
cls_model_path,
157172
rec_model_path,
158173
rec_keys_path,
174+
font_path,
159175
):
160176
if model_path is None:
161177
continue

0 commit comments

Comments
 (0)