Skip to content

Commit 97d9728

Browse files
authored
cpp_infer and python_infer support PP-OCRv5 models (#15410)
* cpp_infer support PP-OCRv5 models * python_infer support PP-OCRv5 models * update version2.x model_list * rollback version2.x model_list * update * update
1 parent b0b31c3 commit 97d9728

File tree

5 files changed

+13
-5
lines changed

5 files changed

+13
-5
lines changed

deploy/cpp_infer/include/ocr_det.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ class DBDetector {
6666
if (config["Global"] && config["Global"]["model_name"]) {
6767
model_name = config["Global"]["model_name"].as<std::string>();
6868
}
69-
if (!model_name.empty()) {
69+
if (!model_name.empty() && model_name != "PP-OCRv5_mobile_det" &&
70+
model_name != "PP-OCRv5_server_det") {
7071
std::cerr << "Error: " << model_name << " is currently not supported."
7172
<< std::endl;
7273
std::exit(EXIT_FAILURE);

deploy/cpp_infer/include/ocr_rec.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ class CRNNRecognizer {
6161
if (config["Global"] && config["Global"]["model_name"]) {
6262
model_name = config["Global"]["model_name"].as<std::string>();
6363
}
64-
if (!model_name.empty()) {
64+
if (!model_name.empty() && model_name != "PP-OCRv5_mobile_rec" &&
65+
model_name != "PP-OCRv5_server_rec") {
6566
std::cerr << "Error: " << model_name << " is currently not supported."
6667
<< std::endl;
6768
std::exit(EXIT_FAILURE);

docs/version2.x/legacy/model_list_2.x.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# PaddleOCR 2.x及更低版本支持的模型
22

3-
由于串联逻辑和模型训练、推理时用到的配置不同,PaddleOCR 2.x 版本的 PP-OCRv4、PP-OCRv3 系列模型与 PaddleOCR 3.0 及以上版本的 PP-OCRv4、PP-OCRv3 系列模型不能互相使用。
3+
由于串联逻辑和模型训练、推理时用到的配置不同,PaddleOCR 2.x 分支的 PP-OCRv4、PP-OCRv3 系列模型与 PaddleOCR 3.0 及以上分支的 PP-OCRv4、PP-OCRv3 系列模型不能互相使用。
44

55
## 检测模型
66

tools/infer/predict_det.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ def __init__(self, args, logger=None):
3838
if os.path.exists(f"{args.det_model_dir}/inference.yml"):
3939
model_config = utility.load_config(f"{args.det_model_dir}/inference.yml")
4040
model_name = model_config.get("Global", {}).get("model_name", "")
41-
if model_name:
41+
if model_name and model_name not in [
42+
"PP-OCRv5_mobile_det",
43+
"PP-OCRv5_server_det",
44+
]:
4245
raise ValueError(
4346
f"{model_name} is not supported. Please check if the model is supported by the PaddleOCR wheel."
4447
)

tools/infer/predict_rec.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ def __init__(self, args, logger=None):
4141
if os.path.exists(f"{args.rec_model_dir}/inference.yml"):
4242
model_config = utility.load_config(f"{args.rec_model_dir}/inference.yml")
4343
model_name = model_config.get("Global", {}).get("model_name", "")
44-
if model_name:
44+
if model_name and model_name not in [
45+
"PP-OCRv5_mobile_rec",
46+
"PP-OCRv5_server_rec",
47+
]:
4548
raise ValueError(
4649
f"{model_name} is not supported. Please check if the model is supported by the PaddleOCR wheel."
4750
)

0 commit comments

Comments
 (0)