-
🔎 Search before asking
🐛 Bug (问题描述)使用paddleocr3.0.0读取本地下载的模型,总是不使用自己下载的模型,报错 Creating model: ('PP-OCRv5_server_det', 'models/v5/PP-OCRv5_mobile_det_infer')
Traceback (most recent call last):
File "E:\PythonCode\PaddleOCR\测试ppocrv5.py", line 48, in <module>
ocr = PaddleOCR(
File "E:\PythonCode\PaddleOCR\paddleocr\_pipelines\ocr.py", line 144, in __init__
super().__init__(**base_params)
File "E:\PythonCode\PaddleOCR\paddleocr\_pipelines\base.py", line 73, in __init__
self.paddlex_pipeline = self._create_paddlex_pipeline()
File "E:\PythonCode\PaddleOCR\paddleocr\_pipelines\base.py", line 107, in _create_paddlex_pipeline
return create_pipeline(config=self._merged_paddlex_config, **kwargs)
File "D:\Anaconda\anaconda3\envs\paddleocr3.0.0\lib\site-packages\paddlex\inference\pipelines\__init__.py", line 165, in create_pipeline
pipeline = BasePipeline.get(pipeline_name)(
File "D:\Anaconda\anaconda3\envs\paddleocr3.0.0\lib\site-packages\paddlex\utils\deps.py", line 195, in _wrapper
return old_init_func(self, *args, **kwargs)
File "D:\Anaconda\anaconda3\envs\paddleocr3.0.0\lib\site-packages\paddlex\inference\pipelines\_parallel.py", line 103, in __init__
self._pipeline = self._create_internal_pipeline(config, self.device)
File "D:\Anaconda\anaconda3\envs\paddleocr3.0.0\lib\site-packages\paddlex\inference\pipelines\_parallel.py", line 158, in _create_internal_pipeline
return self._pipeline_cls(
File "D:\Anaconda\anaconda3\envs\paddleocr3.0.0\lib\site-packages\paddlex\inference\pipelines\ocr\pipeline.py", line 114, in __init__
self.text_det_model = self.create_model(
File "D:\Anaconda\anaconda3\envs\paddleocr3.0.0\lib\site-packages\paddlex\inference\pipelines\base.py", line 107, in create_model
model = create_predictor(
File "D:\Anaconda\anaconda3\envs\paddleocr3.0.0\lib\site-packages\paddlex\inference\models\__init__.py", line 75, in create_predictor
model_name == config["Global"]["model_name"]
AssertionError: Model name mismatch,please input the correct model dir. 🏃♂️ Environment (运行环境)paddleocr3.0.0 🌰 Minimal Reproducible Example (最小可复现问题的Demo)text_detection_model_dir ="models/v5/PP-OCRv5_mobile_det_infer"
text_recognition_model_dir = "models/v5/PP-OCRv5_mobile_rec_infer"
ocr = PaddleOCR(
use_doc_orientation_classify=False, # 文档方向分类模型 默认true 检测整个文档图像的方向并纠正(即0度,90度,180度,270度)。
use_doc_unwarping=False, # 文本图像矫正模型 默认true 纠正图像中的透视变形或弯曲,使文档看起来像是正面拍摄的平面图像。
use_textline_orientation=False, # 文本行方向分类模型 默认true 识别文本行是水平排列还是垂直排列。
text_detection_model_dir=text_detection_model_dir,
text_recognition_model_dir=text_recognition_model_dir,
device="gpu" #device="gpu:3" 指定第三块gpu运行
) 运行时打印Creating model: ('PP-OCRv5_server_det', 'models/v5/PP-OCRv5_mobile_det_infer') 为什么不加载自己本地的模型 |
Beta Was this translation helpful? Give feedback.
Replies: 12 comments
-
本地模型中的 |
Beta Was this translation helpful? Give feedback.
-
Global:
model_name: PP-OCRv5_mobile_det
Hpi:
backend_configs:
paddle_infer:
trt_dynamic_shapes: &id001
x:
- - 1
- 3
- 32
- 32
- - 1
- 3
- 736
- 736
- - 1
- 3
- 4000
- 4000
tensorrt:
dynamic_shapes: *id001
PreProcess:
transform_ops:
- DecodeImage:
channel_first: false
img_mode: BGR
- DetLabelEncode: null
- DetResizeForTest:
resize_long: 960
- NormalizeImage:
mean:
- 0.485
- 0.456
- 0.406
order: hwc
scale: 1./255.
std:
- 0.229
- 0.224
- 0.225
- ToCHWImage: null
- KeepKeys:
keep_keys:
- image
- shape
- polys
- ignore_tags
PostProcess:
name: DBPostProcess
thresh: 0.3
box_thresh: 0.6
max_candidates: 1000
unclip_ratio: 1.5 模型就是在https://paddlepaddle.github.io/PaddleOCR/latest/version3.x/pipeline_usage/OCR.html#1-ocr这里下载的 |
Beta Was this translation helpful? Give feedback.
-
把模型名中的“_infer”删去试试 |
Beta Was this translation helpful? Give feedback.
-
模型名称里是server版本,路径里是mobile版本,估计是这个原因 |
Beta Was this translation helpful? Give feedback.
-
在PaddleOCR()内部有两个参数用来指定模型名称,你需要将这两个参数设置为你自己本地的模型模型名称,比如你本地是移动端模型就在.yml文件中找到这个模型的名称然后设置 |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
请问解决了吗? |
Beta Was this translation helpful? Give feedback.
-
没有 尝试了很多办法都不行 回退版本了 2.8 可以实现需求 |
Beta Was this translation helpful? Give feedback.
-
我也是用的mobile模型,添加了 text_detection_model_name="PP-OCRv5_mobile_det",
text_recognition_model_name="PP-OCRv5_mobile_rec", 就能正常使用。 完整的参数: PaddleOCR(
use_doc_orientation_classify=False,
use_doc_unwarping=False,
use_textline_orientation=False,
device='gpu' if use_gpu else 'cpu',
text_detection_model_dir=det_model_path,
text_recognition_model_dir=rec_model_path,
text_detection_model_name="PP-OCRv5_mobile_det",
text_recognition_model_name="PP-OCRv5_mobile_rec"
) |
Beta Was this translation helpful? Give feedback.
-
我也遇到了这样的问题,删掉 model_name 结尾的 _infer 然后就可以正常运行了。 # 错误示范
det_model_name = "PP-OCRv5_server_det_infer"
rec_model_name = "PP-OCRv5_server_rec_infer"
# 正确示范
det_model_name = "PP-OCRv5_server_det"
rec_model_name = "PP-OCRv5_server_rec"
ocr = PaddleOCR( use_textline_orientation = True , lang = "ch" , device = device , text_det_box_thresh = 0.2 ,
text_detection_model_name = det_model_name , text_recognition_model_name = rec_model_name ,
text_detection_model_dir = det_model_dir , text_recognition_model_dir = rec_model_dir ) |
Beta Was this translation helpful? Give feedback.
-
感谢指正 |
Beta Was this translation helpful? Give feedback.
我也遇到了这样的问题,删掉 model_name 结尾的 _infer 然后就可以正常运行了。