From 0bfda842c9a28f268e1cac962a5d1f09a4d24e1f Mon Sep 17 00:00:00 2001 From: Jianyong Chen <46100303+HolyCrap96@users.noreply.github.com> Date: Tue, 20 Apr 2021 04:09:09 -0500 Subject: [PATCH] fix #101: fix assertion (#103) * fix #101: fix assertion * fix #101: fix pytest --- .../pipelines/textdet_targets/textsnake_targets.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mmocr/datasets/pipelines/textdet_targets/textsnake_targets.py b/mmocr/datasets/pipelines/textdet_targets/textsnake_targets.py index eeebf5bd..73f4597c 100644 --- a/mmocr/datasets/pipelines/textdet_targets/textsnake_targets.py +++ b/mmocr/datasets/pipelines/textdet_targets/textsnake_targets.py @@ -188,6 +188,7 @@ class TextSnakeTargets(BaseTextDetTargets): assert line.shape[0] >= 2 assert line.shape[1] == 2 assert isinstance(n, int) + assert n > 0 length_list = [ norm(line[i + 1] - line[i]) for i in range(len(line) - 1) @@ -234,8 +235,8 @@ class TextSnakeTargets(BaseTextDetTargets): resampled_line2 (ndarray): The resampled line 2. """ - assert sideline1.ndim == sideline1.ndim == 2 - assert sideline1.shape[1] == sideline1.shape[1] == 2 + assert sideline1.ndim == sideline2.ndim == 2 + assert sideline1.shape[1] == sideline2.shape[1] == 2 assert sideline1.shape[0] >= 2 assert sideline2.shape[0] >= 2 assert isinstance(resample_step, float) @@ -250,7 +251,7 @@ class TextSnakeTargets(BaseTextDetTargets): ]) total_length = (length1 + length2) / 2 - resample_point_num = int(float(total_length) / resample_step) + resample_point_num = max(int(float(total_length) / resample_step), 1) resampled_line1 = self.resample_line(sideline1, resample_point_num) resampled_line2 = self.resample_line(sideline2, resample_point_num)