运行PaddleOCR时遇到的一些问题汇总

官方文档提供了PaddleOCR的各类用例说明,但是使用中仍然会有一些问题,这里做一些总结和整理

  1. 跑通train.py代码
    • python tools/train.py -c configs/rec/PP-OCRv3/ch_PP-OCRv3_rec_distillation.yml -o Global.pretrained_model=ckpt/ch_PP-OCRv3_rec_train/best_accuracy Global.epoch_num=20 Global.eval_batch_step=‘[0, 20]’ Train.dataset.data_dir=./data Train.dataset.label_file_list=[‘./data/render_train.list’] Train.loader.batch_size_per_card=64 Eval.dataset.data_dir=./data Eval.dataset.label_file_list=[“./data/val.list”] Eval.loader.batch_size_per_card=64
    • Global.eval_batch_step='[0, 20]'这个参数必须是不可以加引号的,最开始一直报错,调试发现给的例子中并没有给一个可运行参数,这里Global.eval_batch_step=20或者[0,200]等。
  2. OMP:error
    • import os os.environ['KMP_DUPLICATE_LIB_OK']='True
    • 方法参考于总结该问题解决方案:这里
  3. ImportError: /lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.30’ not found (required by /home/dujiang/miniconda3/envs/Dlv3/lib/python3.8/site-packages/scipy/fft/_pocketfft/pypocketfft.cpython-38-x86_64-linux-gnu.so)
    • 见本人写的另一篇文章:如何在不变系统环境情况下链接自己的库
  4. [2024/07/02 11:44:54] ppocr INFO: Initialize indexs of datasets:[‘./data/val.list’]W0702 11:44:54.800262 3711953 gpu_resources.cc:119] Please NOTE: device: 0, GPU Compute Capability: 7.5, Driver API Version: 12.2, Runtime APIVersion: 11.8W0702 11:44:54.801103 3711953 gpu_resources.cc:164] device: 0, cuDNN Version: 8.9.[2024/07/02 11:44:55] ppocr INFO: train dataloader has 18 iters[2024/07/02 11:44:55] ppocr INFO: valid dataloader has 5 iters[2024/07/02 11:44:55] ppocr INFO: load pretrain successful from ./ckpt/ch_PP-OCRv3_rec_train/best_accuracyOSError: (External) CUBLAS error(15) [Hint: ‘CUBLAS_STATUS_NOT_SUPPORTED’. The functionality requested is not supported ] (at /paddle/paddle/phi/kernels/funcs/blas/blas_impl.cu.h:41 [operator < linear > error]eval model:: 0%| | 0/3 [00:02
  5. 关键点应该在于GPU Compute Capability: 7.5, Driver API Version: 12.2, Runtime APIVersion: 11.8W0702 11:44:54.801103 3711953 gpu_resources.cc:164] device: 0, cuDNN Version: 8.9解决方法也很简单import paddle paddle.utils.run_check(),但具体原因不明确。
  6. 训练结束后如何进行测试
    • 训练模型是不能进行推理的需要转换为推理模型,运行如下脚本,根据自己的训练进行调整
    • python tools/export_model.py -c configs\rec\PP-OCRv3\ch_PP-OCRv3_rec_distillation.yml -o Global.pretrained_model=output/rec_ppocr_v3_distillation/best_model/best_accuracy Global.load_static_weights=False Global.save_inference_dir=./inference/db_mv3/
  7. 调用方向分类模型
    • --use_angle_cls=True --cls_model_dir=ckpt/ch_ppocr_mobile_v2.0_cls_infer
    • 更多参数列表在tools\infer\utility.py中可以查看
  8. 将icdar2015数据集转换为paddleocr可以训练的格式
* python ppocr/utils/gen_label.py --mode="det" --root_path="ch4_trainning_images" --input_path="ch4_training_localization_transcription_gt" --output_label="train_icdar2015_label.txt"
* python ppocr/utils/gen_label.py --mode="det" --root_path="ch4_test_images" --input_path="Challenge4_Test_Task1_GT" --output_label="test_icdar2015_label.txt"
  • 注:root_path可以设定为ch4_training_images,这样生成txt路径为ch4_training_images/xxjpg,训练时系统会自动进入项目下的train_data\icdar2015\text_localization进行数据读取,root写错会报递归达到最大问题错误
  • windows会遇到’gbk’ codec can’t encode character ‘\xb4’ in position 720: illegal multibyte sequence
  • 解决方法:with open(out_label, “w”,encoding=‘utf-8’) as out_file:
================== 待补充 ======================

2024.7.9

可视化训练过程

  • visualdl官方已经弃用tools/program.py查看
  • paddleocr目前支持wandb可视化训练结果
	pip install wandb
	wandb login

关于API key需要在wandb注册生成
后面在yml中加入代码

Global:use_wandb: True

执行训练跳转到网页
运行PaddleOCR时遇到的一些问题汇总_第1张图片
2024.7.24
paddleocr对部分显卡的兼容存在一定的问题,如本人h100训练过程发现报错
terminate called after throwing an instance of ‘thrust::system::system_error’
what(): parallel_for failed: cudaErrorNoKernelImageForDevice: no kernel image is available for execution on the device


C++ Traceback (most recent call last):

0 paddle::pybind::ThrowExceptionToPython(std::__exception_ptr::exception_ptr)


Error Message Summary:

FatalError: Process abort signal is detected by the operating system.
[TimeInfo: *** Aborted at 1721621207 (unix time) try “date -d @1721621207” if you are using GNU date ***]
[SignalInfo: *** SIGABRT (@0x3fc00001d25) received by PID 7461 (TID 0x7f9133ed1740) from PID 7461 ***]
已放弃(吐核)

  • 解决方法:升级cuda,升级paddle版本。CUDA12.3 cudnn8.9 paddlepaddle-gpu3.0 gcc12.1
  • 解决来源:本人github提问

你可能感兴趣的:(PaddleOCR,python,ocr,计算机视觉,图像处理,paddle)