Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a43dae373e | ||
|
|
1087f2ee06 | ||
|
|
841a245cd4 | ||
|
|
aecc925630 | ||
|
|
b5abf19a1b | ||
|
|
9775a98f03 | ||
|
|
ac288bbcb9 | ||
|
|
fd69570977 | ||
|
|
1c488eec11 | ||
|
|
c3eed0936f | ||
|
|
44adbbe282 | ||
|
|
940ad41b15 | ||
|
|
e848a9dfb7 | ||
|
|
76653016dc | ||
|
|
9ed160123d | ||
|
|
ffbd4ae116 | ||
|
|
5757c533e6 | ||
|
|
e99e9aaec2 | ||
|
|
690b0a0f61 | ||
|
|
84fbb3fa2e | ||
|
|
b2c7e06e79 | ||
|
|
a500aff476 | ||
|
|
dddac08e28 | ||
|
|
e325d1b208 | ||
|
|
0a7dbe45a9 | ||
|
|
c43488361f | ||
|
|
b065ce88ca | ||
|
|
06b428ec8c | ||
|
|
94f30ef317 | ||
|
|
6c45402b2b | ||
|
|
3423c10225 | ||
|
|
182ff558be |
@@ -7,6 +7,8 @@ This custom node helps to conveniently enhance images through Detector, Detailer
|
||||
|
||||
|
||||
## NOTICE
|
||||
* V7.6: Automatic installation is no longer supported. Please install using ComfyUI-Manager, or manually install requirements.txt and run install.py to complete the installation.
|
||||
* V7.0: Supports Switch based on Execution Model Inversion.
|
||||
* V6.0: Supports FLUX.1 model in Impact KSampler, Detailers, PreviewBridgeLatent
|
||||
* V5.0: It is no longer compatible with versions of ComfyUI before 2024.04.08.
|
||||
* V4.87.4: Update to a version of ComfyUI after 2024.04.08 for proper functionality.
|
||||
@@ -193,11 +195,8 @@ This custom node helps to conveniently enhance images through Detector, Detailer
|
||||
### Switch nodes
|
||||
* `Switch (image,mask)`, `Switch (latent)`, `Switch (SEGS)` - Among multiple inputs, it selects the input designated by the selector and outputs it. The first input must be provided, while the others are optional. However, if the input specified by the selector is not connected, an error may occur.
|
||||
* `Switch (Any)` - This is a Switch node that takes an arbitrary number of inputs and produces a single output. Its type is determined when connected to any node, and connecting inputs increases the available slots for connections.
|
||||
* `Inversed Switch (Any)` - In contrast to `Switch (Any)`, it takes a single input and outputs one of many. Due to ComfyUI's functional limitations, the value of `select` must be determined at the time of queuing a prompt, and while it can serve as a `Primitive Node` or `ImpactInt`, it cannot function properly when connected through other nodes.
|
||||
* Guide
|
||||
* When the `Switch (Any)` and `Inversed Switch (Any)` selects are transformed into primitives, it's important to be cautious because the select range is not appropriately constrained, potentially leading to unintended behavior.
|
||||
* `Switch (image,mask)`, `Switch (latent)`, `Switch (SEGS)`, `Switch (Any)` supports `sel_mode` param. The `sel_mode` sets the moment at which the `select` parameter is determined. `select_on_prompt` determines the `select` at the time of queuing the prompt, while `select_on_execution` determines it during the execution of the workflow. While `select_on_execution` offers more flexibility, it can potentially trigger workflow execution errors due to running nodes that may be impossible to execute within the limitations of ComfyUI. `select_on_prompt` bypasses this constraint by treating any inputs not selected as if they were disconnected. However, please note that when using `select_on_prompt`, the `select` can only be used with widgets or `Primitive Nodes` determined at the queue prompt.
|
||||
* There is an issue when connecting the built-in reroute node with the switch's input/output slots. it can lead to forced disconnections during workflow loading. Therefore, it is advisable not to use reroute for making connections in such cases. However, there are no issues when using the reroute node in Pythongossss.
|
||||
* `Inversed Switch (Any)` - In contrast to `Switch (Any)`, it takes a single input and outputs one of many.
|
||||
* NOTE: See this [tutorial](https://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/switch.md)
|
||||
|
||||
### [Wildcards](http://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/ImpactWildcard.md) nodes
|
||||
* These are nodes that supports syntax in the form of `__wildcard-name__` and dynamic prompt syntax like `{a|b|c}`.
|
||||
@@ -230,11 +229,14 @@ This custom node helps to conveniently enhance images through Detector, Detailer
|
||||
|
||||
|
||||
### Batch/List Util
|
||||
* `Image batch To Image List` - Convert Image batch to Image List
|
||||
* `Image Batch to Image List` - Convert Image batch to Image List
|
||||
- You can use images generated in a multi batch to handle them
|
||||
* `Image List to Image Batch` - Convert Image List to Image Batch
|
||||
* `Make Image List` - Convert multiple images into a single image list
|
||||
* `Make Image Batch` - Convert multiple images into a single image batch
|
||||
- The input of images can be scaled up as needed
|
||||
* `Masks to Mask List`, `Mask List to Masks`, `Make Mask List`, `Make Mask Batch` - It has the same functionality as the nodes above, but uses mask as input instead of image.
|
||||
* `Flatten Mask Batch` - Flattens a Mask Batch into a single Mask. Normal operation is not guaranteed for non-binary masks.
|
||||
|
||||
|
||||
### Logics (experimental)
|
||||
@@ -280,6 +282,8 @@ This custom node helps to conveniently enhance images through Detector, Detailer
|
||||
* `Combine Conditionings` - It takes multiple conditionings as input and combines them into a single conditioning.
|
||||
* `Concat Conditionings` - It takes multiple conditionings as input and concat them into a single conditioning.
|
||||
* `Negative Cond Placeholder` - Models like FLUX.1 do not use Negative Conditioning. This is a placeholder node for them. You can use FLUX.1 by replacing the Negative Conditioning used in Impact KSampler, KSampler (Inspire), and Detailer with this node.
|
||||
* `Execution Order Controller` - A helper node that can forcibly control the execution order of nodes.
|
||||
* Connect the output of the node that should be executed first to the signal, and make the input of the node that should be executed later pass through this node.
|
||||
|
||||
|
||||
## MMDet nodes (DEPRECATED) - Don't use these nodes
|
||||
@@ -306,7 +310,8 @@ This custom node helps to conveniently enhance images through Detector, Detailer
|
||||
|
||||
|
||||
## Ultralytics models
|
||||
* huggingface.co/Bingsu/[adetailer](https://github.com/ultralytics/assets/releases/) - You can download face, people detection models, and clothing detection models.
|
||||
* When using ultralytics models, save them separately in `models/ultralytics/bbox` and `models/ultralytics/segm` depending on the type of model. Many models can be downloaded by searching for `ultralytics` in the Model Manager of ComfyUI-Manager.
|
||||
* huggingface.co/Bingsu/[adetailer](https://huggingface.co/Bingsu/adetailer/tree/main) - You can download face, people detection models, and clothing detection models.
|
||||
* ultralytics/[assets](https://github.com/ultralytics/assets/releases/) - You can download various types of detection models other than faces or people.
|
||||
* civitai/[adetailer](https://civitai.com/search/models?sortBy=models_v5&query=adetailer) - You can download various types detection models....Many models are associated with NSFW content.
|
||||
|
||||
@@ -328,6 +333,10 @@ mmdet_skip = False
|
||||
|
||||
## Installation
|
||||
|
||||
### Install via ComfyUI-Manager (Recommended)
|
||||
* Search `ComfyUI Impact Pack` in ComfyUI-Manager and click `Install` button.
|
||||
|
||||
### Manual Install (Not Recommended)
|
||||
1. `cd custom_nodes`
|
||||
2. `git clone https://github.com/ltdrdata/ComfyUI-Impact-Pack.git`
|
||||
3. `cd ComfyUI-Impact-Pack`
|
||||
@@ -336,24 +345,29 @@ mmdet_skip = False
|
||||
5. (optional) `python install.py`
|
||||
* Impact Pack will automatically install its dependencies during its initial launch.
|
||||
* For the portable version, you should execute the command `..\..\..\python_embeded\python.exe install.py` to run the installation script.
|
||||
|
||||
|
||||
6. Restart ComfyUI
|
||||
|
||||
* NOTE1: If an error occurs during the installation process, please refer to [Troubleshooting Page](troubleshooting/TROUBLESHOOTING.md) for assistance.
|
||||
* NOTE2: You can use this colab notebook [colab notebook](https://colab.research.google.com/github/ltdrdata/ComfyUI-Impact-Pack/blob/Main/notebook/comfyui_colab_impact_pack.ipynb) to launch it. This notebook automatically downloads the impact pack to the custom_nodes directory, installs the tested dependencies, and runs it.
|
||||
* NOTE3: If you create an empty file named `skip_download_model` in the `ComfyUI/custom_nodes/` directory, it will skip the model download step during the installation of the impact pack.
|
||||
|
||||
|
||||
## Package Dependencies (If you need to manual setup.)
|
||||
|
||||
* pip install
|
||||
* openmim
|
||||
* segment-anything
|
||||
* ultralytics
|
||||
* scikit-image
|
||||
* piexif
|
||||
* (optional) pycocotools
|
||||
* piexif
|
||||
* opencv-python
|
||||
* GitPython
|
||||
* scipy
|
||||
* numpy<2
|
||||
* dill
|
||||
* matplotlib
|
||||
* (optional) onnxruntime
|
||||
* (deprecated) openmim # for mim
|
||||
* (deprecated) pycocotools # for mim
|
||||
|
||||
* mim install (deprecated)
|
||||
* mmcv==2.0.0, mmdet==3.0.0, mmengine==0.7.2
|
||||
|
||||
+17
-23
@@ -23,22 +23,6 @@ import impact.sample_error_enhancer
|
||||
print(f"### Loading: ComfyUI-Impact-Pack ({impact.config.version})")
|
||||
|
||||
|
||||
def do_install():
|
||||
import importlib
|
||||
spec = importlib.util.spec_from_file_location('impact_install', os.path.join(os.path.dirname(__file__), 'install.py'))
|
||||
impact_install = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(impact_install)
|
||||
|
||||
|
||||
# ensure dependency
|
||||
if not os.path.exists(os.path.join(subpack_path, ".git")) and os.path.exists(subpack_path):
|
||||
print(f"### CompfyUI-Impact-Pack: corrupted subpack detected.")
|
||||
shutil.rmtree(subpack_path)
|
||||
|
||||
if impact.config.get_config()['dependency_version'] < impact.config.dependency_version or not os.path.exists(subpack_path):
|
||||
print(f"### ComfyUI-Impact-Pack: Updating dependencies [{impact.config.get_config()['dependency_version']} -> {impact.config.dependency_version}]")
|
||||
do_install()
|
||||
|
||||
sys.path.append(subpack_path)
|
||||
|
||||
# Core
|
||||
@@ -63,10 +47,10 @@ try:
|
||||
import mmcv
|
||||
from mmdet.apis import (inference_detector, init_detector)
|
||||
from mmdet.evaluation import get_classes
|
||||
except:
|
||||
import importlib
|
||||
print("### ComfyUI-Impact-Pack: Reinstall dependencies (several dependencies are missing.)")
|
||||
do_install()
|
||||
except Exception as e:
|
||||
import logging
|
||||
logging.error("[Impact Pack] Failed to import due to several dependencies are missing!!!!")
|
||||
raise e
|
||||
|
||||
|
||||
import impact.impact_server # to load server api
|
||||
@@ -161,6 +145,7 @@ NODE_CLASS_MAPPINGS = {
|
||||
"ImpactSegsAndMask": SegsBitwiseAndMask,
|
||||
"ImpactSegsAndMaskForEach": SegsBitwiseAndMaskForEach,
|
||||
"EmptySegs": EmptySEGS,
|
||||
"ImpactFlattenMask": FlattenMask,
|
||||
|
||||
"MediaPipeFaceMeshToSEGS": MediaPipeFaceMeshToSEGS,
|
||||
"MaskToSEGS": MaskToSEGS,
|
||||
@@ -249,6 +234,8 @@ NODE_CLASS_MAPPINGS = {
|
||||
"ImpactImageBatchToImageList": ImageBatchToImageList,
|
||||
"ImpactMakeImageList": MakeImageList,
|
||||
"ImpactMakeImageBatch": MakeImageBatch,
|
||||
"ImpactMakeMaskList": MakeMaskList,
|
||||
"ImpactMakeMaskBatch": MakeMaskBatch,
|
||||
|
||||
"RegionalSampler": RegionalSampler,
|
||||
"RegionalSamplerAdvanced": RegionalSamplerAdvanced,
|
||||
@@ -281,6 +268,7 @@ NODE_CLASS_MAPPINGS = {
|
||||
"ImpactStringSelector": StringSelector,
|
||||
"StringListToString": StringListToString,
|
||||
"WildcardPromptFromString": WildcardPromptFromString,
|
||||
"ImpactExecutionOrderController": ImpactExecutionOrderController,
|
||||
|
||||
"RemoveNoiseMask": RemoveNoiseMask,
|
||||
|
||||
@@ -331,6 +319,7 @@ NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"BitwiseAndMask": "Pixelwise(MASK & MASK)",
|
||||
"SubtractMask": "Pixelwise(MASK - MASK)",
|
||||
"AddMask": "Pixelwise(MASK + MASK)",
|
||||
"ImpactFlattenMask": "Flatten Mask Batch",
|
||||
"DetailerForEach": "Detailer (SEGS)",
|
||||
"DetailerForEachPipe": "Detailer (SEGS/pipe)",
|
||||
"DetailerForEachDebug": "DetailerDebug (SEGS)",
|
||||
@@ -397,13 +386,18 @@ NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"ImageMaskSwitch": "Switch (images, mask)",
|
||||
"ImpactSwitch": "Switch (Any)",
|
||||
"ImpactInversedSwitch": "Inversed Switch (Any)",
|
||||
"ImpactExecutionOrderController": "Execution Order Controller",
|
||||
|
||||
"MasksToMaskList": "Masks to Mask List",
|
||||
"MaskListToMaskBatch": "Mask List to Masks",
|
||||
"ImpactImageBatchToImageList": "Image batch to Image List",
|
||||
"MasksToMaskList": "Mask Batch to Mask List",
|
||||
"MaskListToMaskBatch": "Mask List to Mask Batch",
|
||||
"ImpactImageBatchToImageList": "Image Batch to Image List",
|
||||
"ImageListToImageBatch": "Image List to Image Batch",
|
||||
|
||||
"ImpactMakeImageList": "Make Image List",
|
||||
"ImpactMakeImageBatch": "Make Image Batch",
|
||||
"ImpactMakeMaskList": "Make Mask List",
|
||||
"ImpactMakeMaskBatch": "Make Mask Batch",
|
||||
|
||||
"ImpactStringSelector": "String Selector",
|
||||
"StringListToString": "String List to String",
|
||||
"WildcardPromptFromString": "Wildcard Prompt from String",
|
||||
|
||||
+5
-163
@@ -5,7 +5,6 @@ import subprocess
|
||||
import threading
|
||||
import locale
|
||||
import traceback
|
||||
import re
|
||||
|
||||
|
||||
if sys.argv[0] == 'install.py':
|
||||
@@ -13,7 +12,6 @@ if sys.argv[0] == 'install.py':
|
||||
|
||||
|
||||
impact_path = os.path.join(os.path.dirname(__file__), "modules")
|
||||
old_subpack_path = os.path.join(os.path.dirname(__file__), "subpack")
|
||||
subpack_path = os.path.join(os.path.dirname(__file__), "impact_subpack")
|
||||
subpack_repo = "https://github.com/ltdrdata/ComfyUI-Impact-Subpack"
|
||||
|
||||
@@ -71,64 +69,13 @@ def process_wrap(cmd_str, cwd=None, handler=None, env=None):
|
||||
# ---
|
||||
|
||||
|
||||
pip_list = None
|
||||
|
||||
|
||||
def get_installed_packages():
|
||||
global pip_list
|
||||
|
||||
if pip_list is None:
|
||||
try:
|
||||
result = subprocess.check_output([sys.executable, '-m', 'pip', 'list'], universal_newlines=True)
|
||||
pip_list = set([line.split()[0].lower() for line in result.split('\n') if line.strip()])
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"[ComfyUI-Manager] Failed to retrieve the information of installed pip packages.")
|
||||
return set()
|
||||
|
||||
return pip_list
|
||||
|
||||
|
||||
def is_installed(name):
|
||||
name = name.strip()
|
||||
pattern = r'([^<>!=]+)([<>!=]=?)'
|
||||
match = re.search(pattern, name)
|
||||
|
||||
if match:
|
||||
name = match.group(1)
|
||||
|
||||
result = name.lower() in get_installed_packages()
|
||||
return result
|
||||
|
||||
|
||||
def is_requirements_installed(file_path):
|
||||
print(f"req_path: {file_path}")
|
||||
if os.path.exists(file_path):
|
||||
with open(file_path, 'r') as file:
|
||||
lines = file.readlines()
|
||||
for line in lines:
|
||||
if not is_installed(line):
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
try:
|
||||
import platform
|
||||
import folder_paths
|
||||
from torchvision.datasets.utils import download_url
|
||||
import impact.config
|
||||
|
||||
|
||||
print("### ComfyUI-Impact-Pack: Check dependencies")
|
||||
|
||||
if "python_embeded" in sys.executable or "python_embedded" in sys.executable:
|
||||
pip_install = [sys.executable, '-s', '-m', 'pip', 'install']
|
||||
pip_upgrade = [sys.executable, '-s', '-m', 'pip', 'install', '-U']
|
||||
mim_install = [sys.executable, '-s', '-m', 'mim', 'install']
|
||||
else:
|
||||
pip_install = [sys.executable, '-m', 'pip', 'install']
|
||||
pip_upgrade = [sys.executable, '-m', 'pip', 'install', '-U']
|
||||
mim_install = [sys.executable, '-m', 'mim', 'install']
|
||||
|
||||
|
||||
def ensure_subpack():
|
||||
import git
|
||||
if os.path.exists(subpack_path):
|
||||
@@ -145,106 +92,11 @@ try:
|
||||
else:
|
||||
git.Repo.clone_from(subpack_repo, subpack_path)
|
||||
|
||||
if os.path.exists(old_subpack_path):
|
||||
shutil.rmtree(old_subpack_path)
|
||||
|
||||
|
||||
def ensure_pip_packages_first():
|
||||
subpack_req = os.path.join(subpack_path, "requirements.txt")
|
||||
if os.path.exists(subpack_req) and not is_requirements_installed(subpack_req):
|
||||
process_wrap(pip_install + ['-r', 'requirements.txt'], cwd=subpack_path)
|
||||
|
||||
if not impact.config.get_config()['mmdet_skip']:
|
||||
process_wrap(pip_install + ['openmim'])
|
||||
|
||||
try:
|
||||
import pycocotools
|
||||
except Exception:
|
||||
if platform.system() not in ["Windows"] or platform.machine() not in ["AMD64", "x86_64"]:
|
||||
print(f"Your system is {platform.system()}; !! You need to install 'libpython3-dev' for this step. !!")
|
||||
|
||||
process_wrap(pip_install + ['pycocotools'])
|
||||
else:
|
||||
pycocotools = {
|
||||
(3, 8): "https://github.com/Bing-su/dddetailer/releases/download/pycocotools/pycocotools-2.0.6-cp38-cp38-win_amd64.whl",
|
||||
(3, 9): "https://github.com/Bing-su/dddetailer/releases/download/pycocotools/pycocotools-2.0.6-cp39-cp39-win_amd64.whl",
|
||||
(3, 10): "https://github.com/Bing-su/dddetailer/releases/download/pycocotools/pycocotools-2.0.6-cp310-cp310-win_amd64.whl",
|
||||
(3, 11): "https://github.com/Bing-su/dddetailer/releases/download/pycocotools/pycocotools-2.0.6-cp311-cp311-win_amd64.whl",
|
||||
}
|
||||
|
||||
version = sys.version_info[:2]
|
||||
url = pycocotools[version]
|
||||
process_wrap(pip_install + [url])
|
||||
|
||||
|
||||
def ensure_pip_packages_last():
|
||||
my_path = os.path.dirname(__file__)
|
||||
requirements_path = os.path.join(my_path, "requirements.txt")
|
||||
|
||||
if not is_requirements_installed(requirements_path):
|
||||
process_wrap(pip_install + ['-r', requirements_path])
|
||||
|
||||
# fallback
|
||||
try:
|
||||
import segment_anything
|
||||
from skimage.measure import label, regionprops
|
||||
import piexif
|
||||
except Exception:
|
||||
process_wrap(pip_install + ['-r', requirements_path])
|
||||
|
||||
# !! cv2 importing test must be very last !!
|
||||
try:
|
||||
from cv2 import setNumThreads
|
||||
except Exception:
|
||||
try:
|
||||
is_open_cv_installed = False
|
||||
|
||||
# upgrade if opencv is installed already
|
||||
if is_installed('opencv-python'):
|
||||
process_wrap(pip_upgrade + ['opencv-python'])
|
||||
is_open_cv_installed = True
|
||||
|
||||
if is_installed('opencv-python-headless'):
|
||||
process_wrap(pip_upgrade + ['opencv-python-headless'])
|
||||
is_open_cv_installed = True
|
||||
|
||||
if is_installed('opencv-contrib-python'):
|
||||
process_wrap(pip_upgrade + ['opencv-contrib-python'])
|
||||
is_open_cv_installed = True
|
||||
|
||||
if is_installed('opencv-contrib-python-headless'):
|
||||
process_wrap(pip_upgrade + ['opencv-contrib-python-headless'])
|
||||
is_open_cv_installed = True
|
||||
|
||||
# if opencv is not installed install `opencv-python-headless`
|
||||
if not is_open_cv_installed:
|
||||
process_wrap(pip_install + ['opencv-python-headless'])
|
||||
except:
|
||||
print(f"[ERROR] ComfyUI-Impact-Pack: failed to install 'opencv-python'. Please, install manually.")
|
||||
|
||||
def ensure_mmdet_package():
|
||||
try:
|
||||
import mmcv
|
||||
import mmdet
|
||||
from mmdet.evaluation import get_classes
|
||||
except Exception:
|
||||
process_wrap(pip_install + ['opendatalab==0.0.9'])
|
||||
process_wrap(pip_install + ['-U', 'openmim'])
|
||||
process_wrap(mim_install + ['mmcv>=2.0.0rc4, <2.1.0'])
|
||||
process_wrap(mim_install + ['mmdet==3.0.0'])
|
||||
process_wrap(mim_install + ['mmengine==0.7.4'])
|
||||
|
||||
|
||||
def install():
|
||||
subpack_install_script = os.path.join(subpack_path, "install.py")
|
||||
|
||||
print(f"### ComfyUI-Impact-Pack: Updating subpack")
|
||||
try:
|
||||
import git
|
||||
except Exception:
|
||||
if not is_installed('GitPython'):
|
||||
process_wrap(pip_install + ['GitPython'])
|
||||
|
||||
ensure_subpack() # The installation of the subpack must take place before ensure_pip. cv2 triggers a permission error.
|
||||
|
||||
new_env = os.environ.copy()
|
||||
@@ -253,29 +105,20 @@ try:
|
||||
|
||||
if os.path.exists(subpack_install_script):
|
||||
process_wrap([sys.executable, 'install.py'], cwd=subpack_path, env=new_env)
|
||||
if not is_requirements_installed(os.path.join(subpack_path, 'requirements.txt')):
|
||||
process_wrap(pip_install + ['-r', 'requirements.txt'], cwd=subpack_path)
|
||||
else:
|
||||
print(f"### ComfyUI-Impact-Pack: (Install Failed) Subpack\nFile not found: `{subpack_install_script}`")
|
||||
|
||||
ensure_pip_packages_first()
|
||||
|
||||
if not impact.config.get_config()['mmdet_skip']:
|
||||
ensure_mmdet_package()
|
||||
|
||||
ensure_pip_packages_last()
|
||||
|
||||
# Download model
|
||||
print("### ComfyUI-Impact-Pack: Check basic models")
|
||||
bbox_path = os.path.join(model_path, "mmdets", "bbox")
|
||||
sam_path = os.path.join(model_path, "sams")
|
||||
onnx_path = os.path.join(model_path, "onnx")
|
||||
|
||||
if not os.path.exists(os.path.join(os.path.dirname(__file__), '..', 'skip_download_model')):
|
||||
if not os.path.exists(bbox_path):
|
||||
os.makedirs(bbox_path)
|
||||
|
||||
if not impact.config.get_config()['mmdet_skip']:
|
||||
bbox_path = os.path.join(model_path, "mmdets", "bbox")
|
||||
if not os.path.exists(bbox_path):
|
||||
os.makedirs(bbox_path)
|
||||
|
||||
if not os.path.exists(os.path.join(bbox_path, "mmdet_anime-face_yolov3.pth")):
|
||||
download_url("https://huggingface.co/dustysys/ddetailer/resolve/main/mmdet/bbox/mmdet_anime-face_yolov3.pth", bbox_path)
|
||||
|
||||
@@ -291,7 +134,6 @@ try:
|
||||
|
||||
impact.config.write_config()
|
||||
|
||||
|
||||
install()
|
||||
|
||||
except Exception as e:
|
||||
|
||||
+8
-2
@@ -237,7 +237,7 @@ app.registerExtension({
|
||||
if(nodeData.name == "ImpactControlBridge") {
|
||||
const onConnectionsChange = nodeType.prototype.onConnectionsChange;
|
||||
nodeType.prototype.onConnectionsChange = function (type, index, connected, link_info) {
|
||||
if(!link_info || this.inputs[0].type != '*')
|
||||
if(index != 0 || !link_info || this.inputs[0].type != '*')
|
||||
return;
|
||||
|
||||
// assign type
|
||||
@@ -393,6 +393,7 @@ app.registerExtension({
|
||||
}
|
||||
|
||||
if (nodeData.name === 'ImpactMakeImageList' || nodeData.name === 'ImpactMakeImageBatch' ||
|
||||
nodeData.name === 'ImpactMakeMaskList' || nodeData.name === 'ImpactMakeMaskBatch' ||
|
||||
nodeData.name === 'CombineRegionalPrompts' ||
|
||||
nodeData.name === 'ImpactCombineConditionings' || nodeData.name === 'ImpactConcatConditionings' ||
|
||||
nodeData.name === 'ImpactSEGSConcat' ||
|
||||
@@ -405,6 +406,11 @@ app.registerExtension({
|
||||
input_name = "image";
|
||||
break;
|
||||
|
||||
case 'ImpactMakeMaskList':
|
||||
case 'ImpactMakeMaskBatch':
|
||||
input_name = "mask";
|
||||
break;
|
||||
|
||||
case 'ImpactSEGSConcat':
|
||||
input_name = "segs";
|
||||
break;
|
||||
@@ -507,7 +513,7 @@ app.registerExtension({
|
||||
!stackTrace.includes('LGraphNode.connect') && // for mouse device
|
||||
!stackTrace.includes('loadGraphData') &&
|
||||
this.inputs[index].name != 'select') {
|
||||
this.removeInput(index);
|
||||
this.removeInput(index);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+11
-7
@@ -6,11 +6,15 @@ let refresh_btn2 = document.querySelector('button[title="Refresh widgets in node
|
||||
|
||||
let orig = refresh_btn.onclick;
|
||||
|
||||
refresh_btn.onclick = function() {
|
||||
orig();
|
||||
api.fetchApi('/impact/wildcards/refresh');
|
||||
};
|
||||
if(refresh_btn) {
|
||||
refresh_btn.onclick = function() {
|
||||
orig();
|
||||
api.fetchApi('/impact/wildcards/refresh');
|
||||
};
|
||||
}
|
||||
|
||||
refresh_btn2.addEventListener('click', function() {
|
||||
api.fetchApi('/impact/wildcards/refresh');
|
||||
});
|
||||
if(refresh_btn2) {
|
||||
refresh_btn2?.addEventListener('click', function() {
|
||||
api.fetchApi('/impact/wildcards/refresh');
|
||||
});
|
||||
}
|
||||
@@ -5,6 +5,13 @@ from impact.core import SEG
|
||||
from impact.segs_nodes import SEGSPaste
|
||||
|
||||
|
||||
try:
|
||||
from comfy_extras import nodes_differential_diffusion
|
||||
except Exception:
|
||||
print(f"\n#############################################\n[Impact Pack] ComfyUI is an outdated version.\n#############################################\n")
|
||||
raise Exception("[Impact Pack] ComfyUI is an outdated version.")
|
||||
|
||||
|
||||
class SEGSDetailerForAnimateDiff:
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
@@ -53,6 +60,9 @@ class SEGSDetailerForAnimateDiff:
|
||||
new_segs = []
|
||||
cnet_image_list = []
|
||||
|
||||
if noise_mask_feather > 0 and 'denoise_mask_function' not in model.model_options:
|
||||
model = nodes_differential_diffusion.DifferentialDiffusion().apply(model)[0]
|
||||
|
||||
for seg in segs[1]:
|
||||
cropped_image_frames = None
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ from PIL import ImageOps
|
||||
from impact.utils import *
|
||||
import latent_preview
|
||||
|
||||
|
||||
# NOTE: this should not be `from . import core`.
|
||||
# I don't know why but... 'from .' and 'from impact' refer to different core modules.
|
||||
# This separates global variables of the core module and breaks the preview bridge.
|
||||
@@ -18,7 +19,10 @@ class PreviewBridge:
|
||||
"images": ("IMAGE",),
|
||||
"image": ("STRING", {"default": ""}),
|
||||
},
|
||||
"hidden": {"unique_id": "UNIQUE_ID"},
|
||||
"optional": {
|
||||
"block": ("BOOLEAN", {"default": False, "label_on": "if_empty_mask", "label_off": "never", "tooltip": "is_empty_mask: If the mask is empty, the execution is stopped.\nnever: The execution is never stopped."})
|
||||
},
|
||||
"hidden": {"unique_id": "UNIQUE_ID", "extra_pnginfo": "EXTRA_PNGINFO"},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("IMAGE", "MASK", )
|
||||
@@ -29,6 +33,8 @@ class PreviewBridge:
|
||||
|
||||
CATEGORY = "ImpactPack/Util"
|
||||
|
||||
DESCRIPTION = "This is a feature that allows you to edit and send a Mask over a image.\nIf the block is set to 'is_empty_mask', the execution is stopped when the mask is empty."
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.output_dir = folder_paths.get_temp_directory()
|
||||
@@ -69,7 +75,7 @@ class PreviewBridge:
|
||||
|
||||
return image, mask.unsqueeze(0), ui_item
|
||||
|
||||
def doit(self, images, image, unique_id):
|
||||
def doit(self, images, image, unique_id, block=False, prompt=None, extra_pnginfo=None):
|
||||
need_refresh = False
|
||||
|
||||
if unique_id not in core.preview_bridge_cache:
|
||||
@@ -82,7 +88,7 @@ class PreviewBridge:
|
||||
pixels, mask, path_item = PreviewBridge.load_image(image)
|
||||
image = [path_item]
|
||||
else:
|
||||
res = nodes.PreviewImage().save_images(images, filename_prefix="PreviewBridge/PB-")
|
||||
res = nodes.PreviewImage().save_images(images, filename_prefix="PreviewBridge/PB-", prompt=prompt, extra_pnginfo=extra_pnginfo)
|
||||
image2 = res['ui']['images']
|
||||
pixels = images
|
||||
mask = torch.zeros((64, 64), dtype=torch.float32, device="cpu")
|
||||
@@ -95,9 +101,20 @@ class PreviewBridge:
|
||||
|
||||
image = image2
|
||||
|
||||
is_empty_mask = torch.all(mask == 0)
|
||||
|
||||
if block and is_empty_mask and core.is_execution_model_version_supported:
|
||||
from comfy_execution.graph import ExecutionBlocker
|
||||
result = ExecutionBlocker(None), ExecutionBlocker(None)
|
||||
elif block and is_empty_mask:
|
||||
print(f"[Impact Pack] PreviewBridge: ComfyUI is outdated - blocking feature is disabled.")
|
||||
result = pixels, mask
|
||||
else:
|
||||
result = pixels, mask
|
||||
|
||||
return {
|
||||
"ui": {"images": image},
|
||||
"result": (pixels, mask, ),
|
||||
"result": result,
|
||||
}
|
||||
|
||||
|
||||
@@ -118,6 +135,8 @@ def decode_latent(latent, preview_method, vae_opt=None):
|
||||
decoder_name = "taesdxl"
|
||||
elif preview_method == 'TAESD3':
|
||||
decoder_name = "taesd3"
|
||||
elif preview_method == 'TAEF1':
|
||||
decoder_name = "taef1"
|
||||
|
||||
if decoder_name:
|
||||
vae = nodes.VAELoader().load_vae(decoder_name)[0]
|
||||
@@ -169,16 +188,17 @@ class PreviewBridgeLatent:
|
||||
return {"required": {
|
||||
"latent": ("LATENT",),
|
||||
"image": ("STRING", {"default": ""}),
|
||||
"preview_method": (["Latent2RGB-SD3", "Latent2RGB-SDXL", "Latent2RGB-SD15",
|
||||
"preview_method": (["Latent2RGB-FLUX.1",
|
||||
"Latent2RGB-SDXL", "Latent2RGB-SD15", "Latent2RGB-SD3",
|
||||
"Latent2RGB-SD-X4", "Latent2RGB-Playground-2.5",
|
||||
"Latent2RGB-SC-Prior", "Latent2RGB-SC-B",
|
||||
"Latent2RGB-FLUX.1",
|
||||
"TAESD3", "TAESDXL", "TAESD15"],),
|
||||
"TAEF1", "TAESDXL", "TAESD15", "TAESD3"],),
|
||||
},
|
||||
"optional": {
|
||||
"vae_opt": ("VAE", )
|
||||
"vae_opt": ("VAE", ),
|
||||
"block": ("BOOLEAN", {"default": False, "label_on": "if_empty_mask", "label_off": "never", "tooltip": "is_empty_mask: If the mask is empty, the execution is stopped.\nnever: The execution is never stopped. Instead, it returns a white mask."})
|
||||
},
|
||||
"hidden": {"unique_id": "UNIQUE_ID"},
|
||||
"hidden": {"unique_id": "UNIQUE_ID", "prompt": "PROMPT", "extra_pnginfo": "EXTRA_PNGINFO"},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("LATENT", "MASK", )
|
||||
@@ -189,6 +209,8 @@ class PreviewBridgeLatent:
|
||||
|
||||
CATEGORY = "ImpactPack/Util"
|
||||
|
||||
DESCRIPTION = "This is a feature that allows you to edit and send a Mask over a latent image.\nIf the block is set to 'is_empty_mask', the execution is stopped when the mask is empty."
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.output_dir = folder_paths.get_temp_directory()
|
||||
@@ -230,9 +252,9 @@ class PreviewBridgeLatent:
|
||||
|
||||
return image, mask, ui_item
|
||||
|
||||
def doit(self, latent, image, preview_method, vae_opt=None, unique_id=None):
|
||||
def doit(self, latent, image, preview_method, vae_opt=None, block=False, unique_id=None, prompt=None, extra_pnginfo=None):
|
||||
latent_channels = latent['samples'].shape[1]
|
||||
preview_method_channels = 16 if 'SD3' in preview_method or 'SC-Prior' in preview_method or 'FLUX.1' in preview_method else 4
|
||||
preview_method_channels = 16 if 'SD3' in preview_method or 'SC-Prior' in preview_method or 'FLUX.1' in preview_method or 'TAEF1' == preview_method else 4
|
||||
|
||||
if vae_opt is None and latent_channels != preview_method_channels:
|
||||
print(f"[PreviewBridgeLatent] The version of latent is not compatible with preview_method.\nSD3, SD1/SD2, SDXL, SC-Prior, SC-B and FLUX.1 are not compatible with each other.")
|
||||
@@ -259,10 +281,14 @@ class PreviewBridgeLatent:
|
||||
del res_latent['noise_mask']
|
||||
else:
|
||||
res_latent = latent
|
||||
|
||||
is_empty_mask = True
|
||||
else:
|
||||
res_latent = latent.copy()
|
||||
res_latent['noise_mask'] = mask
|
||||
|
||||
is_empty_mask = torch.all(mask == 1)
|
||||
|
||||
res_image = [path_item]
|
||||
else:
|
||||
decoded_image = decode_latent(latent, preview_method, vae_opt)
|
||||
@@ -284,11 +310,15 @@ class PreviewBridgeLatent:
|
||||
'subfolder': 'PreviewBridge',
|
||||
'type': 'temp',
|
||||
}]
|
||||
|
||||
is_empty_mask = torch.all(mask == 1)
|
||||
else:
|
||||
mask = torch.ones(latent['samples'].shape[2:], dtype=torch.float32, device="cpu").unsqueeze(0)
|
||||
res = nodes.PreviewImage().save_images(decoded_image, filename_prefix="PreviewBridge/PBL-")
|
||||
res = nodes.PreviewImage().save_images(decoded_image, filename_prefix="PreviewBridge/PBL-", prompt=prompt, extra_pnginfo=extra_pnginfo)
|
||||
res_image = res['ui']['images']
|
||||
|
||||
is_empty_mask = True
|
||||
|
||||
path = os.path.join(folder_paths.get_temp_directory(), 'PreviewBridge', res_image[0]['filename'])
|
||||
core.set_previewbridge_image(unique_id, path, res_image[0])
|
||||
core.preview_bridge_image_id_map[image] = (path, res_image[0])
|
||||
@@ -297,7 +327,16 @@ class PreviewBridgeLatent:
|
||||
|
||||
res_latent = latent
|
||||
|
||||
if block and is_empty_mask and core.is_execution_model_version_supported:
|
||||
from comfy_execution.graph import ExecutionBlocker
|
||||
result = ExecutionBlocker(None), ExecutionBlocker(None)
|
||||
elif block and is_empty_mask:
|
||||
print(f"[Impact Pack] PreviewBridgeLatent: ComfyUI is outdated - blocking feature is disabled.")
|
||||
result = res_latent, mask
|
||||
else:
|
||||
result = res_latent, mask
|
||||
|
||||
return {
|
||||
"ui": {"images": res_image},
|
||||
"result": (res_latent, mask, ),
|
||||
"result": result,
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import configparser
|
||||
import os
|
||||
|
||||
version_code = [6, 0, 3]
|
||||
version_code = [7, 6, 2]
|
||||
version = f"V{version_code[0]}.{version_code[1]}" + (f'.{version_code[2]}' if len(version_code) > 2 else '')
|
||||
|
||||
dependency_version = 22
|
||||
|
||||
+16
-2
@@ -45,6 +45,14 @@ current_prompt = None
|
||||
SCHEDULERS = comfy.samplers.KSampler.SCHEDULERS + ['AYS SDXL', 'AYS SD1', 'AYS SVD', 'GITS[coeff=1.2]']
|
||||
|
||||
|
||||
def is_execution_model_version_supported():
|
||||
try:
|
||||
import comfy_execution
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
|
||||
|
||||
def set_previewbridge_image(node_id, file, item):
|
||||
global pb_id_cnt
|
||||
|
||||
@@ -229,7 +237,7 @@ def enhance_detail(image, model, clip, vae, guide_size, guide_size_for_bbox, max
|
||||
noise_mask = utils.tensor_gaussian_blur_mask(noise_mask, noise_mask_feather)
|
||||
noise_mask = noise_mask.squeeze(3)
|
||||
|
||||
if noise_mask_feather > 0:
|
||||
if noise_mask_feather > 0 and 'denoise_mask_function' not in model.model_options:
|
||||
model = nodes_differential_diffusion.DifferentialDiffusion().apply(model)[0]
|
||||
|
||||
if wildcard_opt is not None and wildcard_opt != "":
|
||||
@@ -375,7 +383,7 @@ def enhance_detail_for_animatediff(image_frames, model, clip, vae, guide_size, g
|
||||
noise_mask = utils.tensor_gaussian_blur_mask(noise_mask, noise_mask_feather)
|
||||
noise_mask = noise_mask.squeeze(3)
|
||||
|
||||
if noise_mask_feather > 0:
|
||||
if noise_mask_feather > 0 and 'denoise_mask_function' not in model.model_options:
|
||||
model = nodes_differential_diffusion.DifferentialDiffusion().apply(model)[0]
|
||||
|
||||
if wildcard_opt is not None and wildcard_opt != "":
|
||||
@@ -1672,6 +1680,9 @@ class PixelKSampleUpscaler:
|
||||
self.hook.pre_ksample(model, seed, steps, cfg, sampler_name, scheduler, positive, negative,
|
||||
upscaled_latent, denoise)
|
||||
|
||||
if 'noise_mask' in samples:
|
||||
upscaled_latent['noise_mask'] = samples['noise_mask']
|
||||
|
||||
refined_latent = self.sample(model, seed, steps, cfg, sampler_name, scheduler, positive, negative, upscaled_latent, denoise, upscaled_images)
|
||||
return refined_latent
|
||||
|
||||
@@ -1701,6 +1712,9 @@ class PixelKSampleUpscaler:
|
||||
self.hook.pre_ksample(model, seed, steps, cfg, sampler_name, scheduler, positive, negative,
|
||||
upscaled_latent, denoise)
|
||||
|
||||
if 'noise_mask' in samples:
|
||||
upscaled_latent['noise_mask'] = samples['noise_mask']
|
||||
|
||||
refined_latent = self.sample(model, seed, steps, cfg, sampler_name, scheduler, positive, negative, upscaled_latent, denoise, upscaled_images)
|
||||
return refined_latent
|
||||
|
||||
|
||||
+29
-19
@@ -5,21 +5,31 @@ import impact.utils as utils
|
||||
import torch
|
||||
from impact.core import SEG
|
||||
|
||||
SAM_MODEL_TOOLTIP = {"tooltip": "Segment Anything Model for Silhouette Detection.\nBe sure to use the SAM_MODEL loaded through the SAMLoader (Impact) node as input."}
|
||||
SAM_MODEL_TOOLTIP_OPTIONAL = {"tooltip": "[OPTIONAL]\nSegment Anything Model for Silhouette Detection.\nBe sure to use the SAM_MODEL loaded through the SAMLoader (Impact) node as input.\nGiven this input, it refines the rectangular areas detected by BBOX_DETECTOR into silhouette shapes through SAM.\nsam_model_opt takes priority over segm_detector_opt."}
|
||||
|
||||
MASK_HINT_THRESHOLD_TOOLTIP = "When detection_hint is mask-area, the mask of SEGS is used as a point hint for SAM (Segment Anything).\nIn this case, only the areas of the mask with brightness values equal to or greater than mask_hint_threshold are used as hints."
|
||||
MASK_HINT_USE_NEGATIVE_TOOLTIP = "When detecting with SAM (Segment Anything), negative hints are applied as follows:\nSmall: When the SEGS is smaller than 10 pixels in size\nOuter: Sampling the image area outside the SEGS region at regular intervals"
|
||||
|
||||
DILATION_TOOLTIP = "Set the value to dilate the result mask. If the value is negative, it erodes the mask."
|
||||
DETECTION_HINT_TOOLTIP = {"tooltip": "It is recommended to use only center-1.\nWhen refining the mask of SEGS with the SAM (Segment Anything) model, center-1 uses only the rectangular area of SEGS and a single point at the exact center as hints.\nOther options were added during the experimental stage and do not work well."}
|
||||
|
||||
BBOX_EXPANSION_TOOLTIP = "When performing SAM (Segment Anything) detection within the SEGS area, the rectangular area of SEGS is expanded and used as a hint."
|
||||
|
||||
class SAMDetectorCombined:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {"required": {
|
||||
"sam_model": ("SAM_MODEL", ),
|
||||
"segs": ("SEGS", ),
|
||||
"image": ("IMAGE", ),
|
||||
"sam_model": ("SAM_MODEL", SAM_MODEL_TOOLTIP),
|
||||
"segs": ("SEGS", {"tooltip": "This is the segment information detected by the detector.\nIt refines the Mask through the SAM (Segment Anything) detector for all areas pointed to by SEGS, and combines all Masks to return as a single Mask."}),
|
||||
"image": ("IMAGE", {"tooltip": "It is assumed that segs contains only the information about the detected areas, and does not include the image. SAM (Segment Anything) operates by referencing this image."}),
|
||||
"detection_hint": (["center-1", "horizontal-2", "vertical-2", "rect-4", "diamond-4", "mask-area",
|
||||
"mask-points", "mask-point-bbox", "none"],),
|
||||
"dilation": ("INT", {"default": 0, "min": -512, "max": 512, "step": 1}),
|
||||
"threshold": ("FLOAT", {"default": 0.93, "min": 0.0, "max": 1.0, "step": 0.01}),
|
||||
"bbox_expansion": ("INT", {"default": 0, "min": 0, "max": 1000, "step": 1}),
|
||||
"mask_hint_threshold": ("FLOAT", {"default": 0.7, "min": 0.0, "max": 1.0, "step": 0.01}),
|
||||
"mask_hint_use_negative": (["False", "Small", "Outter"], )
|
||||
"mask-points", "mask-point-bbox", "none"], DETECTION_HINT_TOOLTIP),
|
||||
"dilation": ("INT", {"default": 0, "min": -512, "max": 512, "step": 1, "tooltip": DILATION_TOOLTIP}),
|
||||
"threshold": ("FLOAT", {"default": 0.93, "min": 0.0, "max": 1.0, "step": 0.01, "tooltip": "Set the sensitivity threshold for the mask detected by SAM (Segment Anything). A higher value generates a more specific mask with a narrower range. For example, when pointing to a person's area, it might detect clothes, which is a narrower range, instead of the entire person."}),
|
||||
"bbox_expansion": ("INT", {"default": 0, "min": 0, "max": 1000, "step": 1, "tooltip": BBOX_EXPANSION_TOOLTIP}),
|
||||
"mask_hint_threshold": ("FLOAT", {"default": 0.7, "min": 0.0, "max": 1.0, "step": 0.01, "tooltip": MASK_HINT_THRESHOLD_TOOLTIP}),
|
||||
"mask_hint_use_negative": (["False", "Small", "Outter"], {"tooltip": MASK_HINT_USE_NEGATIVE_TOOLTIP})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,16 +48,16 @@ class SAMDetectorSegmented:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {"required": {
|
||||
"sam_model": ("SAM_MODEL", ),
|
||||
"segs": ("SEGS", ),
|
||||
"image": ("IMAGE", ),
|
||||
"sam_model": ("SAM_MODEL", SAM_MODEL_TOOLTIP),
|
||||
"segs": ("SEGS", {"tooltip": "This is the segment information detected by the detector.\nFor the SEGS region, the masks detected by SAM (Segment Anything) are created as a unified mask and a batch of individual masks."}),
|
||||
"image": ("IMAGE", {"tooltip": "It is assumed that segs contains only the information about the detected areas, and does not include the image. SAM (Segment Anything) operates by referencing this image."}),
|
||||
"detection_hint": (["center-1", "horizontal-2", "vertical-2", "rect-4", "diamond-4", "mask-area",
|
||||
"mask-points", "mask-point-bbox", "none"],),
|
||||
"dilation": ("INT", {"default": 0, "min": -512, "max": 512, "step": 1}),
|
||||
"mask-points", "mask-point-bbox", "none"], DETECTION_HINT_TOOLTIP),
|
||||
"dilation": ("INT", {"default": 0, "min": -512, "max": 512, "step": 1, "tooltip": DILATION_TOOLTIP}),
|
||||
"threshold": ("FLOAT", {"default": 0.93, "min": 0.0, "max": 1.0, "step": 0.01}),
|
||||
"bbox_expansion": ("INT", {"default": 0, "min": 0, "max": 1000, "step": 1}),
|
||||
"mask_hint_threshold": ("FLOAT", {"default": 0.7, "min": 0.0, "max": 1.0, "step": 0.01}),
|
||||
"mask_hint_use_negative": (["False", "Small", "Outter"], )
|
||||
"bbox_expansion": ("INT", {"default": 0, "min": 0, "max": 1000, "step": 1, "tooltip": BBOX_EXPANSION_TOOLTIP}),
|
||||
"mask_hint_threshold": ("FLOAT", {"default": 0.7, "min": 0.0, "max": 1.0, "step": 0.01, "tooltip": MASK_HINT_THRESHOLD_TOOLTIP}),
|
||||
"mask_hint_use_negative": (["False", "Small", "Outter"], {"tooltip": MASK_HINT_USE_NEGATIVE_TOOLTIP})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,7 +209,7 @@ class SimpleDetectorForEach:
|
||||
},
|
||||
"optional": {
|
||||
"post_dilation": ("INT", {"default": 0, "min": -512, "max": 512, "step": 1}),
|
||||
"sam_model_opt": ("SAM_MODEL", ),
|
||||
"sam_model_opt": ("SAM_MODEL", SAM_MODEL_TOOLTIP_OPTIONAL),
|
||||
"segm_detector_opt": ("SEGM_DETECTOR", ),
|
||||
}
|
||||
}
|
||||
@@ -311,7 +321,7 @@ class SimpleDetectorForAnimateDiff:
|
||||
"optional": {
|
||||
"masking_mode": (["Pivot SEGS", "Combine neighboring frames", "Don't combine"],),
|
||||
"segs_pivot": (["Combined mask", "1st frame mask"],),
|
||||
"sam_model_opt": ("SAM_MODEL", ),
|
||||
"sam_model_opt": ("SAM_MODEL", SAM_MODEL_TOOLTIP_OPTIONAL),
|
||||
"segm_detector_opt": ("SEGM_DETECTOR", ),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,6 +78,8 @@ class PreviewDetailerHookProvider:
|
||||
|
||||
CATEGORY = "ImpactPack/Util"
|
||||
|
||||
NOT_IDEMPOTENT = True
|
||||
|
||||
def doit(self, quality, unique_id):
|
||||
hook = hooks.PreviewDetailerHook(unique_id, quality)
|
||||
return (hook, hook)
|
||||
return hook, hook
|
||||
|
||||
@@ -27,6 +27,15 @@ import comfy.model_management
|
||||
import base64
|
||||
import impact.wildcards as wildcards
|
||||
from . import hooks
|
||||
from . import utils
|
||||
|
||||
|
||||
try:
|
||||
from comfy_extras import nodes_differential_diffusion
|
||||
except Exception:
|
||||
print(f"\n#############################################\n[Impact Pack] ComfyUI is an outdated version.\n#############################################\n")
|
||||
raise Exception("[Impact Pack] ComfyUI is an outdated version.")
|
||||
|
||||
|
||||
warnings.filterwarnings('ignore', category=UserWarning, message='TypedStorage is deprecated')
|
||||
|
||||
@@ -61,10 +70,10 @@ class CLIPSegDetectorProvider:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {"required": {
|
||||
"text": ("STRING", {"multiline": False}),
|
||||
"blur": ("FLOAT", {"min": 0, "max": 15, "step": 0.1, "default": 7}),
|
||||
"threshold": ("FLOAT", {"min": 0, "max": 1, "step": 0.05, "default": 0.4}),
|
||||
"dilation_factor": ("INT", {"min": 0, "max": 10, "step": 1, "default": 4}),
|
||||
"text": ("STRING", {"multiline": False, "tooltip": "Enter the targets to be detected, separated by commas"}),
|
||||
"blur": ("FLOAT", {"min": 0, "max": 15, "step": 0.1, "default": 7, "tooltip": "Blurs the detected mask"}),
|
||||
"threshold": ("FLOAT", {"min": 0, "max": 1, "step": 0.05, "default": 0.4, "tooltip": "Detects only areas that are certain above the threshold."}),
|
||||
"dilation_factor": ("INT", {"min": 0, "max": 10, "step": 1, "default": 4, "tooltip": "Dilates the detected mask."}),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,6 +82,8 @@ class CLIPSegDetectorProvider:
|
||||
|
||||
CATEGORY = "ImpactPack/Util"
|
||||
|
||||
DESCRIPTION = "Provides a detection function using CLIPSeg, which generates masks based on text prompts.\nTo use this node, the CLIPSeg custom node must be installed."
|
||||
|
||||
def doit(self, text, blur, threshold, dilation_factor):
|
||||
if "CLIPSeg" in nodes.NODE_CLASS_MAPPINGS:
|
||||
return (core.BBoxDetectorBasedOnCLIPSeg(text, blur, threshold, dilation_factor), )
|
||||
@@ -86,8 +97,10 @@ class SAMLoader:
|
||||
models = [x for x in folder_paths.get_filename_list("sams") if 'hq' not in x]
|
||||
return {
|
||||
"required": {
|
||||
"model_name": (models + ['ESAM'], ),
|
||||
"device_mode": (["AUTO", "Prefer GPU", "CPU"],),
|
||||
"model_name": (models + ['ESAM'], {"tooltip": "The detection accuracy varies depending on the SAM model. ESAM can only be used if ComfyUI-YoloWorld-EfficientSAM is installed."}),
|
||||
"device_mode": (["AUTO", "Prefer GPU", "CPU"], {"tooltip": "AUTO: Only applicable when a GPU is available. It temporarily loads the SAM_MODEL into VRAM only when the detection function is used.\n"
|
||||
"Prefer GPU: Tries to keep the SAM_MODEL on the GPU whenever possible. This can be used when there is sufficient VRAM available.\n"
|
||||
"CPU: Always loads only on the CPU."}),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,6 +109,8 @@ class SAMLoader:
|
||||
|
||||
CATEGORY = "ImpactPack"
|
||||
|
||||
DESCRIPTION = "Load the SAM (Segment Anything) model. This can be used in places that utilize SAM detection functionality, such as SAMDetector or SimpleDetector.\nThe SAM detection functionality in Impact Pack must use the SAM_MODEL loaded through this node."
|
||||
|
||||
def load_model(self, model_name, device_mode="auto"):
|
||||
if model_name == 'ESAM':
|
||||
if 'ESAM_ModelLoader_Zho' not in nodes.NODE_CLASS_MAPPINGS:
|
||||
@@ -237,14 +252,22 @@ class DetailerForEach:
|
||||
else:
|
||||
wmode, wildcard_chooser = None, None
|
||||
|
||||
if wmode in ['ASC', 'DSC']:
|
||||
if wmode in ['ASC', 'DSC', 'ASC-SIZE', 'DSC-SIZE']:
|
||||
if wmode == 'ASC':
|
||||
ordered_segs = sorted(segs[1], key=lambda x: (x.bbox[0], x.bbox[1]))
|
||||
else:
|
||||
elif wmode == 'DSC':
|
||||
ordered_segs = sorted(segs[1], key=lambda x: (x.bbox[0], x.bbox[1]), reverse=True)
|
||||
elif wmode == 'ASC-SIZE':
|
||||
ordered_segs = sorted(segs[1], key=lambda x: (x.bbox[2]-x.bbox[0]) * (x.bbox[3]-x.bbox[1]))
|
||||
|
||||
else: # wmode == 'DSC-SIZE'
|
||||
ordered_segs = sorted(segs[1], key=lambda x: (x.bbox[2]-x.bbox[0]) * (x.bbox[3]-x.bbox[1]), reverse=True)
|
||||
else:
|
||||
ordered_segs = segs[1]
|
||||
|
||||
if noise_mask_feather > 0 and 'denoise_mask_function' not in model.model_options:
|
||||
model = nodes_differential_diffusion.DifferentialDiffusion().apply(model)[0]
|
||||
|
||||
for i, seg in enumerate(ordered_segs):
|
||||
cropped_image = crop_ndarray4(image.cpu().numpy(), seg.crop_region) # Never use seg.cropped_image to handle overlapping area
|
||||
cropped_image = to_tensor(cropped_image)
|
||||
@@ -290,6 +313,13 @@ class DetailerForEach:
|
||||
# Negative Conditioning is placeholder such as FLUX.1
|
||||
cropped_negative = negative
|
||||
|
||||
if wildcard_item and wildcard_item.strip() == '[SKIP]':
|
||||
continue
|
||||
|
||||
if wildcard_item and wildcard_item.strip() == '[STOP]':
|
||||
break
|
||||
|
||||
orig_cropped_image = cropped_image.clone()
|
||||
enhanced_image, cnet_pils = core.enhance_detail(cropped_image, model, clip, vae, guide_size, guide_size_for_bbox, max_size,
|
||||
seg.bbox, seg_seed, steps, cfg, sampler_name, scheduler,
|
||||
cropped_positive, cropped_negative, denoise, cropped_mask, force_inpaint,
|
||||
@@ -309,7 +339,7 @@ class DetailerForEach:
|
||||
# use image paste
|
||||
image = image.cpu()
|
||||
enhanced_image = enhanced_image.cpu()
|
||||
tensor_paste(image, enhanced_image, (seg.crop_region[0], seg.crop_region[1]), mask)
|
||||
tensor_paste(image, enhanced_image, (seg.crop_region[0], seg.crop_region[1]), mask) # this code affecting to `cropped_image`.
|
||||
enhanced_list.append(enhanced_image)
|
||||
|
||||
if detailer_hook is not None:
|
||||
@@ -327,7 +357,7 @@ class DetailerForEach:
|
||||
else:
|
||||
new_seg_image = None
|
||||
|
||||
cropped_list.append(cropped_image)
|
||||
cropped_list.append(orig_cropped_image) # NOTE: Don't use `cropped_image`
|
||||
|
||||
new_seg = SEG(new_seg_image, seg.cropped_mask, seg.confidence, seg.crop_region, seg.bbox, seg.label, seg.control_net_wrapper)
|
||||
new_segs.append(new_seg)
|
||||
@@ -968,7 +998,10 @@ class PixelTiledKSampleUpscalerProvider:
|
||||
tile_size=max(tile_width, tile_height), tile_cnet_strength=tile_cnet_strength)
|
||||
return (upscaler, )
|
||||
else:
|
||||
print("[ERROR] PixelTiledKSampleUpscalerProvider: ComfyUI_TiledKSampler custom node isn't installed. You must install BlenderNeko/ComfyUI_TiledKSampler extension to use this node.")
|
||||
utils.try_install_custom_node('https://github.com/BlenderNeko/ComfyUI_TiledKSampler',
|
||||
"To use 'PixelTiledKSampleUpscalerProvider' node, 'BlenderNeko/ComfyUI_TiledKSampler' extension is required.")
|
||||
|
||||
raise Exception("[ERROR] PixelTiledKSampleUpscalerProvider: ComfyUI_TiledKSampler custom node isn't installed. You must install BlenderNeko/ComfyUI_TiledKSampler extension to use this node.")
|
||||
|
||||
|
||||
class PixelTiledKSampleUpscalerProviderPipe:
|
||||
@@ -1217,6 +1250,7 @@ class IterativeLatentUpscale:
|
||||
upscale_factor_unit = max(0, (upscale_factor - 1.0) / steps)
|
||||
|
||||
current_latent = samples
|
||||
noise_mask = current_latent.get('noise_mask')
|
||||
scale = 1
|
||||
|
||||
for i in range(steps-1):
|
||||
@@ -1231,6 +1265,8 @@ class IterativeLatentUpscale:
|
||||
print(f"IterativeLatentUpscale[{i+1}/{steps}]: {new_w:.1f}x{new_h:.1f} (scale:{scale:.2f}) ")
|
||||
step_info = i, steps
|
||||
current_latent = upscaler.upscale_shape(step_info, current_latent, new_w, new_h, temp_prefix)
|
||||
if noise_mask is not None:
|
||||
current_latent['noise_mask'] = noise_mask
|
||||
|
||||
if scale < upscale_factor:
|
||||
new_w = w*upscale_factor
|
||||
@@ -1242,7 +1278,7 @@ class IterativeLatentUpscale:
|
||||
|
||||
core.update_node_status(unique_id, "", None)
|
||||
|
||||
return (current_latent, upscaler.vae)
|
||||
return current_latent, upscaler.vae
|
||||
|
||||
|
||||
class IterativeImageUpscale:
|
||||
@@ -1625,6 +1661,8 @@ class BitwiseAndMaskForEach:
|
||||
|
||||
CATEGORY = "ImpactPack/Operation"
|
||||
|
||||
DESCRIPTION = "Retains only the overlapping areas between the masks included in base_segs and the mask regions of mask_segs. SEGS with no overlapping mask areas are filtered out."
|
||||
|
||||
def doit(self, base_segs, mask_segs):
|
||||
mask = core.segs_to_combined_mask(mask_segs)
|
||||
mask = make_3d_mask(mask)
|
||||
@@ -1646,6 +1684,8 @@ class SubtractMaskForEach:
|
||||
|
||||
CATEGORY = "ImpactPack/Operation"
|
||||
|
||||
DESCRIPTION = "Removes only the overlapping areas between the masks included in base_segs and the mask regions of mask_segs. SEGS with no overlapping mask areas are filtered out."
|
||||
|
||||
def doit(self, base_segs, mask_segs):
|
||||
mask = core.segs_to_combined_mask(mask_segs)
|
||||
mask = make_3d_mask(mask)
|
||||
@@ -1671,6 +1711,25 @@ class ToBinaryMask:
|
||||
return (mask,)
|
||||
|
||||
|
||||
class FlattenMask:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {"required": {
|
||||
"masks": ("MASK",),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("MASK",)
|
||||
FUNCTION = "doit"
|
||||
|
||||
CATEGORY = "ImpactPack/Operation"
|
||||
|
||||
def doit(self, masks):
|
||||
masks = utils.make_3d_mask(masks)
|
||||
masks = utils.flatten_mask(masks)
|
||||
return (masks,)
|
||||
|
||||
|
||||
class BitwiseAndMask:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
|
||||
@@ -24,37 +24,6 @@ import random
|
||||
from server import PromptServer
|
||||
|
||||
|
||||
@PromptServer.instance.routes.post("/upload/temp")
|
||||
async def upload_image(request):
|
||||
upload_dir = folder_paths.get_temp_directory()
|
||||
|
||||
if not os.path.exists(upload_dir):
|
||||
os.makedirs(upload_dir)
|
||||
|
||||
post = await request.post()
|
||||
image = post.get("image")
|
||||
|
||||
if image and image.file:
|
||||
filename = image.filename
|
||||
if not filename:
|
||||
return web.Response(status=400)
|
||||
|
||||
split = os.path.splitext(filename)
|
||||
i = 1
|
||||
while os.path.exists(os.path.join(upload_dir, filename)):
|
||||
filename = f"{split[0]} ({i}){split[1]}"
|
||||
i += 1
|
||||
|
||||
filepath = os.path.join(upload_dir, filename)
|
||||
|
||||
with open(filepath, "wb") as f:
|
||||
f.write(image.file.read())
|
||||
|
||||
return web.json_response({"name": filename})
|
||||
else:
|
||||
return web.Response(status=400)
|
||||
|
||||
|
||||
sam_predictor = None
|
||||
default_sam_model_name = os.path.join(impact_pack.model_path, "sams", "sam_vit_b_01ec64.pth")
|
||||
|
||||
@@ -353,13 +322,16 @@ def onprompt_for_switch(json_data):
|
||||
|
||||
cls = v['class_type']
|
||||
if cls == 'ImpactInversedSwitch':
|
||||
select_input = v['inputs']['select']
|
||||
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:
|
||||
inversed_switch_info[k] = select_input
|
||||
if 'sel_mode' in v['inputs'] and v['inputs']['sel_mode'] and 'select' in v['inputs']:
|
||||
select_input = v['inputs']['select']
|
||||
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")
|
||||
else:
|
||||
inversed_switch_info[k] = select_input
|
||||
|
||||
elif cls in ['ImpactSwitch', 'LatentSwitch', 'SEGSSwitch', 'ImpactMakeImageList']:
|
||||
if 'sel_mode' in v['inputs'] and v['inputs']['sel_mode'] and 'select' in v['inputs']:
|
||||
@@ -372,7 +344,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.\n##### ##### #####\n")
|
||||
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")
|
||||
else:
|
||||
onprompt_switch_info[k] = select_input
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@ class MMDetLoader:
|
||||
|
||||
CATEGORY = "ImpactPack/Legacy"
|
||||
|
||||
DEPRECATED = True
|
||||
|
||||
def load_mmdet(self, model_name):
|
||||
mmdet_path = folder_paths.get_full_path("mmdets", model_name)
|
||||
model = mmdet_nodes.load_mmdet(mmdet_path)
|
||||
@@ -52,6 +54,8 @@ class BboxDetectorForEach:
|
||||
|
||||
CATEGORY = "ImpactPack/Legacy"
|
||||
|
||||
DEPRECATED = True
|
||||
|
||||
@staticmethod
|
||||
def detect(bbox_model, image, threshold, dilation, crop_factor, drop_size=1, detailer_hook=None):
|
||||
mmdet_results = mmdet_nodes.inference_bbox(bbox_model, image, threshold)
|
||||
@@ -102,6 +106,8 @@ class SegmDetectorCombined:
|
||||
|
||||
CATEGORY = "ImpactPack/Legacy"
|
||||
|
||||
DEPRECATED = True
|
||||
|
||||
def doit(self, segm_model, image, threshold, dilation):
|
||||
mmdet_results = mmdet_nodes.inference_segm(image, segm_model, threshold)
|
||||
segmasks = core.create_segmasks(mmdet_results)
|
||||
@@ -150,6 +156,8 @@ class SegmDetectorForEach:
|
||||
|
||||
CATEGORY = "ImpactPack/Legacy"
|
||||
|
||||
DEPRECATED = True
|
||||
|
||||
def doit(self, segm_model, image, threshold, dilation, crop_factor):
|
||||
mmdet_results = mmdet_nodes.inference_segm(image, segm_model, threshold)
|
||||
segmasks = core.create_segmasks(mmdet_results)
|
||||
@@ -190,6 +198,8 @@ class SegsMaskCombine:
|
||||
|
||||
CATEGORY = "ImpactPack/Legacy"
|
||||
|
||||
DEPRECATED = True
|
||||
|
||||
@staticmethod
|
||||
def combine(segs, image):
|
||||
h = image.shape[1]
|
||||
@@ -226,6 +236,8 @@ class MaskPainter(nodes.PreviewImage):
|
||||
|
||||
CATEGORY = "ImpactPack/Legacy"
|
||||
|
||||
DEPRECATED = True
|
||||
|
||||
def save_painted_images(self, images, filename_prefix="impact-mask",
|
||||
prompt=None, extra_pnginfo=None, mask_image=None, image=None):
|
||||
if image == "#placeholder" or image['image_hash'] != id(images):
|
||||
|
||||
+116
-67
@@ -10,7 +10,6 @@ import re
|
||||
import nodes
|
||||
import traceback
|
||||
|
||||
|
||||
class ImpactCompare:
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
@@ -66,8 +65,8 @@ class ImpactConditionalBranch:
|
||||
return {
|
||||
"required": {
|
||||
"cond": ("BOOLEAN",),
|
||||
"tt_value": (any_typ,),
|
||||
"ff_value": (any_typ,),
|
||||
"tt_value": (any_typ,{"lazy": True}),
|
||||
"ff_value": (any_typ,{"lazy": True}),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -76,7 +75,13 @@ class ImpactConditionalBranch:
|
||||
|
||||
RETURN_TYPES = (any_typ, )
|
||||
|
||||
def doit(self, cond, tt_value, ff_value):
|
||||
def check_lazy_status(self, cond, tt_value=None, ff_value=None):
|
||||
if cond and tt_value is None:
|
||||
return ["tt_value"]
|
||||
if not cond and ff_value is None:
|
||||
return ["ff_value"]
|
||||
|
||||
def doit(self, cond, tt_value=None, ff_value=None):
|
||||
if cond:
|
||||
return (tt_value,)
|
||||
else:
|
||||
@@ -86,11 +91,18 @@ class ImpactConditionalBranch:
|
||||
class ImpactConditionalBranchSelMode:
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
if not core.is_execution_model_version_supported():
|
||||
required_inputs = {
|
||||
"cond": ("BOOLEAN",),
|
||||
"sel_mode": ("BOOLEAN", {"default": True, "label_on": "select_on_prompt", "label_off": "select_on_execution"}),
|
||||
},
|
||||
}
|
||||
else:
|
||||
required_inputs = {
|
||||
"cond": ("BOOLEAN",),
|
||||
}
|
||||
|
||||
return {
|
||||
"required": required_inputs,
|
||||
"optional": {
|
||||
"tt_value": (any_typ,),
|
||||
"ff_value": (any_typ,),
|
||||
@@ -102,7 +114,7 @@ class ImpactConditionalBranchSelMode:
|
||||
|
||||
RETURN_TYPES = (any_typ, )
|
||||
|
||||
def doit(self, cond, sel_mode, tt_value=None, ff_value=None):
|
||||
def doit(self, cond, tt_value=None, ff_value=None, **kwargs):
|
||||
print(f'tt={tt_value is None}\nff={ff_value is None}')
|
||||
if cond:
|
||||
return (tt_value,)
|
||||
@@ -618,85 +630,122 @@ class ImpactControlBridge:
|
||||
def INPUT_TYPES(cls):
|
||||
return {"required": {
|
||||
"value": (any_typ,),
|
||||
"mode": ("BOOLEAN", {"default": True, "label_on": "Active", "label_off": "Mute/Bypass"}),
|
||||
"behavior": ("BOOLEAN", {"default": True, "label_on": "Mute", "label_off": "Bypass"}),
|
||||
"mode": ("BOOLEAN", {"default": True, "label_on": "Active", "label_off": "Stop/Mute/Bypass"}),
|
||||
"behavior": (["Stop", "Mute", "Bypass"], ),
|
||||
},
|
||||
"hidden": {"unique_id": "UNIQUE_ID", "prompt": "PROMPT", "extra_pnginfo": "EXTRA_PNGINFO"}
|
||||
}
|
||||
|
||||
FUNCTION = "doit"
|
||||
|
||||
CATEGORY = "ImpactPack/Logic/_for_test"
|
||||
CATEGORY = "ImpactPack/Logic"
|
||||
RETURN_TYPES = (any_typ,)
|
||||
RETURN_NAMES = ("value",)
|
||||
OUTPUT_NODE = True
|
||||
|
||||
DESCRIPTION = ("When behavior is Stop and mode is active, the input value is passed directly to the output.\n"
|
||||
"When behavior is Mute/Bypass and mode is active, the node connected to the output is changed to active state.\n"
|
||||
"When behavior is Stop and mode is Stop/Mute/Bypass, the workflow execution of the current node is halted.\n"
|
||||
"When behavior is Mute/Bypass and mode is Stop/Mute/Bypass, the node connected to the output is changed to Mute/Bypass state.")
|
||||
|
||||
@classmethod
|
||||
def IS_CHANGED(self, value, mode, behavior=True, unique_id=None, prompt=None, extra_pnginfo=None):
|
||||
# NOTE: extra_pnginfo is not populated for IS_CHANGED.
|
||||
# so extra_pnginfo is useless in here
|
||||
try:
|
||||
workflow = core.current_prompt['extra_data']['extra_pnginfo']['workflow']
|
||||
except:
|
||||
print(f"[Impact Pack] core.current_prompt['extra_data']['extra_pnginfo']['workflow']")
|
||||
return 0
|
||||
def IS_CHANGED(self, value, mode, behavior="Stop", unique_id=None, prompt=None, extra_pnginfo=None):
|
||||
if behavior == "Stop":
|
||||
return value, mode, behavior
|
||||
else:
|
||||
# NOTE: extra_pnginfo is not populated for IS_CHANGED.
|
||||
# so extra_pnginfo is useless in here
|
||||
try:
|
||||
workflow = core.current_prompt['extra_data']['extra_pnginfo']['workflow']
|
||||
except:
|
||||
print(f"[Impact Pack] core.current_prompt['extra_data']['extra_pnginfo']['workflow']")
|
||||
return 0
|
||||
|
||||
nodes, links = workflow_to_map(workflow)
|
||||
next_nodes = []
|
||||
nodes, links = workflow_to_map(workflow)
|
||||
next_nodes = []
|
||||
|
||||
for link in nodes[unique_id]['outputs'][0]['links']:
|
||||
node_id = str(links[link][2])
|
||||
impact.utils.collect_non_reroute_nodes(nodes, links, next_nodes, node_id)
|
||||
for link in nodes[unique_id]['outputs'][0]['links']:
|
||||
node_id = str(links[link][2])
|
||||
impact.utils.collect_non_reroute_nodes(nodes, links, next_nodes, node_id)
|
||||
|
||||
return next_nodes
|
||||
|
||||
def doit(self, value, mode, behavior=True, unique_id=None, prompt=None, extra_pnginfo=None):
|
||||
def doit(self, value, mode, behavior="Stop", unique_id=None, prompt=None, extra_pnginfo=None):
|
||||
global error_skip_flag
|
||||
|
||||
workflow_nodes, links = workflow_to_map(extra_pnginfo['workflow'])
|
||||
|
||||
active_nodes = []
|
||||
mute_nodes = []
|
||||
bypass_nodes = []
|
||||
|
||||
for link in workflow_nodes[unique_id]['outputs'][0]['links']:
|
||||
node_id = str(links[link][2])
|
||||
|
||||
next_nodes = []
|
||||
impact.utils.collect_non_reroute_nodes(workflow_nodes, links, next_nodes, node_id)
|
||||
|
||||
for next_node_id in next_nodes:
|
||||
node_mode = workflow_nodes[next_node_id]['mode']
|
||||
|
||||
if node_mode == 0:
|
||||
active_nodes.append(next_node_id)
|
||||
elif node_mode == 2:
|
||||
mute_nodes.append(next_node_id)
|
||||
elif node_mode == 4:
|
||||
bypass_nodes.append(next_node_id)
|
||||
|
||||
if mode:
|
||||
# active
|
||||
should_be_active_nodes = mute_nodes + bypass_nodes
|
||||
if len(should_be_active_nodes) > 0:
|
||||
PromptServer.instance.send_sync("impact-bridge-continue", {"node_id": unique_id, 'actives': list(should_be_active_nodes)})
|
||||
nodes.interrupt_processing()
|
||||
|
||||
elif behavior:
|
||||
# mute
|
||||
should_be_mute_nodes = active_nodes + bypass_nodes
|
||||
if len(should_be_mute_nodes) > 0:
|
||||
PromptServer.instance.send_sync("impact-bridge-continue", {"node_id": unique_id, 'mutes': list(should_be_mute_nodes)})
|
||||
nodes.interrupt_processing()
|
||||
|
||||
if core.is_execution_model_version_supported:
|
||||
from comfy_execution.graph import ExecutionBlocker
|
||||
else:
|
||||
# bypass
|
||||
should_be_bypass_nodes = active_nodes + mute_nodes
|
||||
if len(should_be_bypass_nodes) > 0:
|
||||
PromptServer.instance.send_sync("impact-bridge-continue", {"node_id": unique_id, 'bypasses': list(should_be_bypass_nodes)})
|
||||
nodes.interrupt_processing()
|
||||
print("[Impact Pack] ImpactControlBridge: ComfyUI is outdated. The 'Stop' behavior cannot function properly.")
|
||||
|
||||
return (value, )
|
||||
if behavior == "Stop":
|
||||
if mode:
|
||||
return (value, )
|
||||
else:
|
||||
return (ExecutionBlocker(None), )
|
||||
else:
|
||||
workflow_nodes, links = workflow_to_map(extra_pnginfo['workflow'])
|
||||
|
||||
active_nodes = []
|
||||
mute_nodes = []
|
||||
bypass_nodes = []
|
||||
|
||||
for link in workflow_nodes[unique_id]['outputs'][0]['links']:
|
||||
node_id = str(links[link][2])
|
||||
|
||||
next_nodes = []
|
||||
impact.utils.collect_non_reroute_nodes(workflow_nodes, links, next_nodes, node_id)
|
||||
|
||||
for next_node_id in next_nodes:
|
||||
node_mode = workflow_nodes[next_node_id]['mode']
|
||||
|
||||
if node_mode == 0:
|
||||
active_nodes.append(next_node_id)
|
||||
elif node_mode == 2:
|
||||
mute_nodes.append(next_node_id)
|
||||
elif node_mode == 4:
|
||||
bypass_nodes.append(next_node_id)
|
||||
|
||||
if mode:
|
||||
# active
|
||||
should_be_active_nodes = mute_nodes + bypass_nodes
|
||||
if len(should_be_active_nodes) > 0:
|
||||
PromptServer.instance.send_sync("impact-bridge-continue", {"node_id": unique_id, 'actives': list(should_be_active_nodes)})
|
||||
nodes.interrupt_processing()
|
||||
|
||||
elif behavior == "Mute" or behavior == True:
|
||||
# mute
|
||||
should_be_mute_nodes = active_nodes + bypass_nodes
|
||||
if len(should_be_mute_nodes) > 0:
|
||||
PromptServer.instance.send_sync("impact-bridge-continue", {"node_id": unique_id, 'mutes': list(should_be_mute_nodes)})
|
||||
nodes.interrupt_processing()
|
||||
|
||||
else:
|
||||
# bypass
|
||||
should_be_bypass_nodes = active_nodes + mute_nodes
|
||||
if len(should_be_bypass_nodes) > 0:
|
||||
PromptServer.instance.send_sync("impact-bridge-continue", {"node_id": unique_id, 'bypasses': list(should_be_bypass_nodes)})
|
||||
nodes.interrupt_processing()
|
||||
|
||||
return (value, )
|
||||
|
||||
|
||||
class ImpactExecutionOrderController:
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {"required": {
|
||||
"signal": (any_typ,),
|
||||
"value": (any_typ,),
|
||||
}}
|
||||
|
||||
FUNCTION = "doit"
|
||||
|
||||
CATEGORY = "ImpactPack/Util"
|
||||
RETURN_TYPES = (any_typ, any_typ)
|
||||
RETURN_NAMES = ("signal", "value")
|
||||
|
||||
def doit(self, signal, value):
|
||||
return signal, value
|
||||
|
||||
|
||||
original_handle_execution = execution.PromptExecutor.handle_execution_error
|
||||
|
||||
@@ -14,6 +14,13 @@ from comfy.cli_args import args
|
||||
import math
|
||||
|
||||
|
||||
try:
|
||||
from comfy_extras import nodes_differential_diffusion
|
||||
except Exception:
|
||||
print(f"\n#############################################\n[Impact Pack] ComfyUI is an outdated version.\n#############################################\n")
|
||||
raise Exception("[Impact Pack] ComfyUI is an outdated version.")
|
||||
|
||||
|
||||
class SEGSDetailer:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
@@ -69,6 +76,9 @@ class SEGSDetailer:
|
||||
new_segs = []
|
||||
cnet_pil_list = []
|
||||
|
||||
if noise_mask_feather > 0 and 'denoise_mask_function' not in model.model_options:
|
||||
model = nodes_differential_diffusion.DifferentialDiffusion().apply(model)[0]
|
||||
|
||||
for i in range(batch_size):
|
||||
seed += 1
|
||||
for seg in segs[1]:
|
||||
@@ -1403,8 +1413,6 @@ class SEGSPicker:
|
||||
|
||||
RETURN_TYPES = ("SEGS", )
|
||||
|
||||
OUTPUT_NODE = True
|
||||
|
||||
FUNCTION = "doit"
|
||||
|
||||
CATEGORY = "ImpactPack/Util"
|
||||
|
||||
@@ -98,7 +98,7 @@ def img2img_segs(image, model, clip, vae, seed, steps, cfg, sampler_name, schedu
|
||||
noise_mask = tensor_gaussian_blur_mask(noise_mask, noise_mask_feather)
|
||||
noise_mask = noise_mask.squeeze(3)
|
||||
|
||||
if noise_mask_feather > 0:
|
||||
if noise_mask_feather > 0 and 'denoise_mask_function' not in model.model_options:
|
||||
model = nodes_differential_diffusion.DifferentialDiffusion().apply(model)[0]
|
||||
|
||||
if control_net_wrapper is not None:
|
||||
|
||||
+119
-265
@@ -5,39 +5,25 @@ from impact.utils import *
|
||||
from nodes import MAX_RESOLUTION
|
||||
import nodes
|
||||
from impact.impact_sampling import KSamplerWrapper, KSamplerAdvancedWrapper, separated_sample, impact_sample
|
||||
|
||||
import comfy
|
||||
|
||||
class TiledKSamplerProvider:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {"required": {
|
||||
"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, ),
|
||||
"denoise": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}),
|
||||
"tile_width": ("INT", {"default": 512, "min": 320, "max": MAX_RESOLUTION, "step": 64}),
|
||||
"tile_height": ("INT", {"default": 512, "min": 320, "max": MAX_RESOLUTION, "step": 64}),
|
||||
"tiling_strategy": (["random", "padded", 'simple'], ),
|
||||
"basic_pipe": ("BASIC_PIPE", )
|
||||
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff, "tooltip": "Random seed to use for generating CPU noise for sampling."}),
|
||||
"steps": ("INT", {"default": 20, "min": 1, "max": 10000, "tooltip": "total sampling steps"}),
|
||||
"cfg": ("FLOAT", {"default": 8.0, "min": 0.0, "max": 100.0, "tooltip": "classifier free guidance value"}),
|
||||
"sampler_name": (comfy.samplers.KSampler.SAMPLERS, {"tooltip": "sampler"}),
|
||||
"scheduler": (comfy.samplers.KSampler.SCHEDULERS, {"tooltip": "noise schedule"}),
|
||||
"denoise": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01, "tooltip": "The amount of noise to remove. This amount is the noise added at the start, and the higher it is, the more the input latent will be modified before being returned."}),
|
||||
"tile_width": ("INT", {"default": 512, "min": 320, "max": MAX_RESOLUTION, "step": 64, "tooltip": "Sets the width of the tile to be used in TiledKSampler."}),
|
||||
"tile_height": ("INT", {"default": 512, "min": 320, "max": MAX_RESOLUTION, "step": 64, "tooltip": "Sets the height of the tile to be used in TiledKSampler."}),
|
||||
"tiling_strategy": (["random", "padded", 'simple'], {"tooltip": "Sets the tiling strategy for TiledKSampler."} ),
|
||||
"basic_pipe": ("BASIC_PIPE", {"tooltip": "basic_pipe input for sampling"})
|
||||
}}
|
||||
|
||||
TOOLTIPS = {
|
||||
"input": {
|
||||
"seed": "Random seed to use for generating CPU noise for sampling.",
|
||||
"steps": "total sampling steps",
|
||||
"cfg": "classifier free guidance value",
|
||||
"sampler_name": "sampler",
|
||||
"scheduler": "noise schedule",
|
||||
"denoise": "The amount of noise to remove. This amount is the noise added at the start, and the higher it is, the more the input latent will be modified before being returned.",
|
||||
"tile_width": "Sets the width of the tile to be used in TiledKSampler.",
|
||||
"tile_height": "Sets the height of the tile to be used in TiledKSampler.",
|
||||
"tiling_strategy": "Sets the tiling strategy for TiledKSampler.",
|
||||
"basic_pipe": "basic_pipe input for sampling",
|
||||
},
|
||||
"output": ("sampler wrapper. (Can be used when generating a regional_prompt.)", )
|
||||
}
|
||||
OUTPUT_TOOLTIPS = ("sampler wrapper. (Can be used when generating a regional_prompt.)", )
|
||||
|
||||
RETURN_TYPES = ("KSAMPLER",)
|
||||
FUNCTION = "doit"
|
||||
@@ -57,32 +43,20 @@ class KSamplerProvider:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {"required": {
|
||||
"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": (core.SCHEDULERS, ),
|
||||
"denoise": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}),
|
||||
"basic_pipe": ("BASIC_PIPE", )
|
||||
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff, "tooltip": "Random seed to use for generating CPU noise for sampling."}),
|
||||
"steps": ("INT", {"default": 20, "min": 1, "max": 10000, "tooltip": "total sampling steps"}),
|
||||
"cfg": ("FLOAT", {"default": 8.0, "min": 0.0, "max": 100.0, "tooltip": "classifier free guidance value"}),
|
||||
"sampler_name": (comfy.samplers.KSampler.SAMPLERS, {"tooltip": "sampler"}),
|
||||
"scheduler": (core.SCHEDULERS, {"tooltip": "noise schedule"}),
|
||||
"denoise": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01, "tooltip": "The amount of noise to remove. This amount is the noise added at the start, and the higher it is, the more the input latent will be modified before being returned."}),
|
||||
"basic_pipe": ("BASIC_PIPE", {"tooltip": "basic_pipe input for sampling"})
|
||||
},
|
||||
"optional": {
|
||||
"scheduler_func_opt": ("SCHEDULER_FUNC",),
|
||||
"scheduler_func_opt": ("SCHEDULER_FUNC", {"tooltip": "[OPTIONAL] Noise schedule generation function. If this is set, the scheduler widget will be ignored."}),
|
||||
}
|
||||
}
|
||||
|
||||
TOOLTIPS = {
|
||||
"input": {
|
||||
"seed": "Random seed to use for generating CPU noise for sampling.",
|
||||
"steps": "total sampling steps",
|
||||
"cfg": "classifier free guidance value",
|
||||
"sampler_name": "sampler",
|
||||
"scheduler": "noise schedule",
|
||||
"denoise": "The amount of noise to remove. This amount is the noise added at the start, and the higher it is, the more the input latent will be modified before being returned.",
|
||||
"basic_pipe": "basic_pipe input for sampling",
|
||||
"scheduler_func_opt": "[OPTIONAL] Noise schedule generation function. If this is set, the scheduler widget will be ignored.",
|
||||
},
|
||||
"output": ("sampler wrapper. (Can be used when generating a regional_prompt.)", )
|
||||
}
|
||||
OUTPUT_TOOLTIPS = ("sampler wrapper. (Can be used when generating a regional_prompt.)",)
|
||||
|
||||
RETURN_TYPES = ("KSAMPLER",)
|
||||
FUNCTION = "doit"
|
||||
@@ -100,30 +74,19 @@ class KSamplerAdvancedProvider:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {"required": {
|
||||
"cfg": ("FLOAT", {"default": 8.0, "min": 0.0, "max": 100.0}),
|
||||
"sampler_name": (comfy.samplers.KSampler.SAMPLERS, ),
|
||||
"scheduler": (core.SCHEDULERS, ),
|
||||
"sigma_factor": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.01}),
|
||||
"basic_pipe": ("BASIC_PIPE", )
|
||||
"cfg": ("FLOAT", {"default": 8.0, "min": 0.0, "max": 100.0, "toolip": "classifier free guidance value"}),
|
||||
"sampler_name": (comfy.samplers.KSampler.SAMPLERS, {"toolip": "sampler"}),
|
||||
"scheduler": (core.SCHEDULERS, {"toolip": "noise schedule"}),
|
||||
"sigma_factor": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.01, "toolip": "Multiplier of noise schedule"}),
|
||||
"basic_pipe": ("BASIC_PIPE", {"toolip": "basic_pipe input for sampling"})
|
||||
},
|
||||
"optional": {
|
||||
"sampler_opt": ("SAMPLER", ),
|
||||
"scheduler_func_opt": ("SCHEDULER_FUNC",),
|
||||
"sampler_opt": ("SAMPLER", {"toolip": "[OPTIONAL] Uses the passed sampler instead of internal impact_sampler."}),
|
||||
"scheduler_func_opt": ("SCHEDULER_FUNC", {"toolip": "[OPTIONAL] Noise schedule generation function. If this is set, the scheduler widget will be ignored."}),
|
||||
}
|
||||
}
|
||||
|
||||
TOOLTIPS = {
|
||||
"input": {
|
||||
"cfg": "classifier free guidance value",
|
||||
"sampler_name": "sampler",
|
||||
"scheduler": "noise schedule",
|
||||
"sigma_factor": "Multiplier of noise schedule",
|
||||
"basic_pipe": "basic_pipe input for sampling",
|
||||
"sampler_opt": "[OPTIONAL] Uses the passed sampler instead of internal impact_sampler.",
|
||||
"scheduler_func_opt": "[OPTIONAL] Noise schedule generation function. If this is set, the scheduler widget will be ignored.",
|
||||
},
|
||||
"output": ("sampler wrapper. (Can be used when generating a regional_prompt.)", )
|
||||
}
|
||||
OUTPUT_TOOLTIPS = ("sampler wrapper. (Can be used when generating a regional_prompt.)", )
|
||||
|
||||
RETURN_TYPES = ("KSAMPLER_ADVANCED",)
|
||||
FUNCTION = "doit"
|
||||
@@ -141,22 +104,14 @@ class TwoSamplersForMask:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {"required": {
|
||||
"latent_image": ("LATENT", ),
|
||||
"base_sampler": ("KSAMPLER", ),
|
||||
"mask_sampler": ("KSAMPLER", ),
|
||||
"mask": ("MASK", )
|
||||
"latent_image": ("LATENT", {"tooltip": "input latent image"}),
|
||||
"base_sampler": ("KSAMPLER", {"tooltip": "Sampler to apply to the region outside the mask."}),
|
||||
"mask_sampler": ("KSAMPLER", {"tooltip": "Sampler to apply to the masked region."}),
|
||||
"mask": ("MASK", {"tooltip": "region mask"})
|
||||
},
|
||||
}
|
||||
|
||||
TOOLTIPS = {
|
||||
"input": {
|
||||
"latent_image": "input latent image",
|
||||
"base_sampler": "Sampler to apply to the region outside the mask.",
|
||||
"mask_sampler": "Sampler to apply to the masked region.",
|
||||
"mask": "region mask",
|
||||
},
|
||||
"output": ("result latent", )
|
||||
}
|
||||
OUTPUT_TOOLTIPS = ("result latent", )
|
||||
|
||||
RETURN_TYPES = ("LATENT", )
|
||||
FUNCTION = "doit"
|
||||
@@ -182,30 +137,18 @@ class TwoAdvancedSamplersForMask:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {"required": {
|
||||
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff}),
|
||||
"steps": ("INT", {"default": 20, "min": 1, "max": 10000}),
|
||||
"denoise": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}),
|
||||
"samples": ("LATENT", ),
|
||||
"base_sampler": ("KSAMPLER_ADVANCED", ),
|
||||
"mask_sampler": ("KSAMPLER_ADVANCED", ),
|
||||
"mask": ("MASK", ),
|
||||
"overlap_factor": ("INT", {"default": 10, "min": 0, "max": 10000})
|
||||
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff, "tooltip": "Random seed to use for generating CPU noise for sampling."}),
|
||||
"steps": ("INT", {"default": 20, "min": 1, "max": 10000, "tooltip": "total sampling steps"}),
|
||||
"denoise": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01, "tooltip": "The amount of noise to remove. This amount is the noise added at the start, and the higher it is, the more the input latent will be modified before being returned."}),
|
||||
"samples": ("LATENT", {"tooltip": "input latent image"}),
|
||||
"base_sampler": ("KSAMPLER_ADVANCED", {"tooltip": "Sampler to apply to the region outside the mask."}),
|
||||
"mask_sampler": ("KSAMPLER_ADVANCED", {"tooltip": "Sampler to apply to the masked region."}),
|
||||
"mask": ("MASK", {"tooltip": "region mask"}),
|
||||
"overlap_factor": ("INT", {"default": 10, "min": 0, "max": 10000, "tooltip": "To smooth the seams of the region boundaries, expand the mask by the overlap_factor amount to overlap with other regions."})
|
||||
},
|
||||
}
|
||||
|
||||
TOOLTIPS = {
|
||||
"input": {
|
||||
"seed": "Random seed to use for generating CPU noise for sampling.",
|
||||
"steps": "total sampling steps",
|
||||
"denoise": "The amount of noise to remove. This amount is the noise added at the start, and the higher it is, the more the input latent will be modified before being returned.",
|
||||
"samples": "input latent image",
|
||||
"base_sampler": "Sampler to apply to the region outside the mask.",
|
||||
"mask_sampler": "Sampler to apply to the masked region.",
|
||||
"mask": "region mask",
|
||||
"overlap_factor": "To smooth the seams of the region boundaries, expand the mask by the overlap_factor amount to overlap with other regions.",
|
||||
},
|
||||
"output": ("result latent", )
|
||||
}
|
||||
OUTPUT_TOOLTIPS = ("result latent", )
|
||||
|
||||
RETURN_TYPES = ("LATENT", )
|
||||
FUNCTION = "doit"
|
||||
@@ -227,23 +170,17 @@ class RegionalPrompt:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {"required": {
|
||||
"mask": ("MASK", ),
|
||||
"advanced_sampler": ("KSAMPLER_ADVANCED", ),
|
||||
"mask": ("MASK", {"tooltip": "region mask"}),
|
||||
"advanced_sampler": ("KSAMPLER_ADVANCED", {"tooltip": "sampler for specified region"}),
|
||||
},
|
||||
"optional": {
|
||||
"variation_seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff}),
|
||||
"variation_strength": ("FLOAT", {"default": 0.0, "min": 0.0, "max": 1.0, "step": 0.01}),
|
||||
"variation_method": (["linear", "slerp"],),
|
||||
"variation_seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff, "tooltip": "Sets the extra seed to be used for noise variation."}),
|
||||
"variation_strength": ("FLOAT", {"default": 0.0, "min": 0.0, "max": 1.0, "step": 0.01, "tooltip": "Sets the strength of the noise variation."}),
|
||||
"variation_method": (["linear", "slerp"], {"tooltip": "Sets how the original noise and extra noise are blended together."}),
|
||||
}
|
||||
}
|
||||
|
||||
TOOLTIPS = {
|
||||
"input": {
|
||||
"mask": "region mask",
|
||||
"advanced_sampler": "sampler for specified region",
|
||||
},
|
||||
"output": ("regional prompts. (Can be used in the RegionalSampler.)", )
|
||||
}
|
||||
OUTPUT_TOOLTIPS = ("regional prompts. (Can be used in the RegionalSampler.)", )
|
||||
|
||||
RETURN_TYPES = ("REGIONAL_PROMPTS", )
|
||||
FUNCTION = "doit"
|
||||
@@ -260,16 +197,11 @@ class CombineRegionalPrompts:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {"required": {
|
||||
"regional_prompts1": ("REGIONAL_PROMPTS", ),
|
||||
"regional_prompts1": ("REGIONAL_PROMPTS", {"tooltip": "input regional_prompts. (Connecting to the input slot increases the number of additional slots.)"}),
|
||||
},
|
||||
}
|
||||
|
||||
TOOLTIPS = {
|
||||
"input": {
|
||||
"regional_prompts1": "input regional_prompts. (Connecting to the input slot increases the number of additional slots.)",
|
||||
},
|
||||
"output": ("Combined REGIONAL_PROMPTS", )
|
||||
}
|
||||
OUTPUT_TOOLTIPS = ("Combined REGIONAL_PROMPTS", )
|
||||
|
||||
RETURN_TYPES = ("REGIONAL_PROMPTS", )
|
||||
FUNCTION = "doit"
|
||||
@@ -289,16 +221,11 @@ class CombineConditionings:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {"required": {
|
||||
"conditioning1": ("CONDITIONING", ),
|
||||
"conditioning1": ("CONDITIONING", { "tooltip": "input conditionings. (Connecting to the input slot increases the number of additional slots.)" }),
|
||||
},
|
||||
}
|
||||
|
||||
TOOLTIPS = {
|
||||
"input": {
|
||||
"conditioning1": "input conditionings. (Connecting to the input slot increases the number of additional slots.)",
|
||||
},
|
||||
"output": ("Combined conditioning", )
|
||||
}
|
||||
OUTPUT_TOOLTIPS = ("Combined conditioning", )
|
||||
|
||||
RETURN_TYPES = ("CONDITIONING", )
|
||||
FUNCTION = "doit"
|
||||
@@ -318,16 +245,11 @@ class ConcatConditionings:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {"required": {
|
||||
"conditioning1": ("CONDITIONING", ),
|
||||
"conditioning1": ("CONDITIONING", { "tooltip": "input conditionings. (Connecting to the input slot increases the number of additional slots.)" }),
|
||||
},
|
||||
}
|
||||
|
||||
TOOLTIPS = {
|
||||
"input": {
|
||||
"conditioning1": "input conditionings. (Connecting to the input slot increases the number of additional slots.)",
|
||||
},
|
||||
"output": ("Concatenated conditioning", )
|
||||
}
|
||||
OUTPUT_TOOLTIPS = ("Concatenated conditioning", )
|
||||
|
||||
RETURN_TYPES = ("CONDITIONING", )
|
||||
FUNCTION = "doit"
|
||||
@@ -360,43 +282,25 @@ class RegionalSampler:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {"required": {
|
||||
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff}),
|
||||
"seed_2nd": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff}),
|
||||
"seed_2nd_mode": (["ignore", "fixed", "seed+seed_2nd", "seed-seed_2nd", "increment", "decrement", "randomize"], ),
|
||||
"steps": ("INT", {"default": 20, "min": 1, "max": 10000}),
|
||||
"base_only_steps": ("INT", {"default": 2, "min": 0, "max": 10000}),
|
||||
"denoise": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}),
|
||||
"samples": ("LATENT", ),
|
||||
"base_sampler": ("KSAMPLER_ADVANCED", ),
|
||||
"regional_prompts": ("REGIONAL_PROMPTS", ),
|
||||
"overlap_factor": ("INT", {"default": 10, "min": 0, "max": 10000}),
|
||||
"restore_latent": ("BOOLEAN", {"default": True, "label_on": "enabled", "label_off": "disabled"}),
|
||||
"additional_mode": (["DISABLE", "ratio additional", "ratio between"], {"default": "ratio between"}),
|
||||
"additional_sampler": (["AUTO", "euler", "heun", "heunpp2", "dpm_2", "dpm_fast", "dpmpp_2m", "ddpm"],),
|
||||
"additional_sigma_ratio": ("FLOAT", {"default": 0.3, "min": 0.0, "max": 1.0, "step": 0.01}),
|
||||
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff, "tooltip": "Random seed to use for generating CPU noise for sampling."}),
|
||||
"seed_2nd": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff, "tooltip": "Additional noise seed. The behavior is determined by seed_2nd_mode."}),
|
||||
"seed_2nd_mode": (["ignore", "fixed", "seed+seed_2nd", "seed-seed_2nd", "increment", "decrement", "randomize"], {"tooltip": "application method of seed_2nd. 1) ignore: Do not use seed_2nd. In the base only sampling stage, the seed is applied as a noise seed, and in the regional sampling stage, denoising is performed as it is without additional noise. 2) Others: In the base only sampling stage, the seed is applied as a noise seed, and once it is closed so that there is no leftover noise, new noise is added with seed_2nd and the regional samping stage is performed. a) fixed: Use seed_2nd as it is as an additional noise seed. b) seed+seed_2nd: Apply the value of seed+seed_2nd as an additional noise seed. c) seed-seed_2nd: Apply the value of seed-seed_2nd as an additional noise seed. d) increment: Not implemented yet. Same with fixed. e) decrement: Not implemented yet. Same with fixed. f) randomize: Not implemented yet. Same with fixed."}),
|
||||
"steps": ("INT", {"default": 20, "min": 1, "max": 10000, "tooltip": "total sampling steps"}),
|
||||
"base_only_steps": ("INT", {"default": 2, "min": 0, "max": 10000, "tooltip": "total sampling steps"}),
|
||||
"denoise": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01, "tooltip": "The amount of noise to remove. This amount is the noise added at the start, and the higher it is, the more the input latent will be modified before being returned."}),
|
||||
"samples": ("LATENT", {"tooltip": "input latent image"}),
|
||||
"base_sampler": ("KSAMPLER_ADVANCED", {"tooltip": "The sampler applied outside the area set by the regional_prompt."}),
|
||||
"regional_prompts": ("REGIONAL_PROMPTS", {"tooltip": "The prompt applied to each region"}),
|
||||
"overlap_factor": ("INT", {"default": 10, "min": 0, "max": 10000, "tooltip": "To smooth the seams of the region boundaries, expand the mask set in regional_prompts by the overlap_factor amount to overlap with other regions."}),
|
||||
"restore_latent": ("BOOLEAN", {"default": True, "label_on": "enabled", "label_off": "disabled", "tooltip": "At each step, restore the noise outside the mask area to its original state, as per the principle of inpainting. This option is provided for backward compatibility, and it is recommended to always set it to true."}),
|
||||
"additional_mode": (["DISABLE", "ratio additional", "ratio between"], {"default": "ratio between", "tooltip": "..._sde or uni_pc and other special samplers are used, the region is not properly denoised, and it causes a phenomenon that destroys the overall harmony. To compensate for this, a recovery operation is performed using another sampler. This requires a longer time for sampling because a second sampling is performed at each step in each region using a special sampler. 1) DISABLE: Disable this feature. 2) ratio additional: After performing the denoise amount to be performed in the step with the sampler set in the region, the recovery sampler is additionally applied by the additional_sigma_ratio. If you use this option, the total denoise amount increases by additional_sigma_ratio. 3) ratio between: The denoise amount to be performed in the step with the sampler set in the region and the denoise amount to be applied to the recovery sampler are divided by additional_sigma_ratio, and denoise is performed for each denoise amount. If you use this option, the total denoise amount does not change."}),
|
||||
"additional_sampler": (["AUTO", "euler", "heun", "heunpp2", "dpm_2", "dpm_fast", "dpmpp_2m", "ddpm"], {"tooltip": "1) AUTO: Automatically set the recovery sampler. If the sampler is uni_pc, uni_pc_bh2, dpmpp_sde, dpmpp_sde_gpu, the dpm_fast sampler is selected If the sampler is dpmpp_2m_sde, dpmpp_2m_sde_gpu, dpmpp_3m_sde, dpmpp_3m_sde_gpu, the dpmpp_2m sampler is selected. 2) Others: Manually set the recovery sampler."}),
|
||||
"additional_sigma_ratio": ("FLOAT", {"default": 0.3, "min": 0.0, "max": 1.0, "step": 0.01, "tooltip": "Multiplier of noise schedule to be applied according to additional_mode."}),
|
||||
},
|
||||
"hidden": {"unique_id": "UNIQUE_ID"},
|
||||
}
|
||||
|
||||
TOOLTIPS = {
|
||||
"input": {
|
||||
"seed": "Random seed to use for generating CPU noise for sampling.",
|
||||
"seed_2nd": "Additional noise seed. The behavior is determined by seed_2nd_mode.",
|
||||
"seed_2nd_mode": "application method of seed_2nd. 1) ignore: Do not use seed_2nd. In the base only sampling stage, the seed is applied as a noise seed, and in the regional sampling stage, denoising is performed as it is without additional noise. 2) Others: In the base only sampling stage, the seed is applied as a noise seed, and once it is closed so that there is no leftover noise, new noise is added with seed_2nd and the regional samping stage is performed. a) fixed: Use seed_2nd as it is as an additional noise seed. b) seed+seed_2nd: Apply the value of seed+seed_2nd as an additional noise seed. c) seed-seed_2nd: Apply the value of seed-seed_2nd as an additional noise seed. d) increment: Not implemented yet. Same with fixed. e) decrement: Not implemented yet. Same with fixed. f) randomize: Not implemented yet. Same with fixed.",
|
||||
"steps": "total sampling steps",
|
||||
"base_only_steps": "total sampling steps",
|
||||
"denoise": "The amount of noise to remove. This amount is the noise added at the start, and the higher it is, the more the input latent will be modified before being returned.",
|
||||
"samples": "input latent image",
|
||||
"base_sampler": "The sampler applied outside the area set by the regional_prompt.",
|
||||
"regional_prompts": "The prompt applied to each region",
|
||||
"overlap_factor": "To smooth the seams of the region boundaries, expand the mask set in regional_prompts by the overlap_factor amount to overlap with other regions.",
|
||||
"restore_latent": "At each step, restore the noise outside the mask area to its original state, as per the principle of inpainting. This option is provided for backward compatibility, and it is recommended to always set it to true.",
|
||||
"additional_mode": "..._sde or uni_pc and other special samplers are used, the region is not properly denoised, and it causes a phenomenon that destroys the overall harmony. To compensate for this, a recovery operation is performed using another sampler. This requires a longer time for sampling because a second sampling is performed at each step in each region using a special sampler. 1) DISABLE: Disable this feature. 2) ratio additional: After performing the denoise amount to be performed in the step with the sampler set in the region, the recovery sampler is additionally applied by the additional_sigma_ratio. If you use this option, the total denoise amount increases by additional_sigma_ratio. 3) ratio between: The denoise amount to be performed in the step with the sampler set in the region and the denoise amount to be applied to the recovery sampler are divided by additional_sigma_ratio, and denoise is performed for each denoise amount. If you use this option, the total denoise amount does not change.",
|
||||
"additional_sampler": "1) AUTO: Automatically set the recovery sampler. If the sampler is uni_pc, uni_pc_bh2, dpmpp_sde, dpmpp_sde_gpu, the dpm_fast sampler is selected If the sampler is dpmpp_2m_sde, dpmpp_2m_sde_gpu, dpmpp_3m_sde, dpmpp_3m_sde_gpu, the dpmpp_2m sampler is selected. 2) Others: Manually set the recovery sampler.",
|
||||
"additional_sigma_ratio": "Multiplier of noise schedule to be applied according to additional_mode.",
|
||||
},
|
||||
"output": ("result latent", )
|
||||
}
|
||||
OUTPUT_TOOLTIPS = ("result latent", )
|
||||
|
||||
RETURN_TYPES = ("LATENT", )
|
||||
FUNCTION = "doit"
|
||||
@@ -428,6 +332,10 @@ class RegionalSampler:
|
||||
@staticmethod
|
||||
def doit(seed, seed_2nd, seed_2nd_mode, steps, base_only_steps, denoise, samples, base_sampler, regional_prompts, overlap_factor, restore_latent,
|
||||
additional_mode, additional_sampler, additional_sigma_ratio, unique_id=None):
|
||||
|
||||
samples = samples.copy()
|
||||
samples['samples'] = comfy.sample.fix_empty_latent_channels(base_sampler.params[0], samples['samples'])
|
||||
|
||||
if restore_latent:
|
||||
latent_compositor = nodes.NODE_CLASS_MAPPINGS['LatentCompositeMasked']()
|
||||
else:
|
||||
@@ -543,44 +451,25 @@ class RegionalSamplerAdvanced:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {"required": {
|
||||
"add_noise": ("BOOLEAN", {"default": True, "label_on": "enabled", "label_off": "disabled"}),
|
||||
"noise_seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff}),
|
||||
"steps": ("INT", {"default": 20, "min": 1, "max": 10000}),
|
||||
"start_at_step": ("INT", {"default": 0, "min": 0, "max": 10000}),
|
||||
"end_at_step": ("INT", {"default": 10000, "min": 0, "max": 10000}),
|
||||
"overlap_factor": ("INT", {"default": 10, "min": 0, "max": 10000}),
|
||||
"restore_latent": ("BOOLEAN", {"default": True, "label_on": "enabled", "label_off": "disabled"}),
|
||||
"return_with_leftover_noise": ("BOOLEAN", {"default": False, "label_on": "enabled", "label_off": "disabled"}),
|
||||
"latent_image": ("LATENT", ),
|
||||
"base_sampler": ("KSAMPLER_ADVANCED", ),
|
||||
"regional_prompts": ("REGIONAL_PROMPTS", ),
|
||||
"additional_mode": (["DISABLE", "ratio additional", "ratio between"], {"default": "ratio between"}),
|
||||
"additional_sampler": (["AUTO", "euler", "heun", "heunpp2", "dpm_2", "dpm_fast", "dpmpp_2m", "ddpm"],),
|
||||
"additional_sigma_ratio": ("FLOAT", {"default": 0.3, "min": 0.0, "max": 1.0, "step": 0.01}),
|
||||
"add_noise": ("BOOLEAN", {"default": True, "label_on": "enabled", "label_off": "disabled", "tooltip": "Whether to add noise"}),
|
||||
"noise_seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff, "tooltip": "Random seed to use for generating CPU noise for sampling."}),
|
||||
"steps": ("INT", {"default": 20, "min": 1, "max": 10000, "tooltip": "total sampling steps"}),
|
||||
"start_at_step": ("INT", {"default": 0, "min": 0, "max": 10000, "tooltip": "The starting step of the sampling to be applied at this node within the range of 'steps'."}),
|
||||
"end_at_step": ("INT", {"default": 10000, "min": 0, "max": 10000, "tooltip": "The step at which sampling applied at this node will stop within the range of steps (if greater than steps, sampling will continue only up to steps)."}),
|
||||
"overlap_factor": ("INT", {"default": 10, "min": 0, "max": 10000, "tooltip": "To smooth the seams of the region boundaries, expand the mask set in regional_prompts by the overlap_factor amount to overlap with other regions."}),
|
||||
"restore_latent": ("BOOLEAN", {"default": True, "label_on": "enabled", "label_off": "disabled", "tooltip": "At each step, restore the noise outside the mask area to its original state, as per the principle of inpainting. This option is provided for backward compatibility, and it is recommended to always set it to true."}),
|
||||
"return_with_leftover_noise": ("BOOLEAN", {"default": False, "label_on": "enabled", "label_off": "disabled", "tooltip": "Whether to return the latent with noise remaining if the noise has not been completely removed according to the noise schedule, or to completely remove the noise before returning it."}),
|
||||
"latent_image": ("LATENT", {"tooltip": "input latent image"}),
|
||||
"base_sampler": ("KSAMPLER_ADVANCED", {"tooltip": "The sampler applied outside the area set by the regional_prompt."}),
|
||||
"regional_prompts": ("REGIONAL_PROMPTS", {"tooltip": "The prompt applied to each region"}),
|
||||
"additional_mode": (["DISABLE", "ratio additional", "ratio between"], {"default": "ratio between", "tooltip": "..._sde or uni_pc and other special samplers are used, the region is not properly denoised, and it causes a phenomenon that destroys the overall harmony. To compensate for this, a recovery operation is performed using another sampler. This requires a longer time for sampling because a second sampling is performed at each step in each region using a special sampler. 1) DISABLE: Disable this feature. 2) ratio additional: After performing the denoise amount to be performed in the step with the sampler set in the region, the recovery sampler is additionally applied by the additional_sigma_ratio. If you use this option, the total denoise amount increases by additional_sigma_ratio. 3) ratio between: The denoise amount to be performed in the step with the sampler set in the region and the denoise amount to be applied to the recovery sampler are divided by additional_sigma_ratio, and denoise is performed for each denoise amount. If you use this option, the total denoise amount does not change."}),
|
||||
"additional_sampler": (["AUTO", "euler", "heun", "heunpp2", "dpm_2", "dpm_fast", "dpmpp_2m", "ddpm"], {"tooltip": "1) AUTO: Automatically set the recovery sampler. If the sampler is uni_pc, uni_pc_bh2, dpmpp_sde, dpmpp_sde_gpu, the dpm_fast sampler is selected If the sampler is dpmpp_2m_sde, dpmpp_2m_sde_gpu, dpmpp_3m_sde, dpmpp_3m_sde_gpu, the dpmpp_2m sampler is selected. 2) Others: Manually set the recovery sampler."}),
|
||||
"additional_sigma_ratio": ("FLOAT", {"default": 0.3, "min": 0.0, "max": 1.0, "step": 0.01, "tooltip": "Multiplier of noise schedule to be applied according to additional_mode."}),
|
||||
},
|
||||
"hidden": {"unique_id": "UNIQUE_ID"},
|
||||
}
|
||||
|
||||
TOOLTIPS = {
|
||||
"input": {
|
||||
"add_noise": "Whether to add noise",
|
||||
"noise_seed": "Random seed to use for generating CPU noise for sampling.",
|
||||
"steps": "total sampling steps",
|
||||
"start_at_step": "The starting step of the sampling to be applied at this node within the range of 'steps'.",
|
||||
"end_at_step": "The step at which sampling applied at this node will stop within the range of steps (if greater than steps, sampling will continue only up to steps).",
|
||||
"overlap_factor": "To smooth the seams of the region boundaries, expand the mask set in regional_prompts by the overlap_factor amount to overlap with other regions.",
|
||||
"restore_latent": "At each step, restore the noise outside the mask area to its original state, as per the principle of inpainting. This option is provided for backward compatibility, and it is recommended to always set it to true.",
|
||||
"return_with_leftover_noise": "Whether to return the latent with noise remaining if the noise has not been completely removed according to the noise schedule, or to completely remove the noise before returning it.",
|
||||
"latent_image": "input latent image",
|
||||
"base_sampler": "The sampler applied outside the area set by the regional_prompt.",
|
||||
"regional_prompts": "The prompt applied to each region",
|
||||
"additional_mode": "..._sde or uni_pc and other special samplers are used, the region is not properly denoised, and it causes a phenomenon that destroys the overall harmony. To compensate for this, a recovery operation is performed using another sampler. This requires a longer time for sampling because a second sampling is performed at each step in each region using a special sampler. 1) DISABLE: Disable this feature. 2) ratio additional: After performing the denoise amount to be performed in the step with the sampler set in the region, the recovery sampler is additionally applied by the additional_sigma_ratio. If you use this option, the total denoise amount increases by additional_sigma_ratio. 3) ratio between: The denoise amount to be performed in the step with the sampler set in the region and the denoise amount to be applied to the recovery sampler are divided by additional_sigma_ratio, and denoise is performed for each denoise amount. If you use this option, the total denoise amount does not change.",
|
||||
"additional_sampler": "1) AUTO: Automatically set the recovery sampler. If the sampler is uni_pc, uni_pc_bh2, dpmpp_sde, dpmpp_sde_gpu, the dpm_fast sampler is selected If the sampler is dpmpp_2m_sde, dpmpp_2m_sde_gpu, dpmpp_3m_sde, dpmpp_3m_sde_gpu, the dpmpp_2m sampler is selected. 2) Others: Manually set the recovery sampler.",
|
||||
"additional_sigma_ratio": "Multiplier of noise schedule to be applied according to additional_mode.",
|
||||
},
|
||||
"output": ("result latent", )
|
||||
}
|
||||
|
||||
OUTPUT_TOOLTIPS = ("result latent", )
|
||||
|
||||
RETURN_TYPES = ("LATENT", )
|
||||
FUNCTION = "doit"
|
||||
@@ -591,6 +480,9 @@ class RegionalSamplerAdvanced:
|
||||
def doit(add_noise, noise_seed, steps, start_at_step, end_at_step, overlap_factor, restore_latent, return_with_leftover_noise, latent_image, base_sampler, regional_prompts,
|
||||
additional_mode, additional_sampler, additional_sigma_ratio, unique_id):
|
||||
|
||||
new_latent_image = latent_image.copy()
|
||||
new_latent_image['samples'] = comfy.sample.fix_empty_latent_channels(base_sampler.params[0], new_latent_image['samples'])
|
||||
|
||||
if restore_latent:
|
||||
latent_compositor = nodes.NODE_CLASS_MAPPINGS['LatentCompositeMasked']()
|
||||
else:
|
||||
@@ -606,7 +498,6 @@ class RegionalSamplerAdvanced:
|
||||
end_at_step = min(steps, end_at_step)
|
||||
total = (end_at_step - start_at_step) * region_len
|
||||
|
||||
new_latent_image = latent_image.copy()
|
||||
base_latent_image = None
|
||||
region_masks = {}
|
||||
|
||||
@@ -681,35 +572,22 @@ class KSamplerBasicPipe:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {"required":
|
||||
{"basic_pipe": ("BASIC_PIPE",),
|
||||
"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": (core.SCHEDULERS, ),
|
||||
"latent_image": ("LATENT", ),
|
||||
"denoise": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}),
|
||||
{"basic_pipe": ("BASIC_PIPE", {"tooltip": "basic_pipe input for sampling"}),
|
||||
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff, "tooltip": "Random seed to use for generating CPU noise for sampling."}),
|
||||
"steps": ("INT", {"default": 20, "min": 1, "max": 10000, "tooltip": "total sampling steps"}),
|
||||
"cfg": ("FLOAT", {"default": 8.0, "min": 0.0, "max": 100.0, "tooltip": "classifier free guidance value"}),
|
||||
"sampler_name": (comfy.samplers.KSampler.SAMPLERS, {"tooltip": "sampler"}),
|
||||
"scheduler": (core.SCHEDULERS, {"tooltip": "noise schedule"}),
|
||||
"latent_image": ("LATENT", {"tooltip": "input latent image"}),
|
||||
"denoise": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01, "tooltip": "The amount of noise to remove. This amount is the noise added at the start, and the higher it is, the more the input latent will be modified before being returned."}),
|
||||
},
|
||||
"optional":
|
||||
{
|
||||
"scheduler_func_opt": ("SCHEDULER_FUNC", ),
|
||||
"scheduler_func_opt": ("SCHEDULER_FUNC", {"tooltip": "[OPTIONAL] Noise schedule generation function. If this is set, the scheduler widget will be ignored."}),
|
||||
}
|
||||
}
|
||||
|
||||
TOOLTIPS = {
|
||||
"input": {
|
||||
"basic_pipe": "basic_pipe input for sampling",
|
||||
"seed": "Random seed to use for generating CPU noise for sampling.",
|
||||
"steps": "total sampling steps",
|
||||
"cfg": "classifier free guidance value",
|
||||
"sampler_name": "sampler",
|
||||
"scheduler": "noise schedule",
|
||||
"latent_image": "input latent image",
|
||||
"denoise": "The amount of noise to remove. This amount is the noise added at the start, and the higher it is, the more the input latent will be modified before being returned.",
|
||||
"scheduler_func_opt": "[OPTIONAL] Noise schedule generation function. If this is set, the scheduler widget will be ignored.",
|
||||
},
|
||||
"output": ("passthrough input basic_pipe", "result latent", "VAE in basic_pipe")
|
||||
}
|
||||
OUTPUT_TOOLTIPS = ("passthrough input basic_pipe", "result latent", "VAE in basic_pipe")
|
||||
|
||||
RETURN_TYPES = ("BASIC_PIPE", "LATENT", "VAE")
|
||||
FUNCTION = "sample"
|
||||
@@ -727,41 +605,25 @@ class KSamplerAdvancedBasicPipe:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {"required":
|
||||
{"basic_pipe": ("BASIC_PIPE",),
|
||||
"add_noise": ("BOOLEAN", {"default": True, "label_on": "enable", "label_off": "disable"}),
|
||||
"noise_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": (core.SCHEDULERS, ),
|
||||
"latent_image": ("LATENT", ),
|
||||
"start_at_step": ("INT", {"default": 0, "min": 0, "max": 10000}),
|
||||
"end_at_step": ("INT", {"default": 10000, "min": 0, "max": 10000}),
|
||||
"return_with_leftover_noise": ("BOOLEAN", {"default": False, "label_on": "enable", "label_off": "disable"}),
|
||||
{"basic_pipe": ("BASIC_PIPE", {"tooltip": "basic_pipe input for sampling"}),
|
||||
"add_noise": ("BOOLEAN", {"default": True, "label_on": "enable", "label_off": "disable", "tooltip": "Whether to add noise"}),
|
||||
"noise_seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff, "tooltip": "Random seed to use for generating CPU noise for sampling."}),
|
||||
"steps": ("INT", {"default": 20, "min": 1, "max": 10000, "tooltip": "total sampling steps"}),
|
||||
"cfg": ("FLOAT", {"default": 8.0, "min": 0.0, "max": 100.0, "tooltip": "classifier free guidance value"}),
|
||||
"sampler_name": (comfy.samplers.KSampler.SAMPLERS, {"tooltip": "sampler"}),
|
||||
"scheduler": (core.SCHEDULERS, {"tooltip": "noise schedule"}),
|
||||
"latent_image": ("LATENT", {"tooltip": "input latent image"}),
|
||||
"start_at_step": ("INT", {"default": 0, "min": 0, "max": 10000, "tooltip": "The starting step of the sampling to be applied at this node within the range of 'steps'."}),
|
||||
"end_at_step": ("INT", {"default": 10000, "min": 0, "max": 10000, "tooltip": "The step at which sampling applied at this node will stop within the range of steps (if greater than steps, sampling will continue only up to steps)."}),
|
||||
"return_with_leftover_noise": ("BOOLEAN", {"default": False, "label_on": "enable", "label_off": "disable", "tooltip": "Whether to return the latent with noise remaining if the noise has not been completely removed according to the noise schedule, or to completely remove the noise before returning it."}),
|
||||
},
|
||||
"optional":
|
||||
{
|
||||
"scheduler_func_opt": ("SCHEDULER_FUNC", ),
|
||||
"scheduler_func_opt": ("SCHEDULER_FUNC", {"tooltip": "[OPTIONAL] Noise schedule generation function. If this is set, the scheduler widget will be ignored."}),
|
||||
}
|
||||
}
|
||||
|
||||
TOOLTIPS = {
|
||||
"input": {
|
||||
"basic_pipe": "basic_pipe input for sampling",
|
||||
"add_noise": "Whether to add noise",
|
||||
"noise_seed": "Random seed to use for generating CPU noise for sampling.",
|
||||
"steps": "total sampling steps",
|
||||
"cfg": "classifier free guidance value",
|
||||
"sampler_name": "sampler",
|
||||
"scheduler": "noise schedule",
|
||||
"latent_image": "input latent image",
|
||||
"start_at_step": "The starting step of the sampling to be applied at this node within the range of 'steps'.",
|
||||
"end_at_step": "The step at which sampling applied at this node will stop within the range of steps (if greater than steps, sampling will continue only up to steps).",
|
||||
"return_with_leftover_noise": "Whether to return the latent with noise remaining if the noise has not been completely removed according to the noise schedule, or to completely remove the noise before returning it.",
|
||||
"scheduler_func_opt": "[OPTIONAL] Noise schedule generation function. If this is set, the scheduler widget will be ignored.",
|
||||
},
|
||||
"output": ("passthrough input basic_pipe", "result latent", "VAE in basic_pipe")
|
||||
}
|
||||
OUTPUT_TOOLTIPS = ("passthrough input basic_pipe", "result latent", "VAE in basic_pipe")
|
||||
|
||||
RETURN_TYPES = ("BASIC_PIPE", "LATENT", "VAE")
|
||||
FUNCTION = "sample"
|
||||
@@ -780,18 +642,12 @@ class GITSSchedulerFuncProvider:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {"required": {
|
||||
"coeff": ("FLOAT", {"default": 1.20, "min": 0.80, "max": 1.50, "step": 0.05}),
|
||||
"denoise": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}),
|
||||
"coeff": ("FLOAT", {"default": 1.20, "min": 0.80, "max": 1.50, "step": 0.05, "tooltip": "coeff factor of GITS Scheduler"}),
|
||||
"denoise": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01, "tooltip": "denoise amount for noise schedule"}),
|
||||
}
|
||||
}
|
||||
|
||||
TOOLTIPS = {
|
||||
"input": {
|
||||
"coeff": "coeff factor of GITS Scheduler",
|
||||
"denoise": "denoise amount for noise schedule",
|
||||
},
|
||||
"output": ("Returns a function that generates a noise schedule using GITSScheduler. This can be used in place of a predetermined noise schedule to dynamically generate a noise schedule based on the steps.",)
|
||||
}
|
||||
OUTPUT_TOOLTIPS = ("Returns a function that generates a noise schedule using GITSScheduler. This can be used in place of a predetermined noise schedule to dynamically generate a noise schedule based on the steps.",)
|
||||
|
||||
RETURN_TYPES = ("SCHEDULER_FUNC",)
|
||||
CATEGORY = "ImpactPack/sampling"
|
||||
@@ -815,9 +671,7 @@ class NegativeConditioningPlaceholder:
|
||||
def INPUT_TYPES(s):
|
||||
return {"required": {}}
|
||||
|
||||
TOOLTIPS = {
|
||||
"output": ("This is a Placeholder for the FLUX model that does not use Negative Conditioning.",)
|
||||
}
|
||||
OUTPUT_TOOLTIPS = ("This is a Placeholder for the FLUX model that does not use Negative Conditioning.",)
|
||||
|
||||
RETURN_TYPES = ("CONDITIONING",)
|
||||
CATEGORY = "ImpactPack/sampling"
|
||||
|
||||
+100
-15
@@ -6,29 +6,49 @@ import comfy
|
||||
import sys
|
||||
import nodes
|
||||
import re
|
||||
import impact.core as core
|
||||
from server import PromptServer
|
||||
import inspect
|
||||
|
||||
|
||||
class GeneralSwitch:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {"required": {
|
||||
"select": ("INT", {"default": 1, "min": 1, "max": 999999, "step": 1}),
|
||||
"sel_mode": ("BOOLEAN", {"default": True, "label_on": "select_on_prompt", "label_off": "select_on_execution", "forceInput": False}),
|
||||
},
|
||||
"optional": {
|
||||
"input1": (any_typ,),
|
||||
dyn_inputs = {"input1": (any_typ, {"lazy": True, "tooltip": "Any input. When connected, one more input slot is added."}), }
|
||||
if core.is_execution_model_version_supported():
|
||||
stack = inspect.stack()
|
||||
if stack[2].function == 'get_input_info' and stack[3].function == 'add_node':
|
||||
for x in range(2, 200):
|
||||
dyn_inputs[f"input{x}"] = (any_typ, {"lazy": True})
|
||||
|
||||
inputs = {"required": {
|
||||
"select": ("INT", {"default": 1, "min": 1, "max": 999999, "step": 1, "tooltip": "The input number you want to output among the inputs"}),
|
||||
"sel_mode": ("BOOLEAN", {"default": False, "label_on": "select_on_prompt", "label_off": "select_on_execution", "forceInput": False,
|
||||
"tooltip": "In the case of 'select_on_execution', the selection is dynamically determined at the time of workflow execution. 'select_on_prompt' is an option that exists for older versions of ComfyUI, and it makes the decision before the workflow execution."}),
|
||||
},
|
||||
"optional": dyn_inputs,
|
||||
"hidden": {"unique_id": "UNIQUE_ID", "extra_pnginfo": "EXTRA_PNGINFO"}
|
||||
}
|
||||
|
||||
return inputs
|
||||
|
||||
RETURN_TYPES = (any_typ, "STRING", "INT")
|
||||
RETURN_NAMES = ("selected_value", "selected_label", "selected_index")
|
||||
OUTPUT_TOOLTIPS = ("Output is generated only from the input chosen by the 'select' value.", "Slot label of the selected input slot", "Outputs the select value as is")
|
||||
FUNCTION = "doit"
|
||||
|
||||
CATEGORY = "ImpactPack/Util"
|
||||
|
||||
def doit(self, *args, **kwargs):
|
||||
def check_lazy_status(self, *args, **kwargs):
|
||||
selected_index = int(kwargs['select'])
|
||||
input_name = f"input{selected_index}"
|
||||
|
||||
print(f"SELECTED: {input_name}")
|
||||
|
||||
return [input_name]
|
||||
|
||||
@staticmethod
|
||||
def doit(*args, **kwargs):
|
||||
selected_index = int(kwargs['select'])
|
||||
input_name = f"input{selected_index}"
|
||||
|
||||
@@ -50,11 +70,10 @@ class GeneralSwitch:
|
||||
print(f"[Impact-Pack] The switch node does not guarantee proper functioning in API mode.")
|
||||
|
||||
if input_name in kwargs:
|
||||
return (kwargs[input_name], selected_label, selected_index)
|
||||
return kwargs[input_name], selected_label, selected_index
|
||||
else:
|
||||
print(f"ImpactSwitch: invalid select index (ignored)")
|
||||
return (None, "", selected_index)
|
||||
|
||||
return None, "", selected_index
|
||||
|
||||
class LatentSwitch:
|
||||
@classmethod
|
||||
@@ -126,23 +145,44 @@ class GeneralInversedSwitch:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {"required": {
|
||||
"select": ("INT", {"default": 1, "min": 1, "max": 999999, "step": 1}),
|
||||
"input": (any_typ,),
|
||||
"select": ("INT", {"default": 1, "min": 1, "max": 999999, "step": 1, "tooltip": "The output number you want to send from the input"}),
|
||||
"input": (any_typ, {"tooltip": "Any input. When connected, one more input slot is added."}),
|
||||
|
||||
},
|
||||
"hidden": {"unique_id": "UNIQUE_ID"},
|
||||
"optional": {
|
||||
"sel_mode": ("BOOLEAN", {"default": False, "label_on": "select_on_prompt", "label_off": "select_on_execution", "forceInput": False,
|
||||
"tooltip": "In the case of 'select_on_execution', the selection is dynamically determined at the time of workflow execution. 'select_on_prompt' is an option that exists for older versions of ComfyUI, and it makes the decision before the workflow execution."}),
|
||||
},
|
||||
"hidden": {"prompt": "PROMPT", "unique_id": "UNIQUE_ID"},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ByPassTypeTuple((any_typ, ))
|
||||
OUTPUT_TOOLTIPS = ("Output occurs only from the output selected by the 'select' value.\nWhen slots are connected, additional slots are created.", )
|
||||
FUNCTION = "doit"
|
||||
|
||||
CATEGORY = "ImpactPack/Util"
|
||||
|
||||
def doit(self, select, input, unique_id):
|
||||
def doit(self, select, prompt, unique_id, input, **kwargs):
|
||||
if core.is_execution_model_version_supported:
|
||||
from comfy_execution.graph import ExecutionBlocker
|
||||
else:
|
||||
print("[Impact Pack] InversedSwitch: ComfyUI is outdated. The 'select_on_execution' mode cannot function properly.")
|
||||
|
||||
res = []
|
||||
|
||||
for i in range(0, select):
|
||||
# search max output count in prompt
|
||||
cnt = 0
|
||||
for x in prompt.values():
|
||||
for y in x.get('inputs', {}).values():
|
||||
if isinstance(y, list) and len(y) == 2:
|
||||
if y[0] == unique_id:
|
||||
cnt = max(cnt, y[1])
|
||||
|
||||
for i in range(0, cnt + 1):
|
||||
if select == i+1:
|
||||
res.append(input)
|
||||
elif core.is_execution_model_version_supported:
|
||||
res.append(ExecutionBlocker(None))
|
||||
else:
|
||||
res.append(None)
|
||||
|
||||
@@ -352,6 +392,26 @@ class ImageBatchToImageList:
|
||||
return (images, )
|
||||
|
||||
|
||||
class MakeMaskList:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {"required": {"mask1": ("MASK",), }}
|
||||
|
||||
RETURN_TYPES = ("MASK",)
|
||||
OUTPUT_IS_LIST = (True,)
|
||||
FUNCTION = "doit"
|
||||
|
||||
CATEGORY = "ImpactPack/Util"
|
||||
|
||||
def doit(self, **kwargs):
|
||||
masks = []
|
||||
|
||||
for k, v in kwargs.items():
|
||||
masks.append(v)
|
||||
|
||||
return (masks, )
|
||||
|
||||
|
||||
class MakeImageList:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
@@ -397,6 +457,31 @@ class MakeImageBatch:
|
||||
return (image1,)
|
||||
|
||||
|
||||
class MakeMaskBatch:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {"required": {"mask1": ("MASK",), }}
|
||||
|
||||
RETURN_TYPES = ("MASK",)
|
||||
FUNCTION = "doit"
|
||||
|
||||
CATEGORY = "ImpactPack/Util"
|
||||
|
||||
def doit(self, **kwargs):
|
||||
mask1 = kwargs['mask1']
|
||||
del kwargs['mask1']
|
||||
masks = [utils.make_3d_mask(value) for value in kwargs.values()]
|
||||
|
||||
if len(masks) == 0:
|
||||
return (mask1,)
|
||||
else:
|
||||
for mask2 in masks:
|
||||
if mask1.shape[1:] != mask2.shape[1:]:
|
||||
mask2 = comfy.utils.common_upscale(mask2.movedim(-1, 1), mask1.shape[2], mask1.shape[1], "lanczos", "center").movedim(1, -1)
|
||||
mask1 = torch.cat((mask1, mask2), dim=0)
|
||||
return (mask1,)
|
||||
|
||||
|
||||
class ReencodeLatent:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
|
||||
+21
-3
@@ -5,8 +5,7 @@ import numpy as np
|
||||
import folder_paths
|
||||
import nodes
|
||||
from . import config
|
||||
from PIL import Image, ImageFilter
|
||||
from scipy.ndimage import zoom
|
||||
from PIL import Image
|
||||
import comfy
|
||||
|
||||
|
||||
@@ -537,6 +536,16 @@ def make_3d_mask(mask):
|
||||
return mask
|
||||
|
||||
|
||||
def make_4d_mask(mask):
|
||||
if len(mask.shape) == 3:
|
||||
return mask.unsqueeze(0)
|
||||
|
||||
elif len(mask.shape) == 2:
|
||||
return mask.unsqueeze(0).unsqueeze(0)
|
||||
|
||||
return mask
|
||||
|
||||
|
||||
def is_same_device(a, b):
|
||||
a_device = torch.device(a) if isinstance(a, str) else a
|
||||
b_device = torch.device(b) if isinstance(b, str) else b
|
||||
@@ -556,7 +565,8 @@ from torchvision.transforms.functional import to_pil_image
|
||||
|
||||
|
||||
def resize_mask(mask, size):
|
||||
resized_mask = torch.nn.functional.interpolate(mask.unsqueeze(0), size=size, mode='bilinear', align_corners=False)
|
||||
mask = make_4d_mask(mask)
|
||||
resized_mask = torch.nn.functional.interpolate(mask, size=size, mode='bilinear', align_corners=False)
|
||||
return resized_mask.squeeze(0)
|
||||
|
||||
|
||||
@@ -568,6 +578,14 @@ def apply_mask_alpha_to_pil(decoded_pil, mask):
|
||||
return decoded_rgba
|
||||
|
||||
|
||||
def flatten_mask(all_masks):
|
||||
merged_mask = (all_masks[0] * 255).to(torch.uint8)
|
||||
for mask in all_masks[1:]:
|
||||
merged_mask |= (mask * 255).to(torch.uint8)
|
||||
|
||||
return merged_mask
|
||||
|
||||
|
||||
def try_install_custom_node(custom_node_url, msg):
|
||||
try:
|
||||
import cm_global
|
||||
|
||||
+18
-15
@@ -12,7 +12,7 @@ from impact import config
|
||||
|
||||
wildcards_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "wildcards"))
|
||||
|
||||
RE_WildCardQuantifier = re.compile(r"(?P<quantifier>\d+)#__(?P<keyword>[\w.\-+/*\\]+)__", re.IGNORECASE)
|
||||
RE_WildCardQuantifier = re.compile(r"(?P<quantifier>\d+)#__(?P<keyword>[\w.\-+/*\\]+?)__", re.IGNORECASE)
|
||||
wildcard_lock = threading.Lock()
|
||||
wildcard_dict = {}
|
||||
|
||||
@@ -121,7 +121,7 @@ def process(text, seed=None):
|
||||
select_sep = ' '
|
||||
range_pattern = r'(\d+)(-(\d+))?'
|
||||
range_pattern2 = r'-(\d+)'
|
||||
wildcard_pattern = r"__([\w.\-+/*\\]+)__"
|
||||
wildcard_pattern = r"__([\w.\-+/*\\]+?)__"
|
||||
|
||||
if len(multi_select_pattern) > 1:
|
||||
r = re.match(range_pattern, options[0])
|
||||
@@ -200,7 +200,7 @@ def process(text, seed=None):
|
||||
return replaced_string, replacements_found
|
||||
|
||||
def replace_wildcard(string):
|
||||
pattern = r"__([\w.\-+/*\\]+)__"
|
||||
pattern = r"__([\w.\-+/*\\]+?)__"
|
||||
matches = re.findall(pattern, string)
|
||||
|
||||
replacements_found = False
|
||||
@@ -425,7 +425,7 @@ def process_with_loras(wildcard_opt, model, clip, clip_encoder=None, seed=None,
|
||||
|
||||
def starts_with_regex(pattern, text):
|
||||
regex = re.compile(pattern)
|
||||
return bool(regex.match(text))
|
||||
return regex.match(text)
|
||||
|
||||
|
||||
def split_to_dict(text):
|
||||
@@ -507,18 +507,21 @@ def process_wildcard_for_segs(wildcard):
|
||||
|
||||
return 'LAB', WildcardChooserDict(items)
|
||||
|
||||
elif starts_with_regex(r"\[(ASC|DSC|RND)\]", wildcard):
|
||||
mode = wildcard[1:4]
|
||||
items = split_string_with_sep(wildcard[5:])
|
||||
|
||||
if mode == 'RND':
|
||||
random.shuffle(items)
|
||||
return mode, WildcardChooser(items, True)
|
||||
else:
|
||||
return mode, WildcardChooser(items, False)
|
||||
|
||||
else:
|
||||
return None, WildcardChooser([(None, wildcard)], False)
|
||||
match = starts_with_regex(r"\[(ASC-SIZE|DSC-SIZE|ASC|DSC|RND)\]", wildcard)
|
||||
|
||||
if match:
|
||||
mode = match[1]
|
||||
items = split_string_with_sep(wildcard[len(match[0]):])
|
||||
|
||||
if mode == 'RND':
|
||||
random.shuffle(items)
|
||||
return mode, WildcardChooser(items, True)
|
||||
else:
|
||||
return mode, WildcardChooser(items, False)
|
||||
|
||||
else:
|
||||
return None, WildcardChooser([(None, wildcard)], False)
|
||||
|
||||
|
||||
def wildcard_load():
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
[project]
|
||||
name = "comfyui-impact-pack"
|
||||
description = "This extension offers various detector nodes and detailer nodes that allow you to configure a workflow that automatically enhances facial details. And provide iterative upscaler."
|
||||
version = "6.0.3"
|
||||
version = "7.6.2"
|
||||
license = { file = "LICENSE.txt" }
|
||||
dependencies = ["segment-anything", "scikit-image", "piexif", "transformers", "opencv-python-headless", "GitPython", "scipy>=1.11.4"]
|
||||
|
||||
|
||||
@@ -6,3 +6,5 @@ opencv-python-headless
|
||||
GitPython
|
||||
scipy>=1.11.4
|
||||
numpy<2
|
||||
dill
|
||||
matplotlib
|
||||
Reference in New Issue
Block a user