mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-09-09 16:47:05 +08:00
fix model_sampling kludges
This commit is contained in:
parent
7805e017bb
commit
a5afb5950c
@ -140,10 +140,6 @@ class BaseModel(torch.nn.Module):
|
||||
sigma = t
|
||||
xc = self.model_sampling.calculate_input(sigma, x)
|
||||
|
||||
#this is probably not the right way to do this
|
||||
if isinstance(self,LotusModel):
|
||||
xc = x#torch.cat([x], dim=1)
|
||||
|
||||
if c_concat is not None:
|
||||
xc = torch.cat([xc] + [c_concat], dim=1)
|
||||
|
||||
@ -605,7 +601,7 @@ class SDXL_instructpix2pix(IP2P, SDXL):
|
||||
else:
|
||||
self.process_ip2p_image_in = lambda image: image #diffusers ip2p
|
||||
|
||||
class LotusModel(BaseModel):
|
||||
class Lotus(BaseModel):
|
||||
def extra_conds(self, **kwargs):
|
||||
out = {}
|
||||
cross_attn = kwargs.get("cross_attn", None)
|
||||
@ -616,14 +612,6 @@ class LotusModel(BaseModel):
|
||||
out['y'] = comfy.conds.CONDRegular(task_emb)
|
||||
return out
|
||||
|
||||
def process_latent_out(self, latent):
|
||||
#TODO FIX
|
||||
#there is some scaling issue that happens during diffusion and this is a kludge to fix it
|
||||
#my best guess is that the scaling is somehow fucked up by the 999 sigma which is why
|
||||
#i'm using it here to scale things back, however this is definitely not correct and is just
|
||||
#patching an error that comes from the actual model sampling being done incorrectly
|
||||
return latent/-(999*0.18215)
|
||||
|
||||
def __init__(self, model_config, model_type=ModelType.EPS, device=None):
|
||||
super().__init__(model_config, model_type, device=device)
|
||||
|
||||
|
||||
@ -511,6 +511,7 @@ class LotusD(SD20):
|
||||
"model_channels": 320,
|
||||
"use_linear_in_transformer": True,
|
||||
"use_temporal_attention": False,
|
||||
"adm_in_channels": 4,
|
||||
"in_channels": 4,
|
||||
}
|
||||
|
||||
@ -519,8 +520,7 @@ class LotusD(SD20):
|
||||
}
|
||||
|
||||
def get_model(self, state_dict, prefix="", device=None):
|
||||
print('identified lotus-d model')
|
||||
return model_base.LotusModel(self, device=device)
|
||||
return model_base.Lotus(self, device=device)
|
||||
|
||||
class SD3(supported_models_base.BASE):
|
||||
unet_config = {
|
||||
|
||||
@ -24,6 +24,10 @@ class X0(comfy.model_sampling.EPS):
|
||||
def calculate_denoised(self, sigma, model_output, model_input):
|
||||
return model_output
|
||||
|
||||
class Lotus(X0):
|
||||
def calculate_input(self, sigma, noise):
|
||||
return noise
|
||||
|
||||
class ModelSamplingDiscreteDistilled(comfy.model_sampling.ModelSamplingDiscrete):
|
||||
original_timesteps = 50
|
||||
|
||||
@ -56,7 +60,7 @@ class ModelSamplingDiscrete:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {"required": { "model": ("MODEL",),
|
||||
"sampling": (["eps", "v_prediction", "lcm", "x0"],),
|
||||
"sampling": (["eps", "v_prediction", "lcm", "x0", "lotus"],),
|
||||
"zsnr": ("BOOLEAN", {"default": False}),
|
||||
}}
|
||||
|
||||
@ -78,6 +82,8 @@ class ModelSamplingDiscrete:
|
||||
sampling_base = ModelSamplingDiscreteDistilled
|
||||
elif sampling == "x0":
|
||||
sampling_type = X0
|
||||
elif sampling == "lotus":
|
||||
sampling_type = Lotus
|
||||
|
||||
class ModelSamplingAdvanced(sampling_base, sampling_type):
|
||||
pass
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user