Skip to content

Instantly share code, notes, and snippets.

View laksjdjf's full-sized avatar
🌏
On Earth

laksjdjf

🌏
On Earth
View GitHub Profile
'''
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
{'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/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)
'''
import torch
import numpy as np
from rembg import remove
class RembgMask:
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"image": ("IMAGE", ),
@laksjdjf
laksjdjf / freeu.py
Last active September 23, 2023 01:03
'''
1. put this file in ComfyUI/custom_nodes
2. load node from <loader>
'''
import torch
from comfy.ldm.modules.diffusionmodules.openaimodel import forward_timestep_embed, timestep_embedding, th
# https://github.com/ChenyangSi/FreeU
def Fourier_filter(x, threshold, scale):