It change UNetModel and VAE Conv2d Layer into circular padding mode that make any text2image process generate seamless patten
2024-6-19 Update:
SeamlessVae Node:
patcher = vae.patcher.clone()
for layer in patcher.model.modules():
if (isinstance(layer, nn.Conv2d)):
pre_hook = layer.register_forward_pre_hook(vae_circular_hook_pre)
hook = layer.register_forward_hook(vae_circular_hook)
setattr(layer, 'circular_pre_hook', pre_hook)
setattr(layer, 'circular_hook', hook)
vae.patcher = patcher
vae.first_stage_model = patcher.model
SeamlessKSampler Node:
padding_mode_list = []
for layer in model.model.diffusion_model.modules():
if (isinstance(layer, nn.Conv2d)):
padding_mode_list.append(layer.padding_mode)
layer.padding_mode = 'circular'
ret = common_ksampler(model, seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, denoise=denoise)
ind = 0
for layer in model.model.diffusion_model.modules():
if (isinstance(layer, nn.Conv2d)):
padding_mode_list.append(layer.padding_mode)
layer.padding_mode = padding_mode_list[ind]
ind += 1