forked from zhang0jhon/AttentionOCR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
91 lines (63 loc) · 1.92 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# -*- coding: utf-8 -*-
import os
from parse_dict import get_dict
# base dir for multiple text datasets
base_dir = '/opt/data/nfs/zhangjinjin/data/text/'
# font path for visualization
font_path = './fonts/cn/SourceHanSans-Normal.ttf'
# 'ocr' for inception model with padding image.
# 'ocr_with_normalized_bbox' for inception model with cropped text region for attention lstm.
model_name = 'ocr' # 'ocr_with_normalized_bbox'
# path for tensorboard summary and checkpoint path
summary_path = './checkpoint'
# tensorflow model name scope
name_scope = 'InceptionV4'
# path for numpy dict with processed image paths and labels used in dataset.py
dataset_name = 'icdar_datasets.npy'
# pb_path = './checkpoint/text_recognition_5435.pb'
# restore training parameters
restore_path = ''
starting_epoch = 1
# checkpoint_path = './checkpoint/model-10000'
# imagenet pretrain model path
pretrain_path = './pretrain/inception_v4.ckpt'
# label dict for text recognition
label_dict = get_dict()
reverse_label_dict = dict((v,k) for k,v in label_dict.items())
# gpu lists
gpus = [6, 7, 8, 9]
num_gpus = len(gpus)
num_classes = len(label_dict)
# max sequence length without EOS
seq_len = 32
# embedding size
wemb_size = 256
# lstm size
lstm_size = 512
# minimum cropped image size for data augment
crop_min_size = 224
# input image size
image_size = 256
# max random image offset for data augment
offset = 16
# CNN endpoint stride
stride = 8
# resize parameters for data augment
TRAIN_SHORT_EDGE_SIZE = 8
MAX_SIZE = image_size - 32
# training batch size
batch_size = 10 #12
# steps per training epoch in tensorpack
steps_per_epoch = 500
# max epochs
num_epochs = 1000
# model weight decay factor
weight_decay = 1e-5
# base learning rate
learning_rate = 1e-4 * num_gpus
# minimun learning rate for cosine decay learning rate
min_lr = learning_rate / 100
# warm up steps
warmup_steps = 1000
# thread for multi-thread data loading
num_threads = 16