mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-04-16 00:23:30 +00:00
Compare commits
3 Commits
f8c292e219
...
fc17b3d6f9
Author | SHA1 | Date | |
---|---|---|---|
![]() |
fc17b3d6f9 | ||
![]() |
11a182ef10 | ||
![]() |
8a50599bd8 |
@ -33,12 +33,13 @@ class RenormCFG:
|
||||
ori_pos_norm = torch.linalg.vector_norm(cond_eps
|
||||
, dim=tuple(range(1, len(cond_eps.shape))), keepdim=True
|
||||
)
|
||||
max_new_norm = ori_pos_norm * float(renorm_cfg)
|
||||
new_pos_norm = torch.linalg.vector_norm(
|
||||
max_new_norms = ori_pos_norm * float(renorm_cfg)
|
||||
new_pos_norms = torch.linalg.vector_norm(
|
||||
half_eps, dim=tuple(range(1, len(half_eps.shape))), keepdim=True
|
||||
)
|
||||
if new_pos_norm >= max_new_norm:
|
||||
half_eps = half_eps * (max_new_norm / new_pos_norm)
|
||||
for i, (max_new_norm, new_pos_norm) in enumerate(zip(max_new_norms, new_pos_norms)):
|
||||
if new_pos_norm >= max_new_norm:
|
||||
half_eps[i] = half_eps[i] * (max_new_norm / new_pos_norm)
|
||||
else:
|
||||
cond_eps, uncond_eps = cond_denoised[:, :in_channels], uncond_denoised[:, :in_channels]
|
||||
cond_rest, _ = cond_denoised[:, in_channels:], uncond_denoised[:, in_channels:]
|
||||
|
Loading…
Reference in New Issue
Block a user