This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
================================================================================================================================================================ | |
Layer (type (var_name)) Input Shape Output Shape Param # Kernel Shape | |
================================================================================================================================================================ | |
SD3Transformer2DModel (SD3Transformer2DModel) -- [1, 16, 128, 128] -- -- | |
├─PatchEmbed (pos_embed) [1, 16, 128, 128] [1, 4096, 1536] -- -- | |
│ └─Conv2d (proj) [1, 16, 128, 128] [1, 1536, 64, 64] 99,840 [2, 2] | |
├─CombinedTimestepTextProjEmbeddings (time_text_embed) [1] [1, 1536] -- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
def sigmoid(x): | |
return 1 / (1 + np.exp(-x)) | |
def inverse_sigmoid(y): | |
return np.log(y / (1 - y)) | |
# 逆シグモイド関数の微分 |