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.27k stars 7.82k forks source link

ppocr INFO: best metric, hmean: 0, is_float16: False #11913

Closed xiaozuxin closed 5 months ago

xiaozuxin commented 7 months ago

请提供下述完整信息以便快速定位问题/Please provide the following information to quickly locate the problem

各位大神,有没有遇到过这样的情况,windows10 下进行自己的推断训练时, 一直显示 ppocr INFO: best metric, hmean: 0, is_float16: False 是什么原因? ppocr

xiaozuxin commented 7 months ago
Global:
  use_gpu: False
  epoch_num: 500
  log_smooth_window: 20
  print_batch_step: 10
  save_model_dir: ./output/det_result/
  save_epoch_step: 1
  # evaluation is run every 5000 iterations after the 4000th iteration
  eval_batch_step: [1, 10]
  cal_metric_during_train: False
  #改为数据集路径
  pretrained_model: ./pretrain_models/ch_ppocr_server_v2.0_det_train/best_accuracy
  checkpoints:
  save_inference_dir:
  use_visualdl: False
  infer_img: ./infer_img
  save_res_path: ./output/det_db/predicts_db.txt
  use_space_char: True

Architecture:
  model_type: det
  algorithm: DB
  Transform:
  Backbone:
    name: ResNet_vd
    layers: 18
    disable_se: True
  Neck:
    name: DBFPN
    out_channels: 256
  Head:
    name: DBHead
    k: 50

Loss:
  name: DBLoss
  balance_loss: true
  main_loss_type: DiceLoss
  alpha: 5
  beta: 10
  ohem_ratio: 3

Optimizer:
  name: Adam
  beta1: 0.9
  beta2: 0.999
  lr:
    name: Cosine
    learning_rate: 0.001
    warmup_epoch: 2
  regularizer:
    name: 'L2'
    factor: 0

PostProcess:
  name: DBPostProcess
  thresh: 0.3
  box_thresh: 0.6
  max_candidates: 1000
  unclip_ratio: 1.5

Metric:
  name: DetMetric
  main_indicator: hmean

Train:
  dataset:
    name: SimpleDataSet
    data_dir: ./train_data/
    label_file_list:
      - ./train_data/det/train.txt
    ratio_list: [1.0]
    transforms:
      - DecodeImage: # load image
          img_mode: BGR
          channel_first: False
      - DetLabelEncode: # Class handling label
      - IaaAugment:
          augmenter_args:
            - { 'type': Fliplr, 'args': { 'p': 0.5 } }
            - { 'type': Affine, 'args': { 'rotate': [-10, 10] } }
            - { 'type': Resize, 'args': { 'size': [0.5, 3] } }
      - EastRandomCropData:
          size: [960, 960]
          max_tries: 50
          keep_ratio: true
      - MakeBorderMap:
          shrink_ratio: 0.4
          thresh_min: 0.3
          thresh_max: 0.7
      - MakeShrinkMap:
          shrink_ratio: 0.4
          min_text_size: 8
      - NormalizeImage:
          scale: 1./255.
          mean: [0.485, 0.456, 0.406]
          std: [0.229, 0.224, 0.225]
          order: 'hwc'
      - ToCHWImage:
      - KeepKeys:
          keep_keys: ['image', 'threshold_map', 'threshold_mask', 'shrink_map', 'shrink_mask'] # the order of the dataloader list
  loader:
    shuffle: True
    drop_last: False
    batch_size_per_card: 8
    num_workers: 4

Eval:
  dataset:
    name: SimpleDataSet
    data_dir: ./train_data/
    label_file_list:
      - ./train_data/det/val.txt
    transforms:
      - DecodeImage: # load image
          img_mode: BGR
          channel_first: False
      - DetLabelEncode: # Class handling label
      - DetResizeForTest:
#           image_shape: [736, 1280]
      - NormalizeImage:
          scale: 1./255.
          mean: [0.485, 0.456, 0.406]
          std: [0.229, 0.224, 0.225]
          order: 'hwc'
      - ToCHWImage:
      - KeepKeys:
          keep_keys: ['image', 'shape', 'polys', 'ignore_tags']
  loader:
    shuffle: False
    drop_last: False
    batch_size_per_card: 1 # must be 1
    num_workers: 2

这是训练的模型yml

Sunting78 commented 7 months ago

您好,是训练自己的数据集吗?训练过程中损失是否正常下降呢?

xiaozuxin commented 7 months ago

train.log

@Sunting78 感谢,我是用 PPOCRLabel 标记自己的图片,划分数据集后,做的本地数据集训练,损失下降还不太会看,这是训练日志,能看到损失情况么。

UserWangZz commented 6 months ago

猜测是因为: batch size = 8 train dataloader has 1 iters 这表示你的数据你数据集很小,只使用一个iteration,便可以遍历整个训练集 log_smooth_window : 20 表示log的平滑窗口是20个iteration,因此这可能就是训练时没有输出log信息的原因,以及训练效果不好的原因。 可以尝试加入更多的数据进行训练。