Skip to content

Commit e86450a

Browse files
committed
Derive the model names from directory names if provided
Fixes #15707
1 parent 966c11e commit e86450a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

paddleocr/_pipelines/ocr.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# arguments from the pipeline class, to reduce boilerplate and improve
1717
# maintainability?
1818

19+
import os
1920
import sys
2021
import warnings
2122

@@ -109,6 +110,20 @@ def __init__(
109110
text_detection_model_name = det_model_name
110111
text_recognition_model_name = rec_model_name
111112
else:
113+
if (
114+
text_detection_model_dir is not None
115+
and text_detection_model_name is None
116+
):
117+
text_detection_model_name = os.path.basename(text_detection_model_dir)
118+
119+
if (
120+
text_recognition_model_dir is not None
121+
and text_recognition_model_name is None
122+
):
123+
text_recognition_model_name = os.path.basename(
124+
text_recognition_model_dir
125+
)
126+
112127
if lang is not None or ocr_version is not None:
113128
warnings.warn(
114129
"`lang` and `ocr_version` will be ignored when model names or model directories are not `None`.",

0 commit comments

Comments
 (0)