Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c21b361e2a | ||
|
|
8f04714145 |
@@ -1,7 +1,7 @@
|
||||
import configparser
|
||||
import os
|
||||
|
||||
version_code = [8, 1, 1]
|
||||
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
|
||||
|
||||
+11
-6
@@ -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:
|
||||
|
||||
@@ -22,6 +22,7 @@ import comfy
|
||||
from io import BytesIO
|
||||
import random
|
||||
from server import PromptServer
|
||||
import logging
|
||||
|
||||
|
||||
sam_predictor = None
|
||||
@@ -79,7 +80,7 @@ async def sam_prepare(request):
|
||||
|
||||
model_name = os.path.join(impact_pack.model_path, "sams", model_name)
|
||||
|
||||
print(f"[INFO] ComfyUI-Impact-Pack: Loading SAM model '{impact_pack.model_path}'")
|
||||
logging.info(f"[Impact Pack] Loading SAM model '{impact_pack.model_path}'")
|
||||
|
||||
filename, image_dir = folder_paths.annotated_filepath(data["filename"])
|
||||
|
||||
@@ -95,7 +96,7 @@ async def sam_prepare(request):
|
||||
thread = threading.Thread(target=async_prepare_sam, args=(image_dir, model_name, filename,))
|
||||
thread.start()
|
||||
|
||||
print(f"[INFO] ComfyUI-Impact-Pack: SAM model loaded. ")
|
||||
logging.info("[Impact Pack] SAM model loaded. ")
|
||||
return web.Response(status=200)
|
||||
|
||||
|
||||
@@ -107,7 +108,7 @@ async def release_sam(request):
|
||||
del sam_predictor
|
||||
sam_predictor = None
|
||||
|
||||
print(f"[INFO] ComfyUI-Impact-Pack: unloading SAM model")
|
||||
logging.info("[Impact Pack]: unloading SAM model")
|
||||
|
||||
|
||||
@PromptServer.instance.routes.post("/sam/detect")
|
||||
@@ -324,20 +325,24 @@ def onprompt_for_switch(json_data):
|
||||
|
||||
cls = v['class_type']
|
||||
if cls == 'ImpactInversedSwitch':
|
||||
# if 'sel_mode' is 'select_on_prompt'
|
||||
if 'sel_mode' in v['inputs'] and v['inputs']['sel_mode'] and 'select' in v['inputs']:
|
||||
select_input = v['inputs']['select']
|
||||
# if 'select' is converted input
|
||||
if isinstance(select_input, list) and len(select_input) == 2:
|
||||
input_node = json_data['prompt'][select_input[0]]
|
||||
if input_node['class_type'] == 'ImpactInt' and 'inputs' in input_node and 'value' in input_node['inputs']:
|
||||
inversed_switch_info[k] = input_node['inputs']['value']
|
||||
else:
|
||||
print(f"\n##### ##### #####\n[WARN] {cls}: For the 'select' operation, only 'select_index' of the 'ImpactInversedSwitch', which is not an input, or 'ImpactInt' and 'Primitive' are allowed as inputs if 'select_on_prompt' is selected.\n##### ##### #####\n")
|
||||
logging.warning(f"\n##### ##### #####\n[Impact Pack] {cls}: For the 'select' operation, only 'select_index' of the 'ImpactInversedSwitch', which is not an input, or 'ImpactInt' and 'Primitive' are allowed as inputs if 'select_on_prompt' is selected.\n##### ##### #####\n")
|
||||
else:
|
||||
inversed_switch_info[k] = select_input
|
||||
|
||||
elif cls in ['ImpactSwitch', 'LatentSwitch', 'SEGSSwitch', 'ImpactMakeImageList']:
|
||||
# if 'sel_mode' is 'select_on_prompt'
|
||||
if 'sel_mode' in v['inputs'] and v['inputs']['sel_mode'] and 'select' in v['inputs']:
|
||||
select_input = v['inputs']['select']
|
||||
# if 'select' is converted input
|
||||
if isinstance(select_input, list) and len(select_input) == 2:
|
||||
input_node = json_data['prompt'][select_input[0]]
|
||||
if input_node['class_type'] == 'ImpactInt' and 'inputs' in input_node and 'value' in input_node['inputs']:
|
||||
@@ -346,7 +351,7 @@ def onprompt_for_switch(json_data):
|
||||
if isinstance(input_node['inputs']['select'], int):
|
||||
onprompt_switch_info[k] = input_node['inputs']['select']
|
||||
else:
|
||||
print(f"\n##### ##### #####\n[WARN] {cls}: For the 'select' operation, only 'select_index' of the 'ImpactSwitch', which is not an input, or 'ImpactInt' and 'Primitive' are allowed as inputs if 'select_on_prompt' is selected.\n##### ##### #####\n")
|
||||
logging.warning(f"\n##### ##### #####\n[Impact Pack] {cls}: For the 'select' operation, only 'select_index' of the 'ImpactSwitch', which is not an input, or 'ImpactInt' and 'Primitive' are allowed as inputs if 'select_on_prompt' is selected.\n##### ##### #####\n")
|
||||
else:
|
||||
onprompt_switch_info[k] = select_input
|
||||
|
||||
@@ -377,6 +382,8 @@ def onprompt_for_switch(json_data):
|
||||
if vv[0] in inversed_switch_info:
|
||||
if vv[1] + 1 != inversed_switch_info[vv[0]]:
|
||||
disable_targets.add(kk)
|
||||
else:
|
||||
del inversed_switch_info[k]
|
||||
|
||||
if vv[0] in disabled_switch:
|
||||
disable_targets.add(kk)
|
||||
@@ -396,6 +403,11 @@ def onprompt_for_switch(json_data):
|
||||
for kk in disable_targets:
|
||||
del v['inputs'][kk]
|
||||
|
||||
# inversed_switch - select out of range
|
||||
for target in inversed_switch_info.keys():
|
||||
del json_data['prompt'][target]['inputs']['input']
|
||||
|
||||
|
||||
def onprompt_for_pickers(json_data):
|
||||
detected_pickers = set()
|
||||
|
||||
@@ -479,7 +491,7 @@ def onprompt_populate_wildcards(json_data):
|
||||
if not isinstance(input_seed, int):
|
||||
continue
|
||||
else:
|
||||
print(f"[Impact Pack] Only `ImpactInt`, `Seed (rgthree)` and `Primitive` Node are allowed as the seed for '{v['class_type']}'. It will be ignored. ")
|
||||
logging.info(f"[Impact Pack] Only `ImpactInt`, `Seed (rgthree)` and `Primitive` Node are allowed as the seed for '{v['class_type']}'. It will be ignored. ")
|
||||
continue
|
||||
except:
|
||||
continue
|
||||
@@ -542,7 +554,7 @@ def onprompt(json_data):
|
||||
regional_sampler_seed_update(json_data)
|
||||
core.current_prompt = json_data
|
||||
except Exception as e:
|
||||
print(f"[WARN] ComfyUI-Impact-Pack: Error on prompt - several features will not work.\n{e}")
|
||||
logging.warning(f"[Impact Pack] ComfyUI-Impact-Pack: Error on prompt - several features will not work.\n{e}")
|
||||
|
||||
return json_data
|
||||
|
||||
|
||||
+1
-1
@@ -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.1"
|
||||
version = "8.1.3"
|
||||
license = { file = "LICENSE.txt" }
|
||||
dependencies = ["segment-anything", "scikit-image", "piexif", "transformers", "opencv-python-headless", "GitPython", "scipy>=1.11.4"]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user