From 2c7c60bec20c8468f9da3b952a3e047a3d9f5e0d Mon Sep 17 00:00:00 2001 From: LDOUBLEV Date: Wed, 24 Feb 2021 20:36:52 +0800 Subject: [PATCH 1/2] fix issue #2072 --- deploy/cpp_infer/src/ocr_rec.cpp | 2 +- ppocr/data/imaug/make_shrink_map.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/deploy/cpp_infer/src/ocr_rec.cpp b/deploy/cpp_infer/src/ocr_rec.cpp index fa1e44ff..76873dad 100644 --- a/deploy/cpp_infer/src/ocr_rec.cpp +++ b/deploy/cpp_infer/src/ocr_rec.cpp @@ -76,7 +76,7 @@ void CRNNRecognizer::Run(std::vector>> boxes, float(*std::max_element(&predict_batch[n * predict_shape[2]], &predict_batch[(n + 1) * predict_shape[2]])); - if (argmax_idx > 0 && (!(i > 0 && argmax_idx == last_index))) { + if (argmax_idx > 0 && (!(n > 0 && argmax_idx == last_index))) { score += max_value; count += 1; str_res.push_back(label_list_[argmax_idx]); diff --git a/ppocr/data/imaug/make_shrink_map.py b/ppocr/data/imaug/make_shrink_map.py index e8e4d43f..ccdcd015 100644 --- a/ppocr/data/imaug/make_shrink_map.py +++ b/ppocr/data/imaug/make_shrink_map.py @@ -32,7 +32,6 @@ class MakeShrinkMap(object): text_polys, ignore_tags = self.validate_polygons(text_polys, ignore_tags, h, w) gt = np.zeros((h, w), dtype=np.float32) - # gt = np.zeros((1, h, w), dtype=np.float32) mask = np.ones((h, w), dtype=np.float32) for i in range(len(text_polys)): polygon = text_polys[i] @@ -51,7 +50,8 @@ class MakeShrinkMap(object): shrinked = [] # Increase the shrink ratio every time we get multiple polygon returned back - possible_ratios = np.arange(self.shrink_ratio, 1, self.shrink_ratio) + possible_ratios = np.arange(self.shrink_ratio, 1, + self.shrink_ratio) np.append(possible_ratios, 1) # print(possible_ratios) for ratio in possible_ratios: @@ -104,4 +104,4 @@ class MakeShrinkMap(object): edge += (polygon[next_index, 0] - polygon[i, 0]) * ( polygon[next_index, 1] - polygon[i, 1]) - return edge / 2. \ No newline at end of file + return edge / 2. From cf2bd5298922b90e7a634d99a1c4a69825189d2c Mon Sep 17 00:00:00 2001 From: LDOUBLEV Date: Wed, 24 Feb 2021 20:38:07 +0800 Subject: [PATCH 2/2] fix issue #2080 --- tools/infer/predict_det.py | 5 +---- tools/infer_det.py | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/tools/infer/predict_det.py b/tools/infer/predict_det.py index 76c6a447..b14825bd 100755 --- a/tools/infer/predict_det.py +++ b/tools/infer/predict_det.py @@ -39,10 +39,7 @@ class TextDetector(object): self.args = args self.det_algorithm = args.det_algorithm pre_process_list = [{ - 'DetResizeForTest': { - 'limit_side_len': args.det_limit_side_len, - 'limit_type': args.det_limit_type - } + 'DetResizeForTest': None }, { 'NormalizeImage': { 'std': [0.229, 0.224, 0.225], diff --git a/tools/infer_det.py b/tools/infer_det.py index d890970e..913d617d 100755 --- a/tools/infer_det.py +++ b/tools/infer_det.py @@ -97,7 +97,7 @@ def main(): preds = model(images) post_result = post_process_class(preds, shape_list) boxes = post_result[0]['points'] - # write resule + # write result dt_boxes_json = [] for box in boxes: tmp_json = {"transcription": ""}