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
12 changes: 6 additions & 6 deletions inference/core/utils/drawing.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +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)))
images_len = len(images)
if images_len <= MAX_COLUMNS_FOR_SINGLE_ROW_GRID:
return 1, images_len
nearest_sqrt = math.ceil(math.sqrt(images_len))
proposed_columns = nearest_sqrt
proposed_rows = nearest_sqrt
while proposed_columns * (proposed_rows - 1) >= len(images):
proposed_rows -= 1
# Calculate the minimal number of rows needed for given columns and images
proposed_rows = (images_len + proposed_columns - 1) // proposed_columns
return proposed_rows, proposed_columns


Expand Down
Loading