PaddlePaddle / PaddleOCR

Awesome multilingual OCR toolkits based on PaddlePaddle (practical ultra lightweight OCR system, support 80+ languages recognition, provide data annotation and synthesis tools, support training and deployment among server, mobile, embedded and IoT devices)
https://paddlepaddle.github.io/PaddleOCR/
Apache License 2.0
44.1k stars 7.81k forks source link

修改yml的label_file_list报错 #4682

Closed monkeycc closed 2 years ago

monkeycc commented 2 years ago

比如 \configs\det\det_r50_vd_db.yml

修改yml

    config['Train']["dataset"]["data_dir"] = Daorushujuji + "/"
    config['Train']["dataset"]["label_file_list"] = Daorushujuji +"/Label.txt"

    config['Eval']["dataset"]["data_dir"] = Daorushujuji + "/"
    config['Eval']["dataset"]["label_file_list"] = Daorushujuji +"/Label.txt"

输出config 也正常 'data_dir': 'D:/OK/', 'label_file_list': 'D:/OK/Label.txt',

但就是报错:

Traceback (most recent call last):
  File "f:/paddleOCR_OK/main_multiprocessing.py", line 1582, in <module>
    OCR_train.main(config, device, logger, vdl_writer)
  File "f:\paddleOCR_OK\OCR_train.py", line 55, in main
    train_dataloader = build_dataloader(config, 'Train', device, logger)
  File "f:\paddleOCR_OK\ppocr\data\__init__.py", line 64, in build_dataloader
    dataset = eval(module_name)(config, mode, logger, seed)
  File "f:\paddleOCR_OK\ppocr\data\simple_dataset.py", line 39, in __init__
    assert len(
AssertionError: The length of ratio_list should be the same as the file_list.

只要修改label_file_list这个值 就会报错

如果在yml写死的话 不会报错

    label_file_list:
      - D:/OK/Label.txt

YML中 这个值是带 - 我直接传”- D:/OK/Label.txt“ 也是报错

直接改为 label_file_list: D:/OK/Label.txt 也是报同样的错误

输出我看了 是正常的

[2021/11/18 16:21:26] root INFO: Architecture :
[2021/11/18 16:21:26] root INFO:     Backbone :
[2021/11/18 16:21:26] root INFO:         layers : 50
[2021/11/18 16:21:26] root INFO:         name : ResNet
[2021/11/18 16:21:26] root INFO:     Head :
[2021/11/18 16:21:26] root INFO:         k : 50
[2021/11/18 16:21:26] root INFO:         name : DBHead
[2021/11/18 16:21:26] root INFO:     Neck :
[2021/11/18 16:21:26] root INFO:         name : DBFPN
[2021/11/18 16:21:26] root INFO:         out_channels : 256
[2021/11/18 16:21:26] root INFO:     Transform : None
[2021/11/18 16:21:26] root INFO:     algorithm : DB
[2021/11/18 16:21:26] root INFO:     model_type : det
[2021/11/18 16:21:26] root INFO: Eval :
[2021/11/18 16:21:26] root INFO:     dataset :
[2021/11/18 16:21:26] root INFO:         data_dir : D:/OK/
[2021/11/18 16:21:26] root INFO:         label_file_list : D:/OK/Label.txt
[2021/11/18 16:21:26] root INFO:         name : SimpleDataSet
[2021/11/18 16:21:26] root INFO:         transforms :
[2021/11/18 16:21:26] root INFO:             DecodeImage :
[2021/11/18 16:21:26] root INFO:                 channel_first : False
[2021/11/18 16:21:26] root INFO:                 img_mode : BGR
[2021/11/18 16:21:26] root INFO:             DetLabelEncode : None
[2021/11/18 16:21:26] root INFO:             DetResizeForTest :
[2021/11/18 16:21:26] root INFO:                 image_shape : [736, 1280]
[2021/11/18 16:21:26] root INFO:             NormalizeImage :
[2021/11/18 16:21:26] root INFO:                 mean : [0.485, 0.456, 0.406]
[2021/11/18 16:21:26] root INFO:                 order : hwc
[2021/11/18 16:21:26] root INFO:                 scale : 1./255.
[2021/11/18 16:21:26] root INFO:                 std : [0.229, 0.224, 0.225]
[2021/11/18 16:21:26] root INFO:             ToCHWImage : None
[2021/11/18 16:21:26] root INFO:             KeepKeys :
[2021/11/18 16:21:26] root INFO:                 keep_keys : ['image', 'shape', 'polys', 'ignore_tags']
[2021/11/18 16:21:26] root INFO:     loader :
[2021/11/18 16:21:26] root INFO:         batch_size_per_card : 1
[2021/11/18 16:21:26] root INFO:         drop_last : False
[2021/11/18 16:21:26] root INFO:         num_workers : 2
[2021/11/18 16:21:26] root INFO:         shuffle : False
[2021/11/18 16:21:26] root INFO: Global :
[2021/11/18 16:21:26] root INFO:     cal_metric_during_train : False
[2021/11/18 16:21:26] root INFO:     checkpoints : None
[2021/11/18 16:21:26] root INFO:     debug : False
[2021/11/18 16:21:26] root INFO:     distributed : False
[2021/11/18 16:21:26] root INFO:     epoch_num : 500
[2021/11/18 16:21:26] root INFO:     eval_batch_step : [0, 2000]
[2021/11/18 16:21:26] root INFO:     infer_img : doc/imgs_en/img_10.jpg
[2021/11/18 16:21:26] root INFO:     log_smooth_window : 20
[2021/11/18 16:21:26] root INFO:     pretrained_model : F:/paddleOCR_OK/pretrain_models/ResNet50_vd_ssld_pretrained.pdparams
[2021/11/18 16:21:26] root INFO:     print_batch_step : 10
[2021/11/18 16:21:26] root INFO:     save_epoch_step : 100
[2021/11/18 16:21:26] root INFO:     save_inference_dir : None
[2021/11/18 16:21:26] root INFO:     save_model_dir : D:/OUT/
[2021/11/18 16:21:26] root INFO:     save_res_path : ./output/det_db/predicts_db.txt
[2021/11/18 16:21:26] root INFO:     use_gpu : True
[2021/11/18 16:21:26] root INFO:     use_visualdl : False
[2021/11/18 16:21:26] root INFO: Loss :
[2021/11/18 16:21:26] root INFO:     alpha : 5
[2021/11/18 16:21:26] root INFO:     balance_loss : True
[2021/11/18 16:21:26] root INFO:     beta : 10
[2021/11/18 16:21:26] root INFO:     main_loss_type : DiceLoss
[2021/11/18 16:21:26] root INFO:     name : DBLoss
[2021/11/18 16:21:26] root INFO:     ohem_ratio : 3
[2021/11/18 16:21:26] root INFO: Metric :
[2021/11/18 16:21:26] root INFO:     main_indicator : hmean
[2021/11/18 16:21:26] root INFO:     name : DetMetric
[2021/11/18 16:21:26] root INFO: Optimizer :
[2021/11/18 16:21:26] root INFO:     beta1 : 0.9
[2021/11/18 16:21:26] root INFO:     beta2 : 0.999
[2021/11/18 16:21:26] root INFO:     lr :
[2021/11/18 16:21:26] root INFO:         learning_rate : 0.001
[2021/11/18 16:21:26] root INFO:     name : Adam
[2021/11/18 16:21:26] root INFO:     regularizer :
[2021/11/18 16:21:26] root INFO:         factor : 0
[2021/11/18 16:21:26] root INFO:         name : L2
[2021/11/18 16:21:26] root INFO: PostProcess :
[2021/11/18 16:21:26] root INFO:     box_thresh : 0.7
[2021/11/18 16:21:26] root INFO:     max_candidates : 1000
[2021/11/18 16:21:26] root INFO:     name : DBPostProcess
[2021/11/18 16:21:26] root INFO:     thresh : 0.3
[2021/11/18 16:21:26] root INFO:     unclip_ratio : 1.5
[2021/11/18 16:21:26] root INFO: Train :
[2021/11/18 16:21:26] root INFO:     dataset :
[2021/11/18 16:21:26] root INFO:         data_dir : D:/OK/
[2021/11/18 16:21:26] root INFO:         label_file_list : D:/OK/Label.txt
[2021/11/18 16:21:26] root INFO:         name : SimpleDataSet
[2021/11/18 16:21:26] root INFO:         ratio_list : [1.0]
[2021/11/18 16:21:26] root INFO:         transforms :
[2021/11/18 16:21:26] root INFO:             DecodeImage :
[2021/11/18 16:21:26] root INFO:                 channel_first : False
[2021/11/18 16:21:26] root INFO:                 img_mode : BGR
[2021/11/18 16:21:26] root INFO:             DetLabelEncode : None
[2021/11/18 16:21:26] root INFO:             IaaAugment :
[2021/11/18 16:21:26] root INFO:                 augmenter_args :
[2021/11/18 16:21:26] root INFO:                     args :
[2021/11/18 16:21:26] root INFO:                         p : 0.5
[2021/11/18 16:21:26] root INFO:                     type : Fliplr
[2021/11/18 16:21:26] root INFO:                     args :
[2021/11/18 16:21:26] root INFO:                         rotate : [-10, 10]
[2021/11/18 16:21:26] root INFO:                     type : Affine
[2021/11/18 16:21:26] root INFO:                     args :
[2021/11/18 16:21:26] root INFO:                         size : [0.5, 3]
[2021/11/18 16:21:26] root INFO:                     type : Resize
[2021/11/18 16:21:26] root INFO:             EastRandomCropData :
[2021/11/18 16:21:26] root INFO:                 keep_ratio : True
[2021/11/18 16:21:26] root INFO:                 max_tries : 50
[2021/11/18 16:21:26] root INFO:                 size : [640, 640]
[2021/11/18 16:21:26] root INFO:             MakeBorderMap :
[2021/11/18 16:21:26] root INFO:                 shrink_ratio : 0.4
[2021/11/18 16:21:26] root INFO:                 thresh_max : 0.7
[2021/11/18 16:21:26] root INFO:                 thresh_min : 0.3
[2021/11/18 16:21:26] root INFO:             MakeShrinkMap :
[2021/11/18 16:21:26] root INFO:                 min_text_size : 8
[2021/11/18 16:21:26] root INFO:                 shrink_ratio : 0.4
[2021/11/18 16:21:26] root INFO:             NormalizeImage :
[2021/11/18 16:21:26] root INFO:                 mean : [0.485, 0.456, 0.406]
[2021/11/18 16:21:26] root INFO:                 order : hwc
[2021/11/18 16:21:26] root INFO:                 scale : 1./255.
[2021/11/18 16:21:26] root INFO:                 std : [0.229, 0.224, 0.225]
[2021/11/18 16:21:26] root INFO:             ToCHWImage : None
[2021/11/18 16:21:26] root INFO:             KeepKeys :
[2021/11/18 16:21:26] root INFO:                 keep_keys : ['image', 'threshold_map', 'threshold_mask', 'shrink_map', 'shrink_mask']
[2021/11/18 16:21:26] root INFO:     loader :
[2021/11/18 16:21:26] root INFO:         batch_size_per_card : 3
[2021/11/18 16:21:26] root INFO:         drop_last : False
[2021/11/18 16:21:26] root INFO:         num_workers : 8
[2021/11/18 16:21:26] root INFO:         shuffle : True
[2021/11/18 16:21:26] root INFO: train with paddle 2.1.3 and device CUDAPlace(0)
Process SpawnProcess-1:
Traceback (most recent call last):
  File "E:\anaconda3\envs\python38\lib\multiprocessing\process.py", line 315, in _bootstrap
    self.run()
  File "E:\anaconda3\envs\python38\lib\multiprocessing\process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "f:\paddleOCR_OK\OCR_train.py", line 155, in OCR_Train_def
    OCR_Train_Class.main(config, device, logger, vdl_writer)
  File "f:\paddleOCR_OK\OCR_train.py", line 60, in main
    train_dataloader = build_dataloader(config, 'Train', device, logger)
  File "f:\paddleOCR_OK\ppocr\data\__init__.py", line 64, in build_dataloader
    dataset = eval(module_name)(config, mode, logger, seed)
  File "f:\paddleOCR_OK\ppocr\data\simple_dataset.py", line 39, in __init__
    assert len(
AssertionError: The length of ratio_list should be the same as the file_list.
monkeycc commented 2 years ago

已经解决 ['D:/OK/Label.txt']