mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-11-22 04:37:01 +08:00
used built-in functions
This commit is contained in:
parent
b5367edfa0
commit
721fd8b321
@ -108,9 +108,7 @@ class SelfAttentionGuidance:
|
|||||||
|
|
||||||
def patch(self, model, scale, blur_sigma, activation_proportion):
|
def patch(self, model, scale, blur_sigma, activation_proportion):
|
||||||
m = model.clone()
|
m = model.clone()
|
||||||
model_sampling = m.model.model_sampling
|
sigma_start = m.model.model_sampling.percent_to_sigma(activation_proportion)
|
||||||
sigmin = model_sampling.sigma(model_sampling.timestep(model_sampling.sigma_min))
|
|
||||||
sigmax = model_sampling.sigma(model_sampling.timestep(model_sampling.sigma_max))
|
|
||||||
|
|
||||||
attn_scores = None
|
attn_scores = None
|
||||||
|
|
||||||
@ -149,7 +147,7 @@ class SelfAttentionGuidance:
|
|||||||
x = args["input"]
|
x = args["input"]
|
||||||
if min(cfg_result.shape[2:]) <= 4: #skip when too small to add padding
|
if min(cfg_result.shape[2:]) <= 4: #skip when too small to add padding
|
||||||
return cfg_result
|
return cfg_result
|
||||||
if 1-activation_proportion < (sigma - sigmin) / (sigmax - sigmin):
|
if sigma > sigma_start:
|
||||||
return cfg_result
|
return cfg_result
|
||||||
# create the adversarially blurred image
|
# create the adversarially blurred image
|
||||||
degraded = create_blur_map(uncond_pred, uncond_attn, sag_sigma, sag_threshold)
|
degraded = create_blur_map(uncond_pred, uncond_attn, sag_sigma, sag_threshold)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user