From c21b361e2ae7fa6c1b148aacb261ca4621654cf7 Mon Sep 17 00:00:00 2001 From: "Dr.Lt.Data" Date: Sat, 21 Dec 2024 17:41:24 +0900 Subject: [PATCH] fix: VAEEncodeTiled - overlap compatibility patch https://github.com/ltdrdata/ComfyUI-Impact-Pack/issues/863 --- modules/impact/config.py | 2 +- modules/impact/core.py | 17 +++++++++++------ pyproject.toml | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/modules/impact/config.py b/modules/impact/config.py index a8bb469a..5962c697 100644 --- a/modules/impact/config.py +++ b/modules/impact/config.py @@ -1,7 +1,7 @@ import configparser import os -version_code = [8, 1, 2] +version_code = [8, 1, 3] 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 f5e4ef6a..10e15928 100644 --- a/modules/impact/core.py +++ b/modules/impact/core.py @@ -1384,9 +1384,14 @@ def vae_decode(vae, samples, use_tile, hook, tile_size=512, overlap=64): return pixels -def vae_encode(vae, pixels, use_tile, hook, tile_size=512): +def vae_encode(vae, pixels, use_tile, hook, tile_size=512, overlap=64): if use_tile: - samples = nodes.VAEEncodeTiled().encode(vae, pixels, tile_size)[0] + encoder = nodes.VAEEncodeTiled() + if 'overlap' in inspect.signature(encoder.encode).parameters: + samples = encoder.encode(vae, pixels, tile_size, overlap=overlap)[0] + else: + print(f"[Impact Pack] Your ComfyUI is outdated.") + samples = encoder.encode(vae, pixels, tile_size)[0] else: samples = nodes.VAEEncode().encode(vae, pixels)[0] @@ -1412,7 +1417,7 @@ def latent_upscale_on_pixel_space_shape2(samples, scale_method, w, h, vae, use_t if hook is not None: pixels = hook.post_upscale(pixels) - return (vae_encode(vae, pixels, use_tile, hook, tile_size=tile_size), old_pixels) + return vae_encode(vae, pixels, use_tile, hook, tile_size=tile_size, overlap=overlap), old_pixels def latent_upscale_on_pixel_space(samples, scale_method, scale_factor, vae, use_tile=False, tile_size=512, save_temp_prefix=None, hook=None, overlap=64): @@ -1433,7 +1438,7 @@ def latent_upscale_on_pixel_space2(samples, scale_method, scale_factor, vae, use if hook is not None: pixels = hook.post_upscale(pixels) - return (vae_encode(vae, pixels, use_tile, hook, tile_size=tile_size), old_pixels) + return vae_encode(vae, pixels, use_tile, hook, tile_size=tile_size, overlap=overlap), old_pixels def latent_upscale_on_pixel_space_with_model_shape(samples, scale_method, upscale_model, new_w, new_h, vae, use_tile=False, tile_size=512, save_temp_prefix=None, hook=None, overlap=64): @@ -1464,7 +1469,7 @@ def latent_upscale_on_pixel_space_with_model_shape2(samples, scale_method, upsca if hook is not None: pixels = hook.post_upscale(pixels) - return (vae_encode(vae, pixels, use_tile, hook, tile_size=tile_size), old_pixels) + return vae_encode(vae, pixels, use_tile, hook, tile_size=tile_size, overlap=overlap), old_pixels def latent_upscale_on_pixel_space_with_model(samples, scale_method, upscale_model, scale_factor, vae, use_tile=False, @@ -1500,7 +1505,7 @@ def latent_upscale_on_pixel_space_with_model2(samples, scale_method, upscale_mod if hook is not None: pixels = hook.post_upscale(pixels) - return (vae_encode(vae, pixels, use_tile, hook, tile_size=tile_size), old_pixels) + return vae_encode(vae, pixels, use_tile, hook, tile_size=tile_size, overlap=overlap), old_pixels class TwoSamplersForMaskUpscaler: diff --git a/pyproject.toml b/pyproject.toml index b5bd5a06..45b987bd 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.2" +version = "8.1.3" license = { file = "LICENSE.txt" } dependencies = ["segment-anything", "scikit-image", "piexif", "transformers", "opencv-python-headless", "GitPython", "scipy>=1.11.4"]