mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 09:14:35 +02:00
@@ -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}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user