PaddleOCR 识别器数据增强

PaddleOCR 识别器自带了数据增强方法,如何开启呢?
参照:rec_chinese_common_train_v2.0.yml配置文件。
增加- RecAug: 字段,例如:

Train:
  dataset:
    name: SimpleDataSet
    data_dir: ./train_data/rec/
    label_file_list: ["./train_data/rec/rec_gt_train.txt"]
    transforms:
      - DecodeImage: # load image
          img_mode: BGR
          channel_first: False
      - RecAug: 
      - CTCLabelEncode: # Class handling label
      - RecResizeImg:
          image_shape: [3, 32, 320]
      - KeepKeys:
          keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
  loader:
    shuffle: True
    batch_size_per_card: 32
    drop_last: True
    num_workers: 0

在这里插入图片描述
增强方法在PaddleOCR-release-2.4/ppocr/data/imaug/rec_img_aug.py里面。
代码如下:

class RecAug(object):
    def __init__(self, use_tia=True, aug_prob=0.4, **kwargs):
        self.use_tia = use_tia
        self.aug_prob = aug_prob

    def __call__(self, data):
        img = data['image']
        img = warp(img, 10, self.use_tia, self.aug_prob)
        data['image'] = img
        return data

猜你喜欢

转载自blog.csdn.net/hhhhhhhhhhwwwwwwwwww/article/details/125155386