From 80107a8bb7ec0b8d490fb21dfaebdbf2e729d58f Mon Sep 17 00:00:00 2001 From: Shannon Shen <22512825+lolipopshock@users.noreply.github.com> Date: Tue, 5 Apr 2022 16:39:04 -0400 Subject: [PATCH 1/2] fix #131 --- src/layoutparser/visualization.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/layoutparser/visualization.py b/src/layoutparser/visualization.py index 483ac3d..0d10abf 100644 --- a/src/layoutparser/visualization.py +++ b/src/layoutparser/visualization.py @@ -318,7 +318,7 @@ def draw_box( font_obj = _create_font_object(id_font_size, id_font_path) if box_alpha is None: - box_alpha = [0] + box_alpha = [0] * len(layout) else: if isinstance(box_alpha, (float, int)): box_alpha = [box_alpha] * len(layout) @@ -363,6 +363,9 @@ def draw_box( f"The number of colors {len(box_color)} is not equal to the number of blocks {len(layout)}" ) + # A post check of the lengths of the input lists + assert len(layout) == len(box_color) == len(box_alpha) == len(box_width) + for idx, (ele, color, alpha, width) in enumerate( zip(layout, box_color, box_alpha, box_width) ): From 68c3a1c0db7e5809349b10dd95d6c3e67aa69a0d Mon Sep 17 00:00:00 2001 From: Shannon Shen <22512825+lolipopshock@users.noreply.github.com> Date: Tue, 5 Apr 2022 16:54:15 -0400 Subject: [PATCH 2/2] more comments --- src/layoutparser/visualization.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/layoutparser/visualization.py b/src/layoutparser/visualization.py index 0d10abf..002d063 100644 --- a/src/layoutparser/visualization.py +++ b/src/layoutparser/visualization.py @@ -364,6 +364,8 @@ def draw_box( ) # A post check of the lengths of the input lists + # To support more versions of python, we do not use + # zip(*, strict=True) assert len(layout) == len(box_color) == len(box_alpha) == len(box_width) for idx, (ele, color, alpha, width) in enumerate(