diff --git a/README.md b/README.md index b343202..faca193 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,8 @@ This repository offers various extension nodes for ComfyUI. Nodes here have diff * Image Util * `Load Images From Dir (Inspire)`: This is almost same as `LoadImagesFromDirectory` of [ComfyUI-Advanced-Controlnet](https://github.com/Kosinkadink/ComfyUI-Advanced-ControlNet). This is just a modified version. Just note that this node forcibly normalizes the size of the loaded image to match the size of the first image, even if they are not the same size, to create a batch image. +* KSampler Progress - In KSampler, the sampling process generates latent batches. By using `Video Combine` node from [ComfyUI-VideoHelperSuite](https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite), you can create a video from the progress. + ## Credits ComfyUI/[ComfyUI](https://github.com/comfyanonymous/ComfyUI) - A powerful and modular stable diffusion GUI. diff --git a/__init__.py b/__init__.py index b6fe69b..98727d9 100644 --- a/__init__.py +++ b/__init__.py @@ -7,7 +7,7 @@ import importlib -print(f"### Loading: ComfyUI-Inspire-Pack (V0.23.1)") +print(f"### Loading: ComfyUI-Inspire-Pack (V0.24)") node_list = [ "lora_block_weight", @@ -17,6 +17,7 @@ node_list = [ "inspire_server", "image_util", "regional_nodes", + "sampler_nodes", ] NODE_CLASS_MAPPINGS = {} diff --git a/sampler_nodes.py b/sampler_nodes.py new file mode 100644 index 0000000..b667fbc --- /dev/null +++ b/sampler_nodes.py @@ -0,0 +1,57 @@ +import torch +from . import a1111_compat +import comfy + +class KSampler_progress(a1111_compat.KSampler_inspire): + @classmethod + def INPUT_TYPES(s): + return {"required": + {"model": ("MODEL",), + "seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff}), + "steps": ("INT", {"default": 20, "min": 1, "max": 10000}), + "cfg": ("FLOAT", {"default": 8.0, "min": 0.0, "max": 100.0}), + "sampler_name": (comfy.samplers.KSampler.SAMPLERS, ), + "scheduler": (comfy.samplers.KSampler.SCHEDULERS, ), + "positive": ("CONDITIONING", ), + "negative": ("CONDITIONING", ), + "latent_image": ("LATENT", ), + "denoise": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}), + "noise_mode": (["GPU(=A1111)", "CPU"],), + "interval": ("INT", {"default": 1, "min": 1, "max": 10000}), + } + } + + CATEGORY = "InspirePack/analysis" + + RETURN_TYPES = ("LATENT", "LATENT") + RETURN_NAMES = ("latent", "progress_latent") + + def sample(self, model, seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, denoise, noise_mode, interval): + adv_steps = int(steps / denoise) + + sampler = a1111_compat.KSamplerAdvanced_inspire() + + result = [] + for i in range(0, adv_steps+1): + add_noise = i == 0 + return_with_leftover_noise = i != adv_steps + latent_image = sampler.sample(model, add_noise, seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, i, i+1, noise_mode, return_with_leftover_noise)[0] + if i % interval == 0 or i == adv_steps: + result.append(latent_image['samples']) + + if len(result) > 0: + result = torch.cat(result) + result = {'samples': result} + else: + result = latent_image + + return (latent_image, result) + + +NODE_CLASS_MAPPINGS = { + "KSamplerProgress //Inspire": KSampler_progress, +} + +NODE_DISPLAY_NAME_MAPPINGS = { + "KSamplerProgress //Inspire": "KSampler Progress (Inspire)", +}