From 9402ecf4f96a6299ccf4f7e22b9ed403c10a5406 Mon Sep 17 00:00:00 2001 From: "Dr.Lt.Data" Date: Sat, 21 Dec 2024 18:21:58 +0900 Subject: [PATCH] refactor: use ControlNetApplyAdvanced instead of legacy ControlNetApply --- modules/impact/config.py | 2 +- modules/impact/core.py | 20 ++++++++++++++++---- pyproject.toml | 2 +- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/modules/impact/config.py b/modules/impact/config.py index 5962c697..9ad5bb7b 100644 --- a/modules/impact/config.py +++ b/modules/impact/config.py @@ -1,7 +1,7 @@ import configparser import os -version_code = [8, 1, 3] +version_code = [8, 1, 4] version = f"V{version_code[0]}.{version_code[1]}" + (f'.{version_code[2]}' if len(version_code) > 2 else '') dependency_version = 24 diff --git a/modules/impact/core.py b/modules/impact/core.py index 10e15928..33efd7e4 100644 --- a/modules/impact/core.py +++ b/modules/impact/core.py @@ -1675,8 +1675,14 @@ def sample(self, model, seed, steps, cfg, sampler_name, scheduler, positive, neg preprocessor = nodes.NODE_CLASS_MAPPINGS['TilePreprocessor']() # 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=self.tile_cnet_strength)[0] + positive, negative = nodes.ControlNetApplyAdvanced().apply_controlnet(positive=positive, + negative=negative, + control_net=self.tile_cnet, + image=preprocessed, + strength=self.tile_cnet_strength, + start_percent=0, + end_percent=1.0, + vae=self.vae) refined_latent = impact_sampling.impact_sample(model, seed, steps, cfg, sampler_name, scheduler, positive, negative, upscaled_latent, denoise, scheduler_func=self.scheduler_func) @@ -1979,8 +1985,14 @@ def tiled_ksample(self, latent, images): preprocessor = nodes.NODE_CLASS_MAPPINGS['TilePreprocessor']() # 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=self.tile_cnet_strength)[0] + + positive, negative = nodes.ControlNetApplyAdvanced().apply_controlnet(positive=positive, + negative=negative, + control_net=self.tile_cnet, + image=preprocessed, + strength=self.tile_cnet_strength, + start_percent=0, end_percent=1.0, + vae=self.vae) return TiledKSampler().sample(model, seed, tile_width, tile_height, tiling_strategy, steps, cfg, sampler_name, scheduler, positive, negative, latent, denoise)[0] diff --git a/pyproject.toml b/pyproject.toml index 45b987bd..b00207d6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "comfyui-impact-pack" description = "This node pack offers various detector nodes and detailer nodes that allow you to configure a workflow that automatically enhances facial details. And provide iterative upscaler." -version = "8.1.3" +version = "8.1.4" license = { file = "LICENSE.txt" } dependencies = ["segment-anything", "scikit-image", "piexif", "transformers", "opencv-python-headless", "GitPython", "scipy>=1.11.4"]