Visit ComfyUI Online for ready-to-use ComfyUI environment
ComfyUI_Seamless_Patten enables the creation of seamless patterns from text-to-image processes, ensuring smooth, continuous designs without visible edges or interruptions.
ComfyUI_Seamless_Patten is an extension designed to enhance the capabilities of AI artists by enabling the creation of seamless patterns in text-to-image generation processes. This extension modifies the UNetModel and VAE Conv2d layers to use circular padding, which ensures that the generated images can tile seamlessly without visible borders or mismatches. This is particularly useful for creating textures, wallpapers, and other designs that require a continuous, repeating pattern.
The core functionality of ComfyUI_Seamless_Patten revolves around changing the padding mode of convolutional layers in the neural network models used for image generation. Normally, these layers use a standard padding mode that can result in visible seams when images are tiled. By switching to circular padding, the extension ensures that the edges of the images wrap around seamlessly.
The SeamlessVae Node modifies the VAE (Variational Autoencoder) model to use circular padding. This involves registering hooks that change the padding mode of Conv2d layers before and after the forward pass of the model.
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
The SeamlessKSampler Node modifies the KSampler model to use circular padding during the sampling process. This ensures that the diffusion model, which generates the images, also supports seamless tiling.
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
Currently, the extension modifies existing models (UNetModel and VAE) rather than providing new models. The changes ensure that these models can generate seamless patterns by using circular padding.
For additional resources, tutorials, and community support, consider the following:
© Copyright 2024 RunComfy. All Rights Reserved.