Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixocr #5

Merged
merged 4 commits into from
May 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions configs/det/det_db_mv3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Global:
epoch_num: 1200
log_smooth_window: 20
print_batch_step: 2
save_model_dir: output
save_model_dir: ./output/det_db/
save_epoch_step: 200
eval_batch_step: 5000
train_batch_size_per_card: 16
Expand All @@ -13,7 +13,7 @@ Global:
reader_yml: ./configs/det/det_db_icdar15_reader.yml
pretrain_weights: ./pretrain_models/MobileNetV3_pretrained/MobileNetV3_large_x0_5_pretrained/
checkpoints:
save_res_path: ./output/predicts_db.txt
save_res_path: ./output/det_db/predicts_db.txt
save_inference_dir:

Architecture:
Expand Down
8 changes: 5 additions & 3 deletions configs/det/det_db_r50_vd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ Global:
epoch_num: 1200
log_smooth_window: 20
print_batch_step: 2
save_model_dir: output
save_model_dir: ./output/det_db/
save_epoch_step: 200
eval_batch_step: 5000
train_batch_size_per_card: 8
test_batch_size_per_card: 16
image_shape: [3, 640, 640]
reader_yml: ./configs/det/det_db_icdar15_reader.yml
pretrain_weights: ./pretrain_models/ResNet50_vd_pretrained/
save_res_path: ./output/predicts_db.txt

save_res_path: ./output/det_db/predicts_db.txt
checkpoints:
save_inference_dir:

Architecture:
function: ppocr.modeling.architectures.det_model,DetModel

Expand Down
6 changes: 4 additions & 2 deletions configs/det/det_east_mv3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ Global:
epoch_num: 100000
log_smooth_window: 20
print_batch_step: 5
save_model_dir: output
save_model_dir: ./output/det_east/
save_epoch_step: 200
eval_batch_step: 5000
train_batch_size_per_card: 16
test_batch_size_per_card: 16
image_shape: [3, 512, 512]
reader_yml: ./configs/det/det_east_icdar15_reader.yml
pretrain_weights: ./pretrain_models/MobileNetV3_pretrained/MobileNetV3_large_x0_5_pretrained/
save_res_path: ./output/predicts_east.txt
checkpoints:
save_res_path: ./output/det_east/predicts_east.txt
save_inference_dir:

Architecture:
function: ppocr.modeling.architectures.det_model,DetModel
Expand Down
8 changes: 5 additions & 3 deletions configs/det/det_east_r50_vd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ Global:
epoch_num: 100000
log_smooth_window: 20
print_batch_step: 5
save_model_dir: output
save_model_dir: ./output/det_east/
save_epoch_step: 200
eval_batch_step: 5000
train_batch_size_per_card: 8
test_batch_size_per_card: 16
image_shape: [3, 512, 512]
reader_yml: ./configs/det/det_east_icdar15_reader.yml
pretrain_weights: ./pretrain_models/ResNet50_vd_pretrained/
save_res_path: ./output/predicts_east.txt

save_res_path: ./output/det_east/predicts_east.txt
checkpoints:
save_inference_dir:

Architecture:
function: ppocr.modeling.architectures.det_model,DetModel

Expand Down
6 changes: 4 additions & 2 deletions configs/rec/rec_mv3_none_bilstm_ctc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Global:
epoch_num: 72
log_smooth_window: 20
print_batch_step: 10
save_model_dir: output
save_model_dir: output/rec_CRNN
save_epoch_step: 3
eval_batch_step: 2000
train_batch_size_per_card: 256
Expand All @@ -14,7 +14,9 @@ Global:
character_type: en
loss_type: ctc
reader_yml: ./configs/rec/rec_benchmark_reader.yml
pretrain_weights:
pretrain_weights:
checkpoints:
save_inference_dir:

