fix texture tiling

Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
Vladimir Mandic
2025-04-30 09:44:34 -04:00
parent 473f394f97
commit a84b77d396
3 changed files with 6 additions and 6 deletions
+3 -5
View File
@@ -538,19 +538,17 @@ def set_latents(p):
return latents
last_circular = False
def apply_circular(enable, model):
global last_circular # pylint: disable=global-statement
def apply_circular(enable: bool, model):
if not hasattr(model, 'unet') or not hasattr(model, 'vae'):
return
if last_circular == enable:
if getattr(model, 'texture_tiling', False) == enable:
return
try:
for layer in [layer for layer in model.unet.modules() if type(layer) is torch.nn.Conv2d]:
layer.padding_mode = 'circular' if enable else 'zeros'
for layer in [layer for layer in model.vae.modules() if type(layer) is torch.nn.Conv2d]:
layer.padding_mode = 'circular' if enable else 'zeros'
last_circular = enable
model.texture_tiling = enable
except Exception as e:
debug(f"Diffusers tiling failed: {e}")