Skip to content

Commit

Permalink
fix(api): ensure panorama never generates a negative number of views
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Sep 5, 2023
1 parent 8e1f188 commit 944c92b
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions api/onnx_web/diffusers/pipelines/panorama.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,17 @@ def get_views(self, panorama_height, panorama_width, window_size, stride):
# Here, we define the mappings F_i (see Eq. 7 in the MultiDiffusion paper https://arxiv.org/abs/2302.08113)
panorama_height /= 8
panorama_width /= 8
num_blocks_height = (panorama_height - window_size) // stride + 1
num_blocks_width = (panorama_width - window_size) // stride + 1

num_blocks_height = abs((panorama_height - window_size) // stride) + 1
num_blocks_width = abs((panorama_width - window_size) // stride) + 1
total_num_blocks = int(num_blocks_height * num_blocks_width)
logger.debug(
"panorama generated %s views, %s by %s blocks",
total_num_blocks,
num_blocks_height,
num_blocks_width,
)

views = []
for i in range(total_num_blocks):
h_start = int((i // num_blocks_width) * stride)
Expand All @@ -361,12 +369,6 @@ def get_views(self, panorama_height, panorama_width, window_size, stride):
w_end = w_start + window_size
views.append((h_start, h_end, w_start, w_end))

logger.debug(
"panorama generated %s views, %s by %s blocks",
total_num_blocks,
num_blocks_height,
num_blocks_width,
)
return views

@torch.no_grad()
Expand Down

0 comments on commit 944c92b

Please sign in to comment.