diff options
author | CodeHatchling <steve@codehatch.com> | 2023-11-29 05:35:07 +0000 |
---|---|---|
committer | CodeHatchling <steve@codehatch.com> | 2023-11-29 05:35:07 +0000 |
commit | c5c7fa06aae1ae9f8b6d29ae2da3874921d4729b (patch) | |
tree | 27a4fff92fcd4c979601a465cd20f279d3a09f50 /modules/sd_samplers_cfg_denoiser.py | |
parent | debf836fcc8d9becc3da8b1a29e33f40b0d9ef3e (diff) | |
download | stable-diffusion-webui-gfx803-c5c7fa06aae1ae9f8b6d29ae2da3874921d4729b.tar.gz stable-diffusion-webui-gfx803-c5c7fa06aae1ae9f8b6d29ae2da3874921d4729b.tar.bz2 stable-diffusion-webui-gfx803-c5c7fa06aae1ae9f8b6d29ae2da3874921d4729b.zip |
Added slider for detail preservation strength, removed largely needless offset parameter, changed labels in UI and for saving to/pasting data from PNG files.
Diffstat (limited to 'modules/sd_samplers_cfg_denoiser.py')
-rw-r--r-- | modules/sd_samplers_cfg_denoiser.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/modules/sd_samplers_cfg_denoiser.py b/modules/sd_samplers_cfg_denoiser.py index c4d6fda6..598cd487 100644 --- a/modules/sd_samplers_cfg_denoiser.py +++ b/modules/sd_samplers_cfg_denoiser.py @@ -45,7 +45,7 @@ class CFGDenoiser(torch.nn.Module): self.nmask = None
self.mask_blend_power = 1
self.mask_blend_scale = 1
- self.mask_blend_offset = 0
+ self.inpaint_detail_preservation = 16
self.init_latent = None
self.steps = None
"""number of steps as specified by user in UI"""
@@ -105,14 +105,13 @@ class CFGDenoiser(torch.nn.Module): # Record the original latent vector magnitudes.
# We bring them to a power so that larger magnitudes are favored over smaller ones.
# 64-bit operations are used here to allow large exponents.
- detail_preservation = 32
- a_magnitude = torch.norm(a, p=2, dim=1).to(torch.float64) ** detail_preservation
- b_magnitude = torch.norm(b, p=2, dim=1).to(torch.float64) ** detail_preservation
+ a_magnitude = torch.norm(a, p=2, dim=1).to(torch.float64) ** self.inpaint_detail_preservation
+ b_magnitude = torch.norm(b, p=2, dim=1).to(torch.float64) ** self.inpaint_detail_preservation
one_minus_t = 1 - t
# Interpolate the powered magnitudes, then un-power them (bring them back to a power of 1).
- interp_magnitude = (a_magnitude * one_minus_t + b_magnitude * t) ** (1 / detail_preservation)
+ interp_magnitude = (a_magnitude * one_minus_t + b_magnitude * t) ** (1 / self.inpaint_detail_preservation)
# Linearly interpolate the image vectors.
image_interp = a * one_minus_t + b * t
@@ -142,7 +141,7 @@ class CFGDenoiser(torch.nn.Module): NOTE: "mask" is not used
"""
- return torch.pow(nmask, (_sigma ** self.mask_blend_power) * self.mask_blend_scale + self.mask_blend_offset)
+ return torch.pow(nmask, (_sigma ** self.mask_blend_power) * self.mask_blend_scale)
if state.interrupted or state.skipped:
raise sd_samplers_common.InterruptedException
|