Skip to content

Instantly share code, notes, and snippets.

View laksjdjf's full-sized avatar
🌏
On Earth

laksjdjf

🌏
On Earth
View GitHub Profile
===========================================================================================================================================================
Layer (type (var_name)) Input Shape Output Shape Param # Kernel Shape
===========================================================================================================================================================
StableCascadeUnet (StableCascadeUnet) -- [1, 4, 256, 256] -- 3
├─Linear (clip_txt_pooled_mapper) [1, 1, 1280] [1, 1, 5120] 6,558,720 --
├─LayerNorm (clip_norm) [1, 4, 1280] [1, 4, 1280] -- --
├─Sequential (embedding) [1, 4, 256, 256] [1, 320, 128, 128] -- --
│ └─PixelUnshuf
===========================================================================================================================================================
Layer (type (var_name)) Input Shape Output Shape Param # Kernel Shape
===========================================================================================================================================================
StableCascadeUnet (StableCascadeUnet) [2, 16, 24, 24] [2, 16, 24, 24] 8,923,136 3
├─Linear (clip_txt_pooled_mapper) [2, 77, 1280] [2, 77, 8192] 10,493,952 --
├─LayerNorm (clip_norm) [2, 308, 2048] [2, 308, 2048] -- --
├─Sequential (embedding) [2, 16, 24, 24] [2, 2048, 24, 24] -- --
│ └─PixelUnshuf
'''
load from sampling/custom_sampling/scheulers
input text like "999,893,...,156"
connect to SamplerCustom
'''
import torch
class TextScheduler:
@classmethod
@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
'''
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
'''
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:
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
'''
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):
================================================================================================================================================================
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] --
# 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