-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Description
🔎 Search before asking
- I have searched the PaddleOCR Docs and found no similar bug report.
- I have searched the PaddleOCR Issues and found no similar bug report.
- I have searched the PaddleOCR Discussions and found no similar bug report.
🐛 Bug (问题描述)
Creating model: ('PP-OCRv5_mobile_det', 'models/PP-OCRv5_mobile_det_infer')
E:\Anaconda3\envs\paddle3.0\Lib\site-packages\paddle\utils\cpp_extension\extension_utils.py:718: UserWarning: No ccache found. Please be aware that recompiling all source files may be required. You can download and install ccache from: https://github.com/ccache/ccache/blob/master/doc/INSTALL.md
warnings.warn(warning_message)
<paddle.base.libpaddle.AnalysisConfig object at 0x000001EEF7380930>
Traceback (most recent call last):
File "G:\python-event-service\services\OSD_detector\111.py", line 4, in
ocr = PaddleOCR(
^^^^^^^^^^
File "E:\Anaconda3\envs\paddle3.0\Lib\site-packages\paddleocr_pipelines\ocr.py", line 163, in init
super().init(**base_params)
File "E:\Anaconda3\envs\paddle3.0\Lib\site-packages\paddleocr_pipelines\base.py", line 67, in init
self.paddlex_pipeline = self._create_paddlex_pipeline()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Anaconda3\envs\paddle3.0\Lib\site-packages\paddleocr_pipelines\base.py", line 105, in _create_paddlex_pipeline
return create_pipeline(config=self.merged_paddlex_config, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Anaconda3\envs\paddle3.0\Lib\site-packages\paddlex\inference\pipelines_init.py", line 167, in create_pipeline
pipeline = BasePipeline.get(pipeline_name)(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Anaconda3\envs\paddle3.0\Lib\site-packages\paddlex\utils\deps.py", line 206, in _wrapper
return old_init_func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Anaconda3\envs\paddle3.0\Lib\site-packages\paddlex\inference\pipelines_parallel.py", line 103, in init
self._pipeline = self._create_internal_pipeline(config, self.device)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Anaconda3\envs\paddle3.0\Lib\site-packages\paddlex\inference\pipelines_parallel.py", line 158, in _create_internal_pipeline
return self.pipeline_cls(
^^^^^^^^^^^^^^^^^^^
File "E:\Anaconda3\envs\paddle3.0\Lib\site-packages\paddlex\inference\pipelines\ocr\pipeline.py", line 117, in init
self.text_det_model = self.create_model(
^^^^^^^^^^^^^^^^^^
File "E:\Anaconda3\envs\paddle3.0\Lib\site-packages\paddlex\inference\pipelines\base.py", line 106, in create_model
model = create_predictor(
^^^^^^^^^^^^^^^^^
File "E:\Anaconda3\envs\paddle3.0\Lib\site-packages\paddlex\inference\models_init.py", line 84, in create_predictor
return BasePredictor.get(model_name)(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Anaconda3\envs\paddle3.0\Lib\site-packages\paddlex\inference\models\text_detection\predictor.py", line 57, in init
self.pre_tfs, self.infer, self.post_op = self._build()
^^^^^^^^^^^^^
File "E:\Anaconda3\envs\paddle3.0\Lib\site-packages\paddlex\inference\models\text_detection\predictor.py", line 77, in _build
infer = self.create_static_infer()
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Anaconda3\envs\paddle3.0\Lib\site-packages\paddlex\inference\models\base\predictor\base_predictor.py", line 300, in create_static_infer
return PaddleInfer(
^^^^^^^^^^^^
File "E:\Anaconda3\envs\paddle3.0\Lib\site-packages\paddlex\inference\models\common\static_infer.py", line 284, in init
self.predictor = self._create()
^^^^^^^^^^^^^^
File "E:\Anaconda3\envs\paddle3.0\Lib\site-packages\paddlex\inference\models\common\static_infer.py", line 490, in _create
predictor = paddle.inference.create_predictor(config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
IndexError: invalid map<K, T> key
PP-OCRv5使用自己的数据训练检测模型和识别模型
导出模型命令:
(test) [root@localhost PaddleOCR-3.3.2]# python tools/export_model.py -c configs/det/PP-OCRv5/PP-OCRv5_mobile_det.yml -o Global.pretrained_model=output/PP-OCRv5_mobile_det/best_accuracy.pdparams Global.save_i
nference_dir="./inference/PP-OCRv5_mobile_det_infer/"
which: no ccache in (/usr/local/cuda/bin:/home/osd/anaconda3/envs/test/bin:/home/osd/anaconda3/condabin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/opt/redis/redis-5.0.12/src:/opt/r
edis/redis-5.0.12/src:/root/bin:/opt/redis/redis-5.0.12/src:/opt/redis/redis-5.0.12/src:/root/bin)
/home/osd/anaconda3/envs/test/lib/python3.11/site-packages/paddle/utils/cpp_extension/extension_utils.py:719: UserWarning: No ccache found. Please be aware that recompiling all source files may be required. Y
ou can download and install ccache from: https://github.com/ccache/ccache/blob/master/doc/INSTALL.md
warnings.warn(warning_message)
Skipping import of the encryption module.
W1226 08:43:29.594699 97690 gpu_resources.cc:114] Please NOTE: device: 0, GPU Compute Capability: 7.5, Driver API Version: 12.2, Runtime API Version: 12.0
[2025/12/26 08:43:29] ppocr INFO: load pretrain successful from output/PP-OCRv5_mobile_det/best_accuracy
[2025/12/26 08:43:29] ppocr INFO: Export inference config file to ./inference/PP-OCRv5_mobile_det_infer/inference.yml
Skipping import of the encryption module
W1226 08:43:31.798440 97690 eager_utils.cc:3534] Paddle static graph(PIR) not support input out tensor for now!!!!!
[2025/12/26 08:43:33] ppocr INFO: inference model is saved to ./inference/PP-OCRv5_mobile_det_infer/inference
(test) [root@localhost PaddleOCR-3.3.2]# python tools/export_model.py -c configs/rec/PP-OCRv5/PP-OCRv5_mobile_rec.yml -o Global.pretrained_model=output/PP-OCRv5_mobile_rec/best_accuracy.pdparams Global.save_i
nference_dir="./inference/PP-OCRv5_mobile_rec_infer/"
which: no ccache in (/usr/local/cuda/bin:/home/osd/anaconda3/envs/test/bin:/home/osd/anaconda3/condabin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/opt/redis/redis-5.0.12/src:/opt/r
edis/redis-5.0.12/src:/root/bin:/opt/redis/redis-5.0.12/src:/opt/redis/redis-5.0.12/src:/root/bin)
/home/osd/anaconda3/envs/test/lib/python3.11/site-packages/paddle/utils/cpp_extension/extension_utils.py:719: UserWarning: No ccache found. Please be aware that recompiling all source files may be required. Y
ou can download and install ccache from: https://github.com/ccache/ccache/blob/master/doc/INSTALL.md
warnings.warn(warning_message)
Skipping import of the encryption module.
W1226 09:08:35.073326 354260 gpu_resources.cc:114] Please NOTE: device: 0, GPU Compute Capability: 7.5, Driver API Version: 12.2, Runtime API Version: 12.0
[2025/12/26 09:08:36] ppocr INFO: load pretrain successful from output/PP-OCRv5_mobile_rec/best_accuracy
[2025/12/26 09:08:36] ppocr INFO: Export inference config file to ./inference/PP-OCRv5_mobile_rec_infer/inference.yml
Skipping import of the encryption module
W1226 09:08:37.533684 354260 eager_utils.cc:3534] Paddle static graph(PIR) not support input out tensor for now!!!!!
[2025/12/26 09:08:39] ppocr INFO: inference model is saved to ./inference/PP-OCRv5_mobile_rec_infer/inference
使用导出的模型推理时报错,报错信息在最上面
我使用paddleocr 项目中tool下的工具推理都没有问题
python tools/infer_det.py -c output/PP-OCRv5_mobile_det/config.yml -o Global.infer_img=111.jpg Global.pretrained_model=output/PP-OCRv5_mobile_det/best_accuracy.pdparams
[2025/12/26 14:49:09] ppocr INFO: load pretrain successful from output/PP-OCRv5_mobile_det/best_accuracy
[2025/12/26 14:49:09] ppocr INFO: infer_img: 111.jpg
[2025/12/26 14:49:11] ppocr INFO: The detected Image saved in ./checkpoints/det_db/det_results/111.jpg
[2025/12/26 14:49:11] ppocr INFO: success!
python tools/infer/predict_det.py --det_model_dir inference/PP-OCRv5_mobile_det_infer --image_dir 111.jpg
[2025/12/26 14:58:47] ppocr WARNING: The first GPU is used for inference by default, GPU ID: 0
[2025/12/26 14:58:50] ppocr INFO: 111.jpg [[[13.0, 58.0], [1491.0, 64.0], [1491.0, 117.0], [13.0, 111.0]], [[1912.0, 58.0], [2467.0, 58.0], [2467.0, 111.0], [1912.0, 111.0]], [[19.0, 11.0], [1069.0, 8.0
], [1069.0, 45.0], [19.0, 48.0]]]
🏃♂️ Environment (运行环境)
paddlepaddle==3.2.2
paddleocr==3.3.2
🌰 Minimal Reproducible Example (最小可复现问题的Demo)
from paddleocr import PaddleOCR
ocr = PaddleOCR(
text_detection_model_name="PP-OCRv5_mobile_det",
text_detection_model_dir="models/PP-OCRv5_mobile_det_infer",
text_recognition_model_name="PP-OCRv5_mobile_rec",
text_recognition_model_dir="models/PP-OCRv5_mobile_rec_infer",
use_doc_orientation_classify=False,
use_doc_unwarping=False,
use_textline_orientation=False,
device="cpu",
text_det_unclip_ratio=1.5,
text_det_thresh=0.3,
text_det_box_thresh=0.7,
)
path = r"H:\osd_data\images\osd_0000002.jpg"
result = ocr.predict(input=path)
for res in result:
res.print()
res.save_to_img("output")
res.save_to_json("output")