Skip to content

Commit

Permalink
Fix temporal tiling for decoder, remove redundant tiles. (#6306)
Browse files Browse the repository at this point in the history
This commit fixes the temporal tile size calculation, and removes
a redundant tile at the end of the range when its elements are
completely covered by the previous tile.

Co-authored-by: Andrew Kvochko <[email protected]>
  • Loading branch information
kvochko and Andrew Kvochko authored Jan 1, 2025
1 parent 79eea51 commit 0f11d60
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion comfy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ def mult_list_upscale(a):
out = torch.zeros([s.shape[0], out_channels] + mult_list_upscale(s.shape[2:]), device=output_device)
out_div = torch.zeros([s.shape[0], out_channels] + mult_list_upscale(s.shape[2:]), device=output_device)

positions = [range(0, s.shape[d+2], tile[d] - overlap[d]) if s.shape[d+2] > tile[d] else [0] for d in range(dims)]
positions = [range(0, s.shape[d+2] - overlap[d], tile[d] - overlap[d]) if s.shape[d+2] > tile[d] else [0] for d in range(dims)]

for it in itertools.product(*positions):
s_in = s
Expand Down
2 changes: 1 addition & 1 deletion nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def decode(self, vae, samples, tile_size, overlap=64, temporal_size=64, temporal
temporal_compression = vae.temporal_compression_decode()
if temporal_compression is not None:
temporal_size = max(2, temporal_size // temporal_compression)
temporal_overlap = min(1, temporal_size // 2, temporal_overlap // temporal_compression)
temporal_overlap = max(1, min(temporal_size // 2, temporal_overlap // temporal_compression))
else:
temporal_size = None
temporal_overlap = None
Expand Down

0 comments on commit 0f11d60

Please sign in to comment.