Skip to content

Commit

Permalink
refactor: use ControlNetApplyAdvanced instead of legacy ControlNetApply
Browse files Browse the repository at this point in the history
  • Loading branch information
ltdrdata committed Dec 21, 2024
1 parent c21b361 commit 9402ecf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion modules/impact/config.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
20 changes: 16 additions & 4 deletions modules/impact/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"]

Expand Down

0 comments on commit 9402ecf

Please sign in to comment.