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
This commit is contained in:
zhang-prog 2025-05-27 12:01:53 +08:00 committed by GitHub
parent b0b31c38ae
commit 97d9728a1d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 13 additions and 5 deletions

View File

@ -66,7 +66,8 @@ public:
if (config["Global"] && config["Global"]["model_name"]) {
model_name = config["Global"]["model_name"].as<std::string>();
}
if (!model_name.empty()) {
if (!model_name.empty() && model_name != "PP-OCRv5_mobile_det" &&
model_name != "PP-OCRv5_server_det") {
std::cerr << "Error: " << model_name << " is currently not supported."
<< std::endl;
std::exit(EXIT_FAILURE);

View File

@ -61,7 +61,8 @@ public:
if (config["Global"] && config["Global"]["model_name"]) {
model_name = config["Global"]["model_name"].as<std::string>();
}
if (!model_name.empty()) {
if (!model_name.empty() && model_name != "PP-OCRv5_mobile_rec" &&
model_name != "PP-OCRv5_server_rec") {
std::cerr << "Error: " << model_name << " is currently not supported."
<< std::endl;
std::exit(EXIT_FAILURE);

View File

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

View File

@ -38,7 +38,10 @@ class TextDetector(object):
if os.path.exists(f"{args.det_model_dir}/inference.yml"):
model_config = utility.load_config(f"{args.det_model_dir}/inference.yml")
model_name = model_config.get("Global", {}).get("model_name", "")
if model_name:
if model_name and model_name not in [
"PP-OCRv5_mobile_det",
"PP-OCRv5_server_det",
]:
raise ValueError(
f"{model_name} is not supported. Please check if the model is supported by the PaddleOCR wheel."
)

View File

@ -41,7 +41,10 @@ class TextRecognizer(object):
if os.path.exists(f"{args.rec_model_dir}/inference.yml"):
model_config = utility.load_config(f"{args.rec_model_dir}/inference.yml")
model_name = model_config.get("Global", {}).get("model_name", "")
if model_name:
if model_name and model_name not in [
"PP-OCRv5_mobile_rec",
"PP-OCRv5_server_rec",
]:
raise ValueError(
f"{model_name} is not supported. Please check if the model is supported by the PaddleOCR wheel."
)