From 721fd8b321726df42ed3de68927de3250eb16f33 Mon Sep 17 00:00:00 2001 From: Extraltodeus Date: Fri, 16 Feb 2024 23:42:46 +0100 Subject: [PATCH] used built-in functions --- comfy_extras/nodes_sag.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/comfy_extras/nodes_sag.py b/comfy_extras/nodes_sag.py index 25b0e7a0..8db84374 100644 --- a/comfy_extras/nodes_sag.py +++ b/comfy_extras/nodes_sag.py @@ -108,9 +108,7 @@ class SelfAttentionGuidance: def patch(self, model, scale, blur_sigma, activation_proportion): m = model.clone() - model_sampling = m.model.model_sampling - sigmin = model_sampling.sigma(model_sampling.timestep(model_sampling.sigma_min)) - sigmax = model_sampling.sigma(model_sampling.timestep(model_sampling.sigma_max)) + sigma_start = m.model.model_sampling.percent_to_sigma(activation_proportion) attn_scores = None @@ -149,7 +147,7 @@ class SelfAttentionGuidance: x = args["input"] if min(cfg_result.shape[2:]) <= 4: #skip when too small to add padding return cfg_result - if 1-activation_proportion < (sigma - sigmin) / (sigmax - sigmin): + if sigma > sigma_start: return cfg_result # create the adversarially blurred image degraded = create_blur_map(uncond_pred, uncond_attn, sag_sigma, sag_threshold)