Closed HSILA closed 2 years ago
For inference model , The dictionary used at prediction needs to be consistent with the training.
For training, you can check following two dicts are the same length
@tink2123 I checked, the two lists were the same length for training. The problem was that label encoder and decoder in the config file didn't match.
Any solution to this problem guys ?
I have the same question, any solutions ? Please help!
Hello I have the same problem how to solve that This my config file Global: debug: false use_gpu: true epoch_num: 300 log_smooth_window: 20 print_batch_step: 10 save_model_dir: ./output/v3_en_mobile save_epoch_step: 3 eval_batch_step: [0, 250] cal_metric_during_train: true pretrained_model: checkpoints: save_inference_dir: use_visualdl: false infer_img: doc/imgs_words/ch/word_1.jpg character_dict_path: /content/PaddleOCR/ppocr/utils/en_dict.txt max_text_length: &max_text_length 27 infer_mode: false use_space_char: true distributed: true save_res_path: ./output/rec/predicts_ppocrv3_en.txt
Optimizer: name: Adam beta1: 0.9 beta2: 0.999 lr: name: Cosine learning_rate: 0.001 warmup_epoch: 5 regularizer: name: L2 factor: 3.0e-05
Architecture: model_type: rec algorithm: SVTR Transform: Backbone: name: MobileNetV1Enhance scale: 0.5 last_conv_stride: [1, 2] last_pool_type: avg Head: name: MultiHead head_list:
Loss: name: MultiLoss loss_config_list:
PostProcess:
name: CTCLabelDecode
Metric: name: RecMetric main_indicator: acc ignore_space: False
Train: dataset: name: SimpleDataSet data_dir: /content/dataf/ ext_op_transform_idx: 1 label_file_list:
IndexError Traceback (most recent call last)
4 frames /content/PaddleOCRproject/ppocr/postprocess/rec_postprocess.py in decode(self, text_index, text_prob, is_remove_duplicate) 91 # print(text_index) 92 for text_id in text_index[batch_idx][selection]: ---> 93 print(self.character[text_id]) 94 char_list = [ 95 self.character[text_id]
IndexError: list index out of range
请提供下述完整信息以便快速定位问题/Please provide the following information to quickly locate the problem
python3 tools/train.py -c my_config.yml
File "tools/train.py", line 188, in
main(config, device, logger, vdl_writer)
File "tools/train.py", line 161, in main
program.train(config, train_dataloader, valid_dataloader, device, model,
File "**/PaddleOCR/tools/program.py", line 285, in train
post_result = post_process_class(preds, batch[1])
File "**/PaddleOCR/ppocr/postprocess/rec_postprocess.py", line 101, in call
label = self.decode(label)
File "**/PaddleOCR/ppocr/postprocess/rec_postprocess.py", line 64, in decode
char_list = [
File "**/PaddleOCR/ppocr/postprocess/rec_postprocess.py", line 65, in
self.character[text_id]
IndexError: list index out of range