fixed algo
This commit is contained in:
@@ -94,8 +94,9 @@ class ApplyVisualStyle:
|
||||
"output": skip_output_layers
|
||||
}
|
||||
|
||||
class_names = set()
|
||||
for n, m in model.model.diffusion_model.named_modules():
|
||||
if m.__class__.__name__ == "CrossAttention":
|
||||
if m.__class__.__name__ == "CrossAttention":
|
||||
is_enabled = self.activate_block_choice(n, block_choices)
|
||||
if is_enabled:
|
||||
block_name = n.split("_")[0]
|
||||
@@ -113,15 +114,11 @@ class ApplyVisualStyle:
|
||||
|
||||
latents = torch.zeros_like(reference_latent)
|
||||
latents = torch.cat([latents] * 2)
|
||||
|
||||
if denoise < 1.0:
|
||||
latents[::1] = reference_latent[:1]
|
||||
else:
|
||||
latents[::2] = reference_latent
|
||||
latents[0] = reference_latent
|
||||
|
||||
denoise_mask = torch.ones_like(latents)[:, :1, ...] * denoise
|
||||
|
||||
denoise_mask[::2] = 0.
|
||||
denoise_mask[0] = 0.
|
||||
|
||||
return (model, positive, negative, {"samples": latents, "noise_mask": denoise_mask})
|
||||
|
||||
|
||||
@@ -42,8 +42,8 @@ class VisualStyleProcessor(object):
|
||||
keys_scale: float = 1.0,
|
||||
enabled: bool = True,
|
||||
enabled_animatediff: bool = False,
|
||||
adain_queries: bool = True,
|
||||
adain_keys: bool = True,
|
||||
adain_queries: bool = False,
|
||||
adain_keys: bool = False,
|
||||
adain_values: bool = False
|
||||
):
|
||||
self.module_self = module_self
|
||||
@@ -75,8 +75,10 @@ class VisualStyleProcessor(object):
|
||||
if self.adain_values:
|
||||
v = adain(v)
|
||||
|
||||
k = concat_first(k, -2, self.keys_scale)
|
||||
v = concat_first(v, -2)
|
||||
k, v = swapping_attention(k, v)
|
||||
|
||||
#k = concat_first(k, -2, self.keys_scale)
|
||||
#v = concat_first(v, -2)
|
||||
|
||||
if mask is None:
|
||||
out = optimized_attention(q, k, v, self.module_self.heads)
|
||||
|
||||
@@ -5,18 +5,6 @@ from dataclasses import dataclass
|
||||
|
||||
T = torch.Tensor
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class StyleAlignedArgs:
|
||||
share_group_norm: bool = True
|
||||
share_layer_norm: bool = True,
|
||||
share_attention: bool = True
|
||||
adain_queries: bool = True
|
||||
adain_keys: bool = True
|
||||
adain_values: bool = False
|
||||
full_attention_share: bool = False
|
||||
keys_scale: float = 1.
|
||||
only_self_level: float = 0.
|
||||
|
||||
def expand_first(feat: T, scale=1., ) -> T:
|
||||
b = feat.shape[0]
|
||||
feat_style = torch.stack((feat[0], feat[b // 2])).unsqueeze(1)
|
||||
|
||||
Reference in New Issue
Block a user