PaddleOCR
PaddleOCR copied to clipboard
[SRN - PPOCR v4] Error when run predict inference
请提供下述完整信息以便快速定位问题/Please provide the following information to quickly locate the problem
- 系统环境/System Environment: macos Sonoma v14 - python3 ver 3.10.6
- 版本号/Version:Paddle: PaddleOCR:PPOCR-V4 问题相关组件/Related components:SRN algorithm
- 运行指令/Command Code:
python tools/infer/predict_rec.py --image_dir="/Users/roy/Desktop/app with nhannguyen/LVTN/AI-modal/PaddleOCR/train/vietnamese/train/img_crop/im0001_2.jpg" \
--use_gpu=False \
--rec_algorithm="SRN" \
--rec_model_dir="./inference/SRN" \
--rec_image_shape="1, 64, 256" \
--rec_char_dict_path="./ppocr/utils/dict/vi_dict.txt"
This is my config:
debug: false
use_gpu: false
epoch_num: 1
log_smooth_window: 20
print_batch_step: 5
save_model_dir: ./output/SRN
save_epoch_step: 10
eval_batch_step:
- 30000
- 40000
cal_metric_during_train: false
pretrained_model: /Users/roy/Desktop/app with nhannguyen/LVTN/AI-modal/PaddleOCR/det_r50_vd_sast_icdar15_v2.0_train/best_accuracy
checkpoints: null
save_inference_dir: ./inference/SRN
use_visualdl: false
infer_img: doc/imgs_words/en/word_1.png
character_dict_path: ./ppocr/utils/dict/vi_dict.txt
character_type: vi
max_text_length: 25
num_heads: 8
infer_mode: false
use_space_char: true
save_res_path: ./output/SRN/predicts_srn.txt
load_static_weights: true
distributed: false
Optimizer:
name: Adam
beta1: 0.9
beta2: 0.999
clip_norm: 10.0
lr:
learning_rate: 0.0001
Architecture:
model_type: rec
algorithm: SRN
in_channels: 1
Transform: null
Backbone:
name: ResNetFPN
Head:
name: SRNHead
max_text_length: 25
num_heads: 8
num_encoder_TUs: 2
num_decoder_TUs: 4
hidden_dims: 512
Loss:
name: SRNLoss
PostProcess:
name: SRNLabelDecode
Metric:
name: RecMetric
main_indicator: acc
Train:
dataset:
name: SimpleDataSet
data_dir: ./train/vietnamese/train/img_crop
label_file_list:
- ./train/vietnamese/train/crop_label.txt
ratio_list:
- 1
transforms:
- DecodeImage:
img_mode: BGR
channel_first: false
- SRNLabelEncode: null
- SRNRecResizeImg:
image_shape:
- 1
- 64
- 256
- KeepKeys:
keep_keys:
- image
- label
- length
- encoder_word_pos
- gsrm_word_pos
- gsrm_slf_attn_bias1
- gsrm_slf_attn_bias2
loader:
shuffle: false
batch_size_per_card: 32
drop_last: false
num_workers: 8
Eval:
dataset:
name: SimpleDataSet
data_dir: ./train/vietnamese/train/img_crop
label_file_list:
- ./train/vietnamese/train/crop_label.txt
ratio_list:
- 1
transforms:
- DecodeImage:
img_mode: BGR
channel_first: false
- SRNLabelEncode: null
- SRNRecResizeImg:
image_shape:
- 1
- 64
- 256
- KeepKeys:
keep_keys:
- image
- label
- length
- encoder_word_pos
- gsrm_word_pos
- gsrm_slf_attn_bias1
- gsrm_slf_attn_bias2
loader:
shuffle: false
drop_last: false
batch_size_per_card: 32
num_workers: 8
profiler_options: null
- 完整报错/Complete Error Message:
Traceback (most recent call last):
File "/Users/roy/Desktop/app with nhannguyen/LVTN/AI-modal/PaddleOCR/tools/infer/predict_rec.py", line 743, in <module>
main(utility.parse_args())
File "/Users/roy/Desktop/app with nhannguyen/LVTN/AI-modal/PaddleOCR/tools/infer/predict_rec.py", line 704, in main
text_recognizer = TextRecognizer(args)
File "/Users/roy/Desktop/app with nhannguyen/LVTN/AI-modal/PaddleOCR/tools/infer/predict_rec.py", line 147, in __init__
) = utility.create_predictor(args, "rec", logger)
File "/Users/roy/Desktop/app with nhannguyen/LVTN/AI-modal/PaddleOCR/tools/infer/utility.py", line 296, in create_predictor
predictor = inference.create_predictor(config)
ValueError: (InvalidArgument) The Input Variable(X) of (reshape2) Operator used to determine kernel data type is empty or not phi::DenseTensor or SelectedRows or LoDTensorArray.
[Hint: Expected data_type != dafault_data_type, but received data_type:-1 == dafault_data_type:-1.] (at /Users/paddle/xly/workspace/77aceb8e-2a5b-4fe4-a675-547f3aad14a4/Paddle/paddle/fluid/framework/operator.cc:2932)
[operator < reshape2 > error]
更新一下paddle版本试试
更新一下paddle版本试试
更新一下paddle版本试试
which version
@nhannguyen1003 maybe paddlepaddle2.5 or 2.6
@nhannguyen1003 maybe paddlepaddle2.5 or 2.6
I've use paddle2.6.1 and paddleocr2.7.5 but it's still not work. When I turn on GPU it work but nothing happen. Can you share me about your paddle version?
hi @nhannguyen1003, I can reproduce this issue, which may be a bug.
warnings.warn(
Traceback (most recent call last):
File "/home/greatx/repos/PaddleOCR/tools/infer/predict_rec.py", line 743, in <module>
main(utility.parse_args())
File "/home/greatx/repos/PaddleOCR/tools/infer/predict_rec.py", line 704, in main
text_recognizer = TextRecognizer(args)
File "/home/greatx/repos/PaddleOCR/tools/infer/predict_rec.py", line 147, in __init__
) = utility.create_predictor(args, "rec", logger)
File "/home/greatx/repos/PaddleOCR/tools/infer/utility.py", line 296, in create_predictor
predictor = inference.create_predictor(config)
ValueError: (InvalidArgument) The Input Variable(X) of (reshape2) Operator used to determine kernel data type is empty or not phi::DenseTensor or SelectedRows or LoDTensorArray.
[Hint: Expected data_type != dafault_data_type, but received data_type:-1 == dafault_data_type:-1.] (at ../paddle/fluid/framework/operator.cc:2924)
[operator < reshape2 > error]
the predict mode worked for me
python3 tools/infer_rec.py -c configs/rec/rec_r50_fpn_srn.yml -o Global.pretrained_model={path/to/weights}/best_accuracy Global.infer_img=doc/imgs_words/en/word_1.png
所以是predic_rec脚本出现问题了吗?
the predict mode worked for me
python3 tools/infer_rec.py -c configs/rec/rec_r50_fpn_srn.yml -o Global.pretrained_model={path/to/weights}/best_accuracy Global.infer_img=doc/imgs_words/en/word_1.png
所以是predic_rec脚本出现问题了吗?
估计和静态图推理有关
所以是predic_rec脚本出现问题了吗?
估计和静态图推理有关
the predict mode worked for me
python3 tools/infer_rec.py -c configs/rec/rec_r50_fpn_srn.yml -o Global.pretrained_model={path/to/weights}/best_accuracy Global.infer_img=doc/imgs_words/en/word_1.png
Could you please to give me your configuration?
@leapvn-nhannt just configs/rec/rec_r50_fpn_srn.yml
, no change
@leapvn-nhannt just
configs/rec/rec_r50_fpn_srn.yml
, no change
Could you mind to give me your environment: python: , paddleocr, paddlepaddle?
@nhannguyen1003 paddlepaddle 2.6.1, latest paddleocr in main branch, and python 3.10
@nhannguyen1003 paddlepaddle 2.6.1, latest paddleocr in main branch, and python 3.10
I've checked and found that it's available when run infer_rec, but when exported to inference it isn't work.
hi @nhannguyen1003, this will take time to check in depth and I will look into it further.
@nhannguyen1003 maybe paddlepaddle2.5 or 2.6
请问paddleocr 支持batch 推理吗?
@nhannguyen1003 你的问题解决了么?可以告诉我吗
hi @nhannguyen1003, this will take time to check in depth and I will look into it further.
Did you solved this problem? Please tell me if problem is solved
@ltkien0105 not yet.