mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-01-11 23:00:51 +08:00
Merge f39c9caa55 into 5943fbf457
This commit is contained in:
commit
1009ebb5cd
@ -1113,6 +1113,18 @@ class DynamicSlot(ComfyTypeI):
|
|||||||
out_dict[input_type][finalized_id] = value
|
out_dict[input_type][finalized_id] = value
|
||||||
out_dict["dynamic_paths"][finalized_id] = finalize_prefix(curr_prefix, curr_prefix[-1])
|
out_dict["dynamic_paths"][finalized_id] = finalize_prefix(curr_prefix, curr_prefix[-1])
|
||||||
|
|
||||||
|
@comfytype(io_type="IMAGECOMPARE")
|
||||||
|
class ImageCompare(ComfyTypeI):
|
||||||
|
Type = dict
|
||||||
|
|
||||||
|
class Input(WidgetInput):
|
||||||
|
def __init__(self, id: str, display_name: str=None, optional=False, tooltip: str=None,
|
||||||
|
socketless: bool=True):
|
||||||
|
super().__init__(id, display_name, optional, tooltip, None, None, socketless)
|
||||||
|
|
||||||
|
def as_dict(self):
|
||||||
|
return super().as_dict()
|
||||||
|
|
||||||
DYNAMIC_INPUT_LOOKUP: dict[str, Callable[[dict[str, Any], dict[str, Any], tuple[str, dict[str, Any]], str, list[str] | None], None]] = {}
|
DYNAMIC_INPUT_LOOKUP: dict[str, Callable[[dict[str, Any], dict[str, Any], tuple[str, dict[str, Any]], str, list[str] | None], None]] = {}
|
||||||
def register_dynamic_input_func(io_type: str, func: Callable[[dict[str, Any], dict[str, Any], tuple[str, dict[str, Any]], str, list[str] | None], None]):
|
def register_dynamic_input_func(io_type: str, func: Callable[[dict[str, Any], dict[str, Any], tuple[str, dict[str, Any]], str, list[str] | None], None]):
|
||||||
DYNAMIC_INPUT_LOOKUP[io_type] = func
|
DYNAMIC_INPUT_LOOKUP[io_type] = func
|
||||||
@ -1958,4 +1970,5 @@ __all__ = [
|
|||||||
"add_to_dict_v1",
|
"add_to_dict_v1",
|
||||||
"add_to_dict_v3",
|
"add_to_dict_v3",
|
||||||
"V3Data",
|
"V3Data",
|
||||||
|
"ImageCompare",
|
||||||
]
|
]
|
||||||
|
|||||||
53
comfy_extras/nodes_image_compare.py
Normal file
53
comfy_extras/nodes_image_compare.py
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
import nodes
|
||||||
|
|
||||||
|
from typing_extensions import override
|
||||||
|
from comfy_api.latest import IO, ComfyExtension
|
||||||
|
|
||||||
|
|
||||||
|
class ImageCompare(IO.ComfyNode):
|
||||||
|
"""Compares two images with a slider interface."""
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def define_schema(cls):
|
||||||
|
return IO.Schema(
|
||||||
|
node_id="ImageCompare",
|
||||||
|
display_name="Image Compare",
|
||||||
|
description="Compares two images side by side with a slider.",
|
||||||
|
category="image",
|
||||||
|
is_experimental=True,
|
||||||
|
is_output_node=True,
|
||||||
|
inputs=[
|
||||||
|
IO.Image.Input("image_a", optional=True),
|
||||||
|
IO.Image.Input("image_b", optional=True),
|
||||||
|
IO.ImageCompare.Input("compare_view"),
|
||||||
|
],
|
||||||
|
outputs=[],
|
||||||
|
)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def execute(cls, image_a=None, image_b=None, compare_view=None) -> IO.NodeOutput:
|
||||||
|
result = {"a_images": [], "b_images": []}
|
||||||
|
|
||||||
|
preview_node = nodes.PreviewImage()
|
||||||
|
|
||||||
|
if image_a is not None and len(image_a) > 0:
|
||||||
|
saved = preview_node.save_images(image_a, "comfy.compare.a")
|
||||||
|
result["a_images"] = saved["ui"]["images"]
|
||||||
|
|
||||||
|
if image_b is not None and len(image_b) > 0:
|
||||||
|
saved = preview_node.save_images(image_b, "comfy.compare.b")
|
||||||
|
result["b_images"] = saved["ui"]["images"]
|
||||||
|
|
||||||
|
return IO.NodeOutput(ui=result)
|
||||||
|
|
||||||
|
|
||||||
|
class ImageCompareExtension(ComfyExtension):
|
||||||
|
@override
|
||||||
|
async def get_node_list(self) -> list[type[IO.ComfyNode]]:
|
||||||
|
return [
|
||||||
|
ImageCompare,
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
async def comfy_entrypoint() -> ImageCompareExtension:
|
||||||
|
return ImageCompareExtension()
|
||||||
Loading…
Reference in New Issue
Block a user