Skip to content
Open
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
9 changes: 5 additions & 4 deletions inference/core/utils/drawing.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,13 @@ def _establish_grid_size(


def _negotiate_grid_size(images: List[np.ndarray]) -> Tuple[int, int]:
if len(images) <= MAX_COLUMNS_FOR_SINGLE_ROW_GRID:
return 1, len(images)
nearest_sqrt = math.ceil(np.sqrt(len(images)))
num_images = len(images)
if num_images <= MAX_COLUMNS_FOR_SINGLE_ROW_GRID:
return 1, num_images
nearest_sqrt = math.ceil(math.sqrt(num_images))
proposed_columns = nearest_sqrt
proposed_rows = nearest_sqrt
while proposed_columns * (proposed_rows - 1) >= len(images):
while proposed_columns * (proposed_rows - 1) >= num_images:
proposed_rows -= 1
return proposed_rows, proposed_columns

Expand Down
Loading