INNER CODE UNIT · Python
sampler_pre_cfg_automatic_cfg_function
Extraltodeus/ComfyUI-AutomaticCFG · nodes.py:88
def sampler_pre_cfg_automatic_cfg_function(sigma, uncond, cond, cond_scale, **kwargs):
if sigma[0] < minimum_sigma_to_disable_uncond or sigma[0] > maximum_sigma_to_enable_uncond:
uncond = None
if sigma[0] <= disabled_cond_start and sigma[0] > disabled_cond_end:
cond = None
return uncond, cond, cond_scale
return sampler_pre_cfg_automatic_cfg_function
def get_entropy(tensor):
hist = np.histogram(tensor.cpu(), bins=100)[0]
hist = hist / hist.sum()
hist = hist[hist > 0]
return -np.sum(hist * np.log2(hist))
def map_sigma(sigma, sigmax, sigmin):
return 1 + ((sigma - sigmax) * (0 - 1)) / (sigmin - sigmax)
def center_latent_mean_values(latent, per_channel, mult):