Skip to content
Merged
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
7 changes: 6 additions & 1 deletion src/layoutparser/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -363,6 +363,11 @@ 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
# 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(
zip(layout, box_color, box_alpha, box_width)
):
Expand Down