Skip to content

Instantly share code, notes, and snippets.

View laksjdjf's full-sized avatar
🌏
On Earth

laksjdjf

🌏
On Earth
View GitHub Profile
# ref:https://github.com/tfernd/HyperTile
from einops import rearrange
'''
1. put this file in ComfyUI/custom_nodes
2. load node from <loader>
3. set nh and nw (2-4 is recommended. if 1 is set, it will be the same as original)
'''
{'down_blocks.1.attentions.0.transformer_blocks.0': 'down_blocks.1.attentions.0.transformer_blocks.0',
'down_blocks.1.attentions.0.transformer_blocks.1': 'down_blocks.1.attentions.0.transformer_blocks.1',
'down_blocks.1.attentions.1.transformer_blocks.0': 'down_blocks.1.attentions.1.transformer_blocks.0',
'down_blocks.1.attentions.1.transformer_blocks.1': 'down_blocks.1.attentions.1.transformer_blocks.1',
'down_blocks.2.attentions.0.transformer_blocks.0': 'down_blocks.2.attentions.0.transformer_blocks.0',
'down_blocks.2.attentions.0.transformer_blocks.1': 'down_blocks.2.attentions.0.transformer_blocks.1',
'down_blocks.2.attentions.0.transformer_blocks.2': 'down_blocks.2.attentions.0.transformer_blocks.2',
'down_blocks.2.attentions.0.transformer_blocks.3': 'down_blocks.2.attentions.0.transformer_blocks.6',
'down_blocks.2.attentions.1.transformer_blocks.0': 'down_blocks.2.attentions.1.transformer_blocks.0',
'down_blocks.2.attentions.1.transformer_blocks.1': 'down_blocks.2.attentions.1.transformer_block
# ref:https://github.com/v0xie/sd-webui-cads
'''
1. put this file in ComfyUI/custom_nodes
2. load node from <loader>
'''
import torch
import numpy as np
import copy
================================================================================================================================================================
Layer (type (var_name)) Input Shape Output Shape Param # Kernel Shape
================================================================================================================================================================
Transformer2DModel (Transformer2DModel) [1, 4, 32, 32] [1, 8, 32, 32] 2,304 --
├─PatchEmbed (pos_embed) [1, 4, 32, 32] [1, 256, 1152] -- --
│ └─Conv2d (proj) [1, 4, 32, 32] [1, 1152, 16, 16] 19,584 [2, 2]
├─AdaLayerNormSingle (adaln_single) [1] [1, 6912] --
'''
https://gist.github.com/kohya-ss/3f774da220df102548093a7abc8538ed
1. put this file in ComfyUI/custom_nodes
2. load node from <loaders>
'''
import torch
from comfy.ldm.modules.diffusionmodules.openaimodel import forward_timestep_embed, timestep_embedding, th
def apply_control(h, control, name):
import comfy
from comfy.samplers import KSAMPLER
import torch
from comfy.k_diffusion.sampling import default_noise_sampler, get_ancestral_step, to_d, BrownianTreeNoiseSampler
from tqdm.auto import trange
@torch.no_grad()
def sample_euler_ancestral(model, x, sigmas, extra_args=None, callback=None, disable=None, eta=1., s_noise=1., noise_sampler=None, upscale_ratio=2.0, start_step=5, end_step=15, upscale_n_step=3):
"""Ancestral sampling with Euler method steps."""
extra_args = {} if extra_args is None else extra_args
import comfy
from comfy.samplers import KSAMPLER
import torch
from torchvision.transforms.functional import gaussian_blur
from comfy.k_diffusion.sampling import default_noise_sampler, get_ancestral_step, to_d, BrownianTreeNoiseSampler
from tqdm.auto import trange
def interpolate(x, size, unsharp_strength=0.0, unsharp_kernel_size=3, unsharp_sigma=0.5, unsharp=False, mode="bicubic", align_corners=False):
x = torch.nn.functional.interpolate(x, size=size, mode=mode, align_corners=align_corners)
if unsharp_strength > 0 and unsharp:
'''
https://arxiv.org/abs/2312.00858
1. put this file in ComfyUI/custom_nodes
2. load node from <loaders>
start_step, end_step: apply this method when the timestep is between start_step and end_step
cache_interval: interval of caching (1 means no caching)
cache_depth: depth of caching
'''
@laksjdjf
laksjdjf / LCMSamplerRCFG.py
Last active December 21, 2023 12:02
Implementation of RCFG in https://arxiv.org/abs/2312.12491
'''
Implementation of RCFG in https://arxiv.org/abs/2312.12491
Node is in sampling/custom_sampling/samplers
original_latent is OPTIONAL
If original_latent is set, it is Self-Negative else Onetime-Negative
cfg is recommendet near 1.0 (KSAMPLER"s cfg is ignored)
delta is よくわかんない
'''
from comfy.samplers import KSAMPLER
'''
load from sampling/custom_sampling/scheulers
input text like "999,893,...,156"
connect to SamplerCustom
'''
import torch
class TextScheduler:
@classmethod