Architecture:
function: ppocr.modeling.architectures.rec_model,RecModel
Expand Down
6 changes: 4 additions & 2 deletions configs/rec/rec_mv3_none_none_ctc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Global:
epoch_num: 72
log_smooth_window: 20
print_batch_step: 10
save_model_dir: output
save_model_dir: output/rec_Rosetta
save_epoch_step: 3
eval_batch_step: 2000
train_batch_size_per_card: 256
Expand All @@ -15,7 +15,9 @@ Global:
loss_type: ctc
reader_yml: ./configs/rec/rec_benchmark_reader.yml
pretrain_weights:

checkpoints:
save_inference_dir:

Architecture:
function: ppocr.modeling.architectures.rec_model,RecModel

Expand Down
6 changes: 4 additions & 2 deletions configs/rec/rec_mv3_tps_bilstm_attn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Global:
epoch_num: 72
log_smooth_window: 20
print_batch_step: 10
save_model_dir: output
save_model_dir: output/rec_RARE
save_epoch_step: 3
eval_batch_step: 2000
train_batch_size_per_card: 256
Expand All @@ -14,7 +14,9 @@ Global:
character_type: en
loss_type: attention
reader_yml: ./configs/rec/rec_benchmark_reader.yml
pretrain_weights:
pretrain_weights:
checkpoints:
save_inference_dir:

Architecture:
function: ppocr.modeling.architectures.rec_model,RecModel
Expand Down
7 changes: 5 additions & 2 deletions configs/rec/rec_mv3_tps_bilstm_ctc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Global:
epoch_num: 72
log_smooth_window: 20
print_batch_step: 10
save_model_dir: output
save_model_dir: output/rec_STARNet
save_epoch_step: 3
eval_batch_step: 2000
train_batch_size_per_card: 256
Expand All @@ -14,7 +14,10 @@ Global:
character_type: en
loss_type: ctc
reader_yml: ./configs/rec/rec_benchmark_reader.yml
pretrain_weights:
pretrain_weights:
checkpoints:
save_inference_dir:


Architecture:
function: ppocr.modeling.architectures.rec_model,RecModel
Expand Down
6 changes: 4 additions & 2 deletions configs/rec/rec_r34_vd_none_bilstm_ctc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Global:
epoch_num: 72
log_smooth_window: 20
print_batch_step: 10
save_model_dir: output
save_model_dir: output/rec_CRNN
save_epoch_step: 3
eval_batch_step: 2000
train_batch_size_per_card: 256
Expand All @@ -14,7 +14,9 @@ Global:
character_type: en
loss_type: ctc
reader_yml: ./configs/rec/rec_benchmark_reader.yml
pretrain_weights:
pretrain_weights:
checkpoints:
save_inference_dir:

Architecture:
function: ppocr.modeling.architectures.rec_model,RecModel
Expand Down
6 changes: 4 additions & 2 deletions configs/rec/rec_r34_vd_none_none_ctc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Global:
epoch_num: 72
log_smooth_window: 20
print_batch_step: 10
save_model_dir: output
save_model_dir: output/rec_Rosetta
save_epoch_step: 3
eval_batch_step: 2000
train_batch_size_per_card: 256
Expand All @@ -14,7 +14,9 @@ Global:
character_type: en
loss_type: ctc
reader_yml: ./configs/rec/rec_benchmark_reader.yml
pretrain_weights:
pretrain_weights:
checkpoints:
save_inference_dir:

Architecture:
function: ppocr.modeling.architectures.rec_model,RecModel
Expand Down
6 changes: 4 additions & 2 deletions configs/rec/rec_r34_vd_tps_bilstm_attn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Global:
epoch_num: 72
log_smooth_window: 20
print_batch_step: 10
save_model_dir: output
save_model_dir: output/rec_RARE
save_epoch_step: 3
eval_batch_step: 2000
train_batch_size_per_card: 256
Expand All @@ -14,7 +14,9 @@ Global:
character_type: en
loss_type: attention
reader_yml: ./configs/rec/rec_benchmark_reader.yml
pretrain_weights:
pretrain_weights:
checkpoints:
save_inference_dir:

