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