0. 制作docker环境

sudo docker run -itd  -h simpleedu_paddleocr_wxd --name simpleedu_paddleocr_wxd --restart=always -v /kolla/wxd/opt/wxd/dockerfile/paddleocr:/home/simpleai/workspace/work/paddleocr -p 28866:8866 -p 28867:8867 -p 28888:8888 227dfbb7853c

1. 制作数据集

2. 训练自己的文本检测模型

python3 tools/train.py -c configs/det/ch_ppocr_v2.0/ch_det_res18_db_v2.0.yml

ch_ppocr_v2.0/ch_det_res18_db_v2.0.yml配置如下

Global:
  use_gpu: true
  epoch_num: 1200
  log_smooth_window: 20
  print_batch_step: 2
  save_model_dir: /home/simpleai/workspace/work/paddleocr/model/train_model/ch_db_res18/
  save_epoch_step: 1200
  # evaluation is run every 5000 iterations after the 4000th iteration
  eval_batch_step: [3000, 2000]
  cal_metric_during_train: False
  pretrained_model: /home/simpleai/workspace/work/paddleocr/model/pretrain_models/text_localization/ch_ppocr_server_v2.0_det/ch_ppocr_server_v2.0_det_train/best_accuracy
  checkpoints:
  save_inference_dir:
  use_visualdl: False
  infer_img: doc/imgs_en/img_10.jpg
  save_res_path: ./output/det_db/predicts_db.txt

Architecture:
  model_type: det
  algorithm: DB
  Transform:
  Backbone:
    name: ResNet
    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: /home/simpleai/workspace/work/paddleocr/data/text_localization/
    label_file_list:
      - /home/simpleai/workspace/work/paddleocr/data/text_localization/train_label.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: 2
    num_workers: 0

Eval:
  dataset:
    name: SimpleDataSet
    data_dir: /home/simpleai/workspace/work/paddleocr/data/text_localization/
    label_file_list:
      - /home/simpleai/workspace/work/paddleocr/data/text_localization/test_label.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: 0

3. 训练自己的文本识别模型

4. 模型转换

5. 模型部署

10. 错误解决

  • 1. ImportError: libGL.so.1: cannot open shared object file: No such file or directory
sudo apt update
sudo apt install libgl1-mesa-glx
  • 2. ImportError: libgthread-2.0.so.0: cannot open shared object file: No such file or directory
sudo apt update
sudo apt install libglib2.0-dev
  • 3. libcudart.so.10.2: cannot open shared object file: No such file or directory
未完待续
  • 3. pip安装中https不能访问问题
sudo echo "nameserver 8.8.8.8" | tee /etc/resolv.conf > /dev/null

参考:
1:PaddleOCR训练自己的数据集
2:PaddleOCR v1.1 使用教程

GitHub 加速计划 / pa / PaddleOCR
50
11
下载
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)
最近提交(Master分支:4 个月前 )
0d41ffc9 4 天前
d523388e * add ppformulanet * rename loss * modify doc * add export code * modify yaml for global ref 5 天前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