feat: PixelTiledKSampleUpscalerProvider - support tile_cnet_strength

fix: `scheduler_func_opt` invalid arg name fix

https://github.com/ltdrdata/ComfyUI-Impact-Pack/issues/647#issuecomment-2181586345
This commit is contained in:
Dr.Lt.Data
2024-06-21 06:41:49 +09:00
parent e254cbed49
commit 5aaa07cf36
6 changed files with 22 additions and 12 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
import configparser
import os
version_code = [5, 15]
version_code = [5, 15, 1]
version = f"V{version_code[0]}.{version_code[1]}" + (f'.{version_code[2]}' if len(version_code) > 2 else '')
dependency_version = 21
+5 -4
View File
@@ -1637,7 +1637,7 @@ class PixelKSampleUpscaler:
upscaled_latent, denoise)
refined_latent = impact_sampling.impact_sample(model, seed, steps, cfg, sampler_name, scheduler,
positive, negative, upscaled_latent, denoise, scheduler_func_opt=self.scheduler_func)
positive, negative, upscaled_latent, denoise, scheduler_func=self.scheduler_func)
return refined_latent
def upscale_shape(self, step_info, samples, w, h, save_temp_prefix=None):
@@ -1665,7 +1665,7 @@ class PixelKSampleUpscaler:
upscaled_latent, denoise)
refined_latent = impact_sampling.impact_sample(model, seed, steps, cfg, sampler_name, scheduler,
positive, negative, upscaled_latent, denoise, scheduler_func_opt=self.scheduler_func)
positive, negative, upscaled_latent, denoise, scheduler_func=self.scheduler_func)
return refined_latent
@@ -1858,7 +1858,7 @@ class PixelTiledKSampleUpscaler:
def __init__(self, scale_method, model, vae, seed, steps, cfg, sampler_name, scheduler, positive, negative,
denoise,
tile_width, tile_height, tiling_strategy,
upscale_model_opt=None, hook_opt=None, tile_cnet_opt=None, tile_size=512):
upscale_model_opt=None, hook_opt=None, tile_cnet_opt=None, tile_size=512, tile_cnet_strength=1.0):
self.params = scale_method, model, vae, seed, steps, cfg, sampler_name, scheduler, positive, negative, denoise
self.vae = vae
self.tile_params = tile_width, tile_height, tiling_strategy
@@ -1867,6 +1867,7 @@ class PixelTiledKSampleUpscaler:
self.tile_cnet = tile_cnet_opt
self.tile_size = tile_size
self.is_tiled = True
self.tile_cnet_strength = tile_cnet_strength
def tiled_ksample(self, latent, images):
if "BNK_TiledKSampler" in nodes.NODE_CLASS_MAPPINGS:
@@ -1890,7 +1891,7 @@ class PixelTiledKSampleUpscaler:
# might add capacity to set pyrUp_iters later, not needed for now though
preprocessed = preprocessor.execute(images, pyrUp_iters=3, resolution=min(image_w, image_h))[0]
apply_cnet = getattr(nodes.ControlNetApply(), nodes.ControlNetApply.FUNCTION)
positive = apply_cnet(positive, self.tile_cnet, preprocessed, strength=1.0)[0]
positive = apply_cnet(positive, self.tile_cnet, preprocessed, strength=self.tile_cnet_strength)[0]
return TiledKSampler().sample(model, seed, tile_width, tile_height, tiling_strategy, steps, cfg, sampler_name,
scheduler, positive, negative, latent, denoise)[0]
+12 -4
View File
@@ -947,6 +947,7 @@ class PixelTiledKSampleUpscalerProvider:
"upscale_model_opt": ("UPSCALE_MODEL", ),
"pk_hook_opt": ("PK_HOOK", ),
"tile_cnet_opt": ("CONTROL_NET", ),
"tile_cnet_strength": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}),
}
}
@@ -955,9 +956,12 @@ class PixelTiledKSampleUpscalerProvider:
CATEGORY = "ImpactPack/Upscale"
def doit(self, scale_method, model, vae, seed, steps, cfg, sampler_name, scheduler, positive, negative, denoise, tile_width, tile_height, tiling_strategy, upscale_model_opt=None, pk_hook_opt=None, tile_cnet_opt=None):
def doit(self, scale_method, model, vae, seed, steps, cfg, sampler_name, scheduler, positive, negative, denoise, tile_width, tile_height, tiling_strategy, upscale_model_opt=None,
pk_hook_opt=None, tile_cnet_opt=None, tile_cnet_strength=1.0):
if "BNK_TiledKSampler" in nodes.NODE_CLASS_MAPPINGS:
upscaler = core.PixelTiledKSampleUpscaler(scale_method, model, vae, seed, steps, cfg, sampler_name, scheduler, positive, negative, denoise, tile_width, tile_height, tiling_strategy, upscale_model_opt, pk_hook_opt, tile_cnet_opt, tile_size=max(tile_width, tile_height))
upscaler = core.PixelTiledKSampleUpscaler(scale_method, model, vae, seed, steps, cfg, sampler_name, scheduler, positive, negative, denoise,
tile_width, tile_height, tiling_strategy, upscale_model_opt, pk_hook_opt, tile_cnet_opt,
tile_size=max(tile_width, tile_height), tile_cnet_strength=tile_cnet_strength)
return (upscaler, )
else:
print("[ERROR] PixelTiledKSampleUpscalerProvider: ComfyUI_TiledKSampler custom node isn't installed. You must install BlenderNeko/ComfyUI_TiledKSampler extension to use this node.")
@@ -985,6 +989,7 @@ class PixelTiledKSampleUpscalerProviderPipe:
"upscale_model_opt": ("UPSCALE_MODEL", ),
"pk_hook_opt": ("PK_HOOK", ),
"tile_cnet_opt": ("CONTROL_NET", ),
"tile_cnet_strength": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}),
}
}
@@ -993,10 +998,13 @@ class PixelTiledKSampleUpscalerProviderPipe:
CATEGORY = "ImpactPack/Upscale"
def doit(self, scale_method, seed, steps, cfg, sampler_name, scheduler, denoise, tile_width, tile_height, tiling_strategy, basic_pipe, upscale_model_opt=None, pk_hook_opt=None, tile_cnet_opt=None):
def doit(self, scale_method, seed, steps, cfg, sampler_name, scheduler, denoise, tile_width, tile_height, tiling_strategy, basic_pipe, upscale_model_opt=None, pk_hook_opt=None,
tile_cnet_opt=None, tile_cnet_strength=1.0):
if "BNK_TiledKSampler" in nodes.NODE_CLASS_MAPPINGS:
model, _, vae, positive, negative = basic_pipe
upscaler = core.PixelTiledKSampleUpscaler(scale_method, model, vae, seed, steps, cfg, sampler_name, scheduler, positive, negative, denoise, tile_width, tile_height, tiling_strategy, upscale_model_opt, pk_hook_opt, tile_cnet_opt, tile_size=max(tile_width, tile_height))
upscaler = core.PixelTiledKSampleUpscaler(scale_method, model, vae, seed, steps, cfg, sampler_name, scheduler, positive, negative, denoise,
tile_width, tile_height, tiling_strategy, upscale_model_opt, pk_hook_opt, tile_cnet_opt,
tile_size=max(tile_width, tile_height), tile_cnet_strength=tile_cnet_strength)
return (upscaler, )
else:
print("[ERROR] PixelTiledKSampleUpscalerProviderPipe: ComfyUI_TiledKSampler custom node isn't installed. You must install BlenderNeko/ComfyUI_TiledKSampler extension to use this node.")
+2 -1
View File
@@ -197,7 +197,8 @@ def impact_sample(model, seed, steps, cfg, sampler_name, scheduler, positive, ne
advanced_steps = math.floor(steps / denoise)
start_at_step = advanced_steps - steps
end_at_step = start_at_step + steps
return separated_sample(model, True, seed, advanced_steps, cfg, sampler_name, scheduler, positive, negative, latent_image, start_at_step, end_at_step, False, scheduler_func=scheduler_func)
return separated_sample(model, True, seed, advanced_steps, cfg, sampler_name, scheduler, positive, negative, latent_image,
start_at_step, end_at_step, False, scheduler_func=scheduler_func)
def ksampler_wrapper(model, seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, denoise,
+1 -1
View File
@@ -109,7 +109,7 @@ class SEGSDetailer:
refiner_ratio=refiner_ratio, refiner_model=refiner_model,
refiner_clip=refiner_clip, refiner_positive=refiner_positive, refiner_negative=refiner_negative,
control_net_wrapper=seg.control_net_wrapper, cycle=cycle,
inpaint_model=inpaint_model, noise_mask_feather=noise_mask_feather, scheduler_func_opt=scheduler_func_opt)
inpaint_model=inpaint_model, noise_mask_feather=noise_mask_feather, scheduler_func=scheduler_func_opt)
if cnet_pils is not None:
cnet_pil_list.extend(cnet_pils)
+1 -1
View File
@@ -1,7 +1,7 @@
[project]
name = "comfyui-impact-pack"
description = "This extension offers various detector nodes and detailer nodes that allow you to configure a workflow that automatically enhances facial details. And provide iterative upscaler."
version = "5.15"
version = "5.15.1"
license = "LICENSE"
dependencies = ["segment-anything", "scikit-image", "piexif", "transformers", "opencv-python-headless", "GitPython", "scipy>=1.11.4"]