feat: StepsScheduleHookProvider

https://github.com/ltdrdata/ComfyUI-Impact-Pack/issues/471#issuecomment-1937397697

fix: SimpleDetailerDenoiseSchedulerHook never reach to target

https://github.com/ltdrdata/ComfyUI-Impact-Pack/issues/442

refactor: move ConcatConditionings category to ImpactPack/Util

https://github.com/ltdrdata/ComfyUI-Impact-Pack/issues/467
This commit is contained in:
Dr.Lt.Data
2024-02-11 20:08:09 +09:00
parent 585787bfa7
commit 43bb20dc9d
6 changed files with 51 additions and 9 deletions
+3 -2
View File
@@ -124,8 +124,9 @@ This custom node helps to conveniently enhance images through Detector, Detailer
* You need to install the [BlenderNeko/ComfyUI_TiledKSampler](https://github.com/BlenderNeko/ComfyUI_TiledKSampler) node extension.
* PK_HOOK
* DenoiseScheduleHookProvider - IterativeUpscale provides a hook that gradually changes the denoise to target_denoise as the step progresses.
* CfgScheduleHookProvider - IterativeUpscale provides a hook that gradually changes the cfg to target_cfg as the step progresses.
* DenoiseScheduleHookProvider - IterativeUpscale provides a hook that gradually changes the denoise to target_denoise as the iterative-step progresses.
* CfgScheduleHookProvider - IterativeUpscale provides a hook that gradually changes the cfg to target_cfg as the iterative-step progresses.
* StepsScheduleHookProvider - IterativeUpscale provides a hook that gradually changes the sampling-steps to target_steps as the iterative-step progresses.
* NoiseInjectionHookProvider - During each iteration of IterativeUpscale, noise is injected into the latent space while varying the strength according to a schedule.
* You need to install the [BlenderNeko/ComfyUI_Noise](https://github.com/BlenderNeko/ComfyUI_Noise) node extension.
* The seed serves as the initial value required for generating noise, and it increments by 1 with each iteration as the process unfolds.
+1
View File
@@ -176,6 +176,7 @@ NODE_CLASS_MAPPINGS = {
"PixelKSampleHookCombine": PixelKSampleHookCombine,
"DenoiseScheduleHookProvider": DenoiseScheduleHookProvider,
"StepsScheduleHookProvider": StepsScheduleHookProvider,
"CfgScheduleHookProvider": CfgScheduleHookProvider,
"NoiseInjectionHookProvider": NoiseInjectionHookProvider,
"UnsamplerHookProvider": UnsamplerHookProvider,
+1 -1
View File
@@ -2,7 +2,7 @@ import configparser
import os
version_code = [4, 74]
version_code = [4, 75]
version = f"V{version_code[0]}.{version_code[1]}" + (f'.{version_code[2]}' if len(version_code) > 2 else '')
dependency_version = 20
+21 -5
View File
@@ -122,14 +122,25 @@ class SimpleDenoiseScheduleHook(PixelKSampleHook):
super().__init__()
self.target_denoise = target_denoise
def pre_ksample(self, model, seed, steps, cfg, sampler_name, scheduler, positive, negative, upscaled_latent,
denoise):
def pre_ksample(self, model, seed, steps, cfg, sampler_name, scheduler, positive, negative, upscaled_latent, denoise):
progress = self.cur_step / self.total_step
gap = self.target_denoise - denoise
current_denoise = denoise + gap * progress
return model, seed, steps, cfg, sampler_name, scheduler, positive, negative, upscaled_latent, current_denoise
class SimpleStepsScheduleHook(PixelKSampleHook):
def __init__(self, target_steps):
super().__init__()
self.target_steps = target_steps
def pre_ksample(self, model, seed, steps, cfg, sampler_name, scheduler, positive, negative, upscaled_latent, denoise):
progress = self.cur_step / self.total_step
gap = self.target_steps - steps
current_steps = int(steps + gap * progress)
return model, seed, current_steps, cfg, sampler_name, scheduler, positive, negative, upscaled_latent, denoise
class DetailerHook(PixelKSampleHook):
def cycle_latent(self, latent):
return latent
@@ -147,9 +158,14 @@ class SimpleDetailerDenoiseSchedulerHook(DetailerHook):
self.target_denoise = target_denoise
def pre_ksample(self, model, seed, steps, cfg, sampler_name, scheduler, positive, negative, latent, denoise):
progress = self.cur_step / self.total_step
gap = self.target_denoise - denoise
current_denoise = denoise + gap * progress
if self.total_step > 1:
progress = self.cur_step / (self.total_step - 1)
gap = self.target_denoise - denoise
current_denoise = denoise + gap * progress
else:
# ignore hook if total cycle <= 1
current_denoise = denoise
return model, seed, steps, cfg, sampler_name, scheduler, positive, negative, latent, current_denoise
+24
View File
@@ -780,6 +780,30 @@ class DenoiseScheduleHookProvider:
return (hook, )
class StepsScheduleHookProvider:
schedules = ["simple"]
@classmethod
def INPUT_TYPES(s):
return {"required": {
"schedule_for_iteration": (s.schedules,),
"target_steps": ("INT", {"default": 20, "min": 1, "max": 10000}),
},
}
RETURN_TYPES = ("PK_HOOK",)
FUNCTION = "doit"
CATEGORY = "ImpactPack/Upscale"
def doit(self, schedule_for_iteration, target_steps):
hook = None
if schedule_for_iteration == "simple":
hook = hooks.SimpleStepsScheduleHook(target_steps)
return (hook, )
class DetailerHookCombine:
@classmethod
def INPUT_TYPES(s):
+1 -1
View File
@@ -251,7 +251,7 @@ class ConcatConditionings:
RETURN_TYPES = ("CONDITIONING", )
FUNCTION = "doit"
CATEGORY = "ImpactPack/__for_testing"
CATEGORY = "ImpactPack/Util"
def doit(self, **kwargs):
conditioning_to = list(kwargs.values())[0]