Skip to content

Commit 338ba3e

Browse files
committed
upload PaddleOCR code
1 parent bc93c54 commit 338ba3e

File tree

84 files changed

+15543
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+15543
-0
lines changed

.pre-commit-config.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
- repo: https://github.com/PaddlePaddle/mirrors-yapf.git
2+
sha: 0d79c0c469bab64f7229c9aca2b1186ef47f0e37
3+
hooks:
4+
- id: yapf
5+
files: \.py$
6+
- repo: https://github.com/pre-commit/pre-commit-hooks
7+
sha: a11d9314b22d8f8c7556443875b731ef05965464
8+
hooks:
9+
- id: check-merge-conflict
10+
- id: check-symlinks
11+
- id: detect-private-key
12+
files: (?!.*paddle)^.*$
13+
- id: end-of-file-fixer
14+
files: \.md$
15+
- id: trailing-whitespace
16+
files: \.md$
17+
- repo: https://github.com/Lucas-C/pre-commit-hooks
18+
sha: v1.0.1
19+
hooks:
20+
- id: forbid-crlf
21+
files: \.md$
22+
- id: remove-crlf
23+
files: \.md$
24+
- id: forbid-tabs
25+
files: \.md$
26+
- id: remove-tabs
27+
files: \.md$
28+
- repo: local
29+
hooks:
30+
- id: clang-format
31+
name: clang-format
32+
description: Format files with ClangFormat
33+
entry: bash .clang_format.hook -i
34+
language: system
35+
files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|cuh|proto)$

.style.yapf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[style]
2+
based_on_style = pep8
3+
column_limit = 80

configs/det/det_db_icdar15_reader.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
TrainReader:
2+
reader_function: ppocr.data.det.dataset_traversal,TrainReader
3+
process_function: ppocr.data.det.db_process,DBProcessTrain
4+
num_workers: 8
5+
img_set_dir: ./train_data/icdar2015/text_localization/
6+
label_file_path: ./train_data/icdar2015/text_localization/train_icdar2015_label.txt
7+
8+
EvalReader:
9+
reader_function: ppocr.data.det.dataset_traversal,EvalTestReader
10+
process_function: ppocr.data.det.db_process,DBProcessTest
11+
img_set_dir: ./train_data/icdar2015/text_localization/
12+
label_file_path: ./train_data/icdar2015/text_localization/test_icdar2015_label.txt
13+
test_image_shape: [736, 1280]
14+
15+
TestReader:
16+
reader_function: ppocr.data.det.dataset_traversal,EvalTestReader
17+
process_function: ppocr.data.det.db_process,DBProcessTest
18+
single_img_path:
19+
img_set_dir: ./train_data/icdar2015/text_localization/
20+
label_file_path: ./train_data/icdar2015/text_localization/test_icdar2015_label.txt
21+
test_image_shape: [736, 1280]
22+
do_eval: True

configs/det/det_db_mv3.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
Global:
2+
algorithm: DB
3+
use_gpu: true
4+
epoch_num: 1200
5+
log_smooth_window: 20
6+
print_batch_step: 2
7+
save_model_dir: output
8+
save_epoch_step: 200
9+
eval_batch_step: 5000
10+
train_batch_size_per_card: 16
11+
test_batch_size_per_card: 16
12+
image_shape: [3, 640, 640]
13+
reader_yml: ./configs/det/det_db_icdar15_reader.yml
14+
pretrain_weights: ./pretrain_models/MobileNetV3_pretrained/MobileNetV3_large_x0_5_pretrained/
15+
save_res_path: ./output/predicts_db.txt
16+
17+
Architecture:
18+
function: ppocr.modeling.architectures.det_model,DetModel
19+
20+
Backbone:
21+
function: ppocr.modeling.backbones.det_mobilenet_v3,MobileNetV3
22+
scale: 0.5
23+
model_name: large
24+
25+
Head:
26+
function: ppocr.modeling.heads.det_db_head,DBHead
27+
model_name: large
28+
k: 50
29+
inner_channels: 96
30+
out_channels: 2
31+
32+
Loss:
33+
function: ppocr.modeling.losses.det_db_loss,DBLoss
34+
balance_loss: true
35+
main_loss_type: DiceLoss
36+
alpha: 5
37+
beta: 10
38+
ohem_ratio: 3
39+
40+
Optimizer:
41+
function: ppocr.optimizer,AdamDecay
42+
base_lr: 0.001
43+
beta1: 0.9
44+
beta2: 0.999
45+
46+
PostProcess:
47+
function: ppocr.postprocess.db_postprocess,DBPostProcess
48+
thresh: 0.3
49+
box_thresh: 0.7
50+
max_candidates: 1000
51+
unclip_ratio: 1.5