Architecture:
function: ppocr.modeling.architectures.rec_model,RecModel
Expand Down
4 changes: 3 additions & 1 deletion configs/rec/rec_r34_vd_tps_bilstm_ctc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Global:
epoch_num: 72
log_smooth_window: 20
print_batch_step: 10
save_model_dir: output
save_model_dir: output/rec_STARNet
save_epoch_step: 3
eval_batch_step: 2000
train_batch_size_per_card: 256
Expand All @@ -15,6 +15,8 @@ Global:
loss_type: ctc
reader_yml: ./configs/rec/rec_benchmark_reader.yml
pretrain_weights:
checkpoints:
save_inference_dir:

Architecture:
function: ppocr.modeling.architectures.rec_model,RecModel
Expand Down
2 changes: 1 addition & 1 deletion ppocr/modeling/heads/det_db_head.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def __call__(self, conv_features, mode="train"):
fuse = fluid.layers.concat(input=[p5, p4, p3, p2], axis=1)
shrink_maps = self.binarize(fuse)
if mode != "train":
return shrink_maps
return {"maps", shrink_maps}
threshold_maps = self.thresh(fuse)
binary_maps = self.step_function(shrink_maps, threshold_maps)
y = fluid.layers.concat(
Expand Down
1 change: 1 addition & 0 deletions ppocr/postprocess/db_postprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def box_score_fast(self, bitmap, _box):

def __call__(self, outs_dict, ratio_list):
pred = outs_dict['maps']

pred = pred[:, 0, :, :]
segmentation = pred > self.thresh

Expand Down
9 changes: 5 additions & 4 deletions tools/infer/predict_det.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import numpy as np
import math
import time
import sys


class TextDetector(object):
Expand Down Expand Up @@ -52,10 +53,10 @@ def __init__(self, args):
utility.create_predictor(args, mode="det")

def order_points_clockwise(self, pts):
#######
## https://github.com/jrosebr1/imutils/blob/master/imutils/perspective.py
########
"""
reference from: https://github.com/jrosebr1/imutils/blob/master/imutils/perspective.py
# sort the points based on their x-coordinates
"""
xSorted = pts[np.argsort(pts[:, 0]), :]

# grab the left-most and right-most points from the sorted
Expand Down Expand Up @@ -141,7 +142,7 @@ def __call__(self, img):
outs_dict['f_score'] = outputs[0]
outs_dict['f_geo'] = outputs[1]
else:
outs_dict['maps'] = [outputs[0]]
outs_dict['maps'] = outputs[0]
dt_boxes_list = self.postprocess_op(outs_dict, [ratio_list])
dt_boxes = dt_boxes_list[0]
dt_boxes = self.filter_tag_det_res(dt_boxes, ori_im.shape)
Expand Down
4 changes: 4 additions & 0 deletions tools/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ def train_eval_det_run(config, exe, train_info_dict, eval_info_dict):
eval_batch_step = config['Global']['eval_batch_step']
save_epoch_step = config['Global']['save_epoch_step']
save_model_dir = config['Global']['save_model_dir']
if not os.path.exists(save_model_dir):
os.makedirs(save_model_dir)
train_stats = TrainingStats(log_smooth_window,
train_info_dict['fetch_name_list'])
best_eval_hmean = -1
Expand Down Expand Up @@ -282,6 +284,8 @@ def train_eval_rec_run(config, exe, train_info_dict, eval_info_dict):
eval_batch_step = config['Global']['eval_batch_step']
save_epoch_step = config['Global']['save_epoch_step']
save_model_dir = config['Global']['save_model_dir']
if not os.path.exists(save_model_dir):
os.makedirs(save_model_dir)
train_stats = TrainingStats(log_smooth_window, ['loss', 'acc'])
best_eval_acc = -1
best_batch_id = 0
Expand Down