fix: invalid variation noise logic
- To compensate for the loss of Gaussian noise characteristics due to interpolation between two noises, scale.
This commit is contained in:
@@ -2,7 +2,7 @@ import configparser
|
||||
import os
|
||||
|
||||
|
||||
version_code = [5, 2]
|
||||
version_code = [5, 2, 1]
|
||||
version = f"V{version_code[0]}.{version_code[1]}" + (f'.{version_code[2]}' if len(version_code) > 2 else '')
|
||||
|
||||
dependency_version = 20
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
import copy
|
||||
|
||||
import torch
|
||||
|
||||
import nodes
|
||||
|
||||
from impact import utils
|
||||
from . import segs_nodes
|
||||
from thirdparty import noise_nodes
|
||||
@@ -12,6 +9,7 @@ import asyncio
|
||||
import folder_paths
|
||||
import os
|
||||
from comfy_extras import nodes_custom_sampler
|
||||
import math
|
||||
|
||||
|
||||
class PixelKSampleHook:
|
||||
@@ -201,9 +199,13 @@ class VariationNoiseDetailerHookProvider(DetailerHook):
|
||||
noise = nodes_custom_sampler.Noise_RandomNoise(seed).generate_noise(empty_noise)
|
||||
noise_2nd = nodes_custom_sampler.Noise_RandomNoise(self.variation_seed).generate_noise(empty_noise)
|
||||
|
||||
noise = (1 - self.variation_strength) * noise + self.variation_strength * noise_2nd
|
||||
mixed_noise = ((1 - self.variation_strength) * noise + self.variation_strength * noise_2nd)
|
||||
|
||||
return noise
|
||||
# NOTE: mixed_noise is not gaussian noise; therefore, adjust the scale to correct it to gaussian noise.
|
||||
scale_factor = math.sqrt((1 - self.variation_strength) ** 2 + self.variation_strength ** 2)
|
||||
corrected_noise = mixed_noise / scale_factor # Scale the noise to maintain variance of 1
|
||||
|
||||
return corrected_noise
|
||||
|
||||
|
||||
class SimpleDetailerDenoiseSchedulerHook(DetailerHook):
|
||||
|
||||
Reference in New Issue
Block a user