Create blending weights for spatial tiles.
(
self,
tile_shape,
v,
h,
horizontal_tiles,
vertical_tiles,
spatial_overlap,
device,
dtype,
)
| 523 | return tile_out_latents |
| 524 | |
| 525 | def _create_spatial_weights( |
| 526 | self, |
| 527 | tile_shape, |
| 528 | v, |
| 529 | h, |
| 530 | horizontal_tiles, |
| 531 | vertical_tiles, |
| 532 | spatial_overlap, |
| 533 | device, |
| 534 | dtype, |
| 535 | ): |
| 536 | """Create blending weights for spatial tiles.""" |
| 537 | tile_weights = torch.ones(tile_shape, device=device, dtype=dtype) |
| 538 | |
| 539 | # Apply horizontal blending weights |
| 540 | if h > 0: # Left overlap |
| 541 | h_blend = torch.linspace(0, 1, spatial_overlap, device=device, dtype=dtype) |
| 542 | tile_weights[:, :, :, :, :spatial_overlap] *= h_blend.view(1, 1, 1, 1, -1) |
| 543 | if h < horizontal_tiles - 1: # Right overlap |
| 544 | h_blend = torch.linspace(1, 0, spatial_overlap, device=device, dtype=dtype) |
| 545 | tile_weights[:, :, :, :, -spatial_overlap:] *= h_blend.view(1, 1, 1, 1, -1) |
| 546 | |
| 547 | # Apply vertical blending weights |
| 548 | if v > 0: # Top overlap |
| 549 | v_blend = torch.linspace(0, 1, spatial_overlap, device=device, dtype=dtype) |
| 550 | tile_weights[:, :, :, :spatial_overlap, :] *= v_blend.view(1, 1, 1, -1, 1) |
| 551 | if v < vertical_tiles - 1: # Bottom overlap |
| 552 | v_blend = torch.linspace(1, 0, spatial_overlap, device=device, dtype=dtype) |
| 553 | tile_weights[:, :, :, -spatial_overlap:, :] *= v_blend.view(1, 1, 1, -1, 1) |
| 554 | |
| 555 | return tile_weights |
| 556 | |
| 557 | def _calculate_tile_seed( |
| 558 | self, |