Skip to content

Commit

Permalink
Merge pull request #17 from LDOUBLEV/fixocr
Browse files Browse the repository at this point in the history
fix rec bug and delete infer/predict_eval.py
  • Loading branch information
dyning committed May 14, 2020
2 parents 80fdceb + c65f330 commit adbe225
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 167 deletions.
92 changes: 0 additions & 92 deletions tools/infer/predict_eval.py

This file was deleted.

72 changes: 0 additions & 72 deletions tools/infer/predict_eval_new.py

This file was deleted.

12 changes: 9 additions & 3 deletions tools/infer/predict_rec.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ def __init__(self, args):
char_ops_params['loss_type'] = 'ctc'
self.char_ops = CharacterOps(char_ops_params)

def resize_norm_img(self, img):
def resize_norm_img(self, img, max_wh_ratio):
imgC, imgH, imgW = self.rec_image_shape
imgW = int(32 * max_wh_ratio)
h = img.shape[0]
w = img.shape[1]
ratio = w / float(h)
Expand All @@ -56,14 +57,19 @@ def resize_norm_img(self, img):

def __call__(self, img_list):
img_num = len(img_list)
batch_num = 15
batch_num = 30
rec_res = []
predict_time = 0
for beg_img_no in range(0, img_num, batch_num):
end_img_no = min(img_num, beg_img_no + batch_num)
norm_img_batch = []
max_wh_ratio = 0
for ino in range(beg_img_no, end_img_no):
norm_img = self.resize_norm_img(img_list[ino])
h, w = img_list[ino].shape[0:2]
wh_ratio = w * 1.0 / h
max_wh_ratio = max(max_wh_ratio, wh_ratio)
for ino in range(beg_img_no, end_img_no):
norm_img = self.resize_norm_img(img_list[ino], max_wh_ratio)
norm_img = norm_img[np.newaxis, :]
norm_img_batch.append(norm_img)
norm_img_batch = np.concatenate(norm_img_batch)
Expand Down

0 comments on commit adbe225

Please sign in to comment.