configs/det/det_db_r50_vd.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
Global:
2+
algorithm: DB
3+
use_gpu: true
4+
epoch_num: 1200
5+
log_smooth_window: 20
6+
print_batch_step: 2
7+
save_model_dir: output
8+
save_epoch_step: 200
9+
eval_batch_step: 5000
10+
train_batch_size_per_card: 8
11+
test_batch_size_per_card: 16
12+
image_shape: [3, 640, 640]
13+
reader_yml: ./configs/det/det_db_icdar15_reader.yml
14+
pretrain_weights: ./pretrain_models/ResNet50_vd_pretrained/
15+
save_res_path: ./output/predicts_db.txt
16+
17+
Architecture:
18+
function: ppocr.modeling.architectures.det_model,DetModel
19+
20+
Backbone:
21+
function: ppocr.modeling.backbones.det_resnet_vd,ResNet
22+
layers: 50
23+
24+
Head:
25+
function: ppocr.modeling.heads.det_db_head,DBHead
26+
model_name: large
27+
k: 50
28+
inner_channels: 256
29+
out_channels: 2
30+
31+
Loss:
32+
function: ppocr.modeling.losses.det_db_loss,DBLoss
33+
balance_loss: true
34+
main_loss_type: DiceLoss
35+
alpha: 5
36+
beta: 10
37+
ohem_ratio: 3
38+
39+
Optimizer:
40+
function: ppocr.optimizer,AdamDecay
41+
base_lr: 0.001
42+
beta1: 0.9
43+
beta2: 0.999
44+
45+
PostProcess:
46+
function: ppocr.postprocess.db_postprocess,DBPostProcess
47+
thresh: 0.3
48+
box_thresh: 0.7
49+
max_candidates: 1000
50+
unclip_ratio: 1.5
51+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
TrainReader:
2+
reader_function: ppocr.data.det.dataset_traversal,TrainReader
3+
process_function: ppocr.data.det.east_process,EASTProcessTrain
4+
num_workers: 8
5+
img_set_dir: ./train_data/icdar2015/text_localization/
6+
label_file_path: ./train_data/icdar2015/text_localization/train_icdar2015_label.txt
7+
background_ratio: 0.125
8+
min_crop_side_ratio: 0.1
9+
min_text_size: 10
10+
11+
EvalReader:
12+
reader_function: ppocr.data.det.dataset_traversal,EvalTestReader
13+
process_function: ppocr.data.det.east_process,EASTProcessTest
14+
img_set_dir: ./train_data/icdar2015/text_localization/
15+
label_file_path: ./train_data/icdar2015/text_localization/test_icdar2015_label.txt
16+
17+
TestReader:
18+
reader_function: ppocr.data.det.dataset_traversal,EvalTestReader
19+
process_function: ppocr.data.det.east_process,EASTProcessTest
20+
single_img_path:
21+
img_set_dir: ./train_data/icdar2015/text_localization/
22+
label_file_path: ./train_data/icdar2015/text_localization/test_icdar2015_label.txt
23+
do_eval: True

configs/det/det_east_mv3.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
Global:
2+
algorithm: EAST
3+
use_gpu: true
4+
epoch_num: 100000
5+
log_smooth_window: 20
6+
print_batch_step: 5
7+
save_model_dir: output
8+
save_epoch_step: 200
9+
eval_batch_step: 5000
10+
train_batch_size_per_card: 16
11+
test_batch_size_per_card: 16
12+
image_shape: [3, 512, 512]
13+
reader_yml: ./configs/det/det_east_icdar15_reader.yml
14+
pretrain_weights: ./pretrain_models/MobileNetV3_pretrained/MobileNetV3_large_x0_5_pretrained/
15+
save_res_path: ./output/predicts_east.txt
16+
17+
Architecture:
18+
function: ppocr.modeling.architectures.det_model,DetModel
19+
20+
Backbone:
21+
function: ppocr.modeling.backbones.det_mobilenet_v3,MobileNetV3
22+
scale: 0.5
23+
model_name: large
24+
25+
Head:
26+
function: ppocr.modeling.heads.det_east_head,EASTHead
27+
model_name: small
28+
29+
Loss:
30+
function: ppocr.modeling.losses.det_east_loss,EASTLoss
31+
32+
Optimizer:
33+
function: ppocr.optimizer,AdamDecay
34+
base_lr: 0.001
35+
beta1: 0.9
36+
beta2: 0.999
37+
38+
PostProcess:
39+
function: ppocr.postprocess.east_postprocess,EASTPostPocess
40+
score_thresh: 0.8
41+
cover_thresh: 0.1
42+
nms_thresh: 0.2
43+

configs/det/det_east_r50_vd.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
Global:
2+
algorithm: EAST
3+
use_gpu: true
4+
epoch_num: 100000
5+
log_smooth_window: 20
6+
print_batch_step: 5
7+
save_model_dir: output
8+
save_epoch_step: 200
9+
eval_batch_step: 5000
10+
train_batch_size_per_card: 8
11+
test_batch_size_per_card: 16
12+
image_shape: [3, 512, 512]
13+
reader_yml: ./configs/det/det_east_icdar15_reader.yml
14+
pretrain_weights: ./pretrain_models/ResNet50_vd_pretrained/
15+
save_res_path: ./output/predicts_east.txt
16+
17+
Architecture:
18+
function: ppocr.modeling.architectures.det_model,DetModel
19+
20+
Backbone:
21+
function: ppocr.modeling.backbones.det_resnet_vd,ResNet
22+
layers: 50
23+
24+
Head:
25+
function: ppocr.modeling.heads.det_east_head,EASTHead
26+
model_name: large
27+
28+
Loss:
29+
function: ppocr.modeling.losses.det_east_loss,EASTLoss
30+
31+
Optimizer:
32+
function: ppocr.optimizer,AdamDecay
33+
base_lr: 0.001
34+
beta1: 0.9
35+
beta2: 0.999
36+
37+
PostProcess:
38+
function: ppocr.postprocess.east_postprocess,EASTPostPocess
39+
score_thresh: 0.8
40+
cover_thresh: 0.1
41+
nms_thresh: 0.2
42+

configs/rec/rec_benchmark_reader.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
TrainReader:
2+
reader_function: ppocr.data.rec.dataset_traversal,LMDBReader
3+
num_workers: 8
4+
lmdb_sets_dir: ./train_data/data_lmdb_release/training/
5+
6+
EvalReader:
7+
reader_function: ppocr.data.rec.dataset_traversal,LMDBReader
8+
lmdb_sets_dir: ./train_data/data_lmdb_release/validation/
9+
10+
TestReader:
11+
reader_function: ppocr.data.rec.dataset_traversal,LMDBReader
12+
lmdb_sets_dir: ./train_data/data_lmdb_release/evaluation/
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
Global:
2+
algorithm: CRNN
3+
dataset: common
4+
use_gpu: true
5+
epoch_num: 300
6+
log_smooth_window: 20
7+
print_batch_step: 10
8+
save_model_dir: output
9+
save_epoch_step: 3
10+
eval_batch_step: 2000
11+
train_batch_size_per_card: 256
12+
test_batch_size_per_card: 256
13+
image_shape: [3, 32, 100]
14+
max_text_length: 25
15+
character_type: ch
16+
character_dict_path: ./ppocr/utils/ppocr_keys_v1.txt
17+
loss_type: ctc
18+
reader_yml: ./configs/rec/rec_chinese_reader.yml
19+
pretrain_weights:
20+
21+
Architecture:
22+
function: ppocr.modeling.architectures.rec_model,RecModel
23+
24+
Backbone:
25+
function: ppocr.modeling.backbones.rec_mobilenet_v3,MobileNetV3
26+
scale: 0.5
27+
model_name: small
28+
29+
Head:
30+
function: ppocr.modeling.heads.rec_ctc_head,CTCPredict
31+
encoder_type: rnn
32+
SeqRNN:
33+
hidden_size: 48
34+
35+
Loss:
36+
function: ppocr.modeling.losses.rec_ctc_loss,CTCLoss
37+
38+
Optimizer:
39+
function: ppocr.optimizer,AdamDecay
40+
base_lr: 0.001
41+
beta1: 0.9
42+
beta2: 0.999

0 commit comments

Comments
 (0)