fix: DetailerHook made empty noise.
https://github.com/ltdrdata/ComfyUI-Impact-Pack/issues/584
This commit is contained in:
@@ -170,7 +170,7 @@ class DetailerForEachPipeForAnimateDiff:
|
||||
cnet_image_list.extend(cnet_images)
|
||||
|
||||
if detailer_hook is not None:
|
||||
detailer_hook.post_paste(image_frames)
|
||||
image_frames = detailer_hook.post_paste(image_frames)
|
||||
|
||||
enhanced_segs += enhanced_seg[1]
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import configparser
|
||||
import os
|
||||
|
||||
|
||||
version_code = [5, 5]
|
||||
version_code = [5, 5, 1]
|
||||
version = f"V{version_code[0]}.{version_code[1]}" + (f'.{version_code[2]}' if len(version_code) > 2 else '')
|
||||
|
||||
dependency_version = 20
|
||||
|
||||
@@ -268,7 +268,9 @@ def enhance_detail(image, model, clip, vae, guide_size, guide_size_for_bbox, max
|
||||
|
||||
model2, seed2, steps2, cfg2, sampler_name2, scheduler2, positive2, negative2, upscaled_latent2, denoise2 = \
|
||||
detailer_hook.pre_ksample(model, seed+i, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, denoise)
|
||||
noise = detailer_hook.get_custom_noise(seed+i, torch.zeros(latent_image['samples'].size()), is_start=True)
|
||||
noise, is_touched = detailer_hook.get_custom_noise(seed+i, torch.zeros(latent_image['samples'].size()), is_touched=False)
|
||||
if not is_touched:
|
||||
noise = None
|
||||
else:
|
||||
model2, seed2, steps2, cfg2, sampler_name2, scheduler2, positive2, negative2, upscaled_latent2, denoise2 = \
|
||||
model, seed + i, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, denoise
|
||||
|
||||
+9
-13
@@ -104,14 +104,10 @@ class DetailerHookCombine(PixelKSampleHookCombine):
|
||||
image = self.hook2.post_paste(image)
|
||||
return image
|
||||
|
||||
def get_custom_noise(self, seed, noise, is_start):
|
||||
noise_1st = self.hook1.get_custom_noise(seed, noise, is_start)
|
||||
noise, is_start = (noise_1st, False) if noise_1st is not None else (noise, is_start)
|
||||
|
||||
noise_2nd = self.hook2.get_custom_noise(seed, noise, False)
|
||||
noise = noise_2nd if noise_2nd is not None else noise
|
||||
|
||||
return noise
|
||||
def get_custom_noise(self, seed, noise, is_touched):
|
||||
noise_1st, is_touched = self.hook1.get_custom_noise(seed, noise, is_touched)
|
||||
noise_2nd, is_touched = self.hook2.get_custom_noise(seed, noise, is_touched)
|
||||
return noise, is_touched
|
||||
|
||||
|
||||
class SimpleCfgScheduleHook(PixelKSampleHook):
|
||||
@@ -174,8 +170,8 @@ class DetailerHook(PixelKSampleHook):
|
||||
def post_paste(self, image):
|
||||
return image
|
||||
|
||||
def get_custom_noise(self, seed, noise, is_start):
|
||||
return noise
|
||||
def get_custom_noise(self, seed, noise, is_touched):
|
||||
return noise, is_touched
|
||||
|
||||
|
||||
# class CustomNoiseDetailerHookProvider(DetailerHook):
|
||||
@@ -193,9 +189,9 @@ class VariationNoiseDetailerHookProvider(DetailerHook):
|
||||
self.variation_seed = variation_seed
|
||||
self.variation_strength = variation_strength
|
||||
|
||||
def get_custom_noise(self, seed, noise, is_start):
|
||||
def get_custom_noise(self, seed, noise, is_touched):
|
||||
empty_noise = {'samples': torch.zeros(noise.size())}
|
||||
if is_start:
|
||||
if not is_touched:
|
||||
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)
|
||||
|
||||
@@ -205,7 +201,7 @@ class VariationNoiseDetailerHookProvider(DetailerHook):
|
||||
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
|
||||
return corrected_noise, True
|
||||
|
||||
|
||||
class SimpleDetailerDenoiseSchedulerHook(DetailerHook):
|
||||
|
||||
@@ -306,7 +306,7 @@ class DetailerForEach:
|
||||
enhanced_list.append(enhanced_image)
|
||||
|
||||
if detailer_hook is not None:
|
||||
detailer_hook.post_paste(image)
|
||||
image = detailer_hook.post_paste(image)
|
||||
|
||||
if not (enhanced_image is None):
|
||||
# Convert enhanced_pil_alpha to RGBA mode
|
||||
|
||||
@@ -1746,7 +1746,7 @@ class SEGSUpscaler:
|
||||
tensor_paste(new_image, enhanced_image, (left, top), mask)
|
||||
|
||||
if upscaler_hook_opt is not None:
|
||||
upscaler_hook_opt.post_paste(new_image)
|
||||
new_image = upscaler_hook_opt.post_paste(new_image)
|
||||
|
||||
enhanced_img = tensor_convert_rgb(new_image)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user