Sub-packages: - edge/ — Canny, Lineart, LineartAnime (3 nodes) - restore/ — SCUNet, NAFNet, Adversarial (3 nodes) - compare/ — CCIP, LPIPS (2 nodes) - validate/ — Classify (11 ops), Check (5 ops), Metric (2 ops) - tagging/ — WD14, DeepDanbooru, DeepGelbooru, MLDanbooru, Camie, PixAI (6 nodes) Root nodes: - ImgUtilsOCR — PaddleOCR with heat/box threshold - ImgUtilsDetect — 10 detection types + confidence knob - ImgUtilsPose — DWPose + auto_detect toggle - ImgUtilsSegment — isnetis + scale knob - ImgUtilsTags — tag string processing - ImgUtilsCDC — upscaling + tile_size - ImgUtilsCensor — NSFW censoring with method/confidence/body-part toggles - ImgUtilsAlign — resize to max dimension - ImgUtilsSqueeze — transparency-based auto-crop Every node exposes its native function parameters as knobs. Removed mega-nodes: transform (11 ops), compare (3 ops), validate (18 ops).
29 lines
1.3 KiB
Python
29 lines
1.3 KiB
Python
"""Node: ImgUtilsLPIPS — LPIPS perceptual similarity."""
|
|
from __future__ import annotations
|
|
from comfy_api.latest import io
|
|
from ..utils import comfy_to_pil
|
|
|
|
class ImgUtilsLPIPS(io.ComfyNode):
|
|
@classmethod
|
|
def define_schema(cls) -> io.Schema:
|
|
return io.Schema(
|
|
node_id="ImgUtilsLPIPS", display_name="Imgutils Compare (LPIPS)",
|
|
category="imgutils/compare",
|
|
description="Compute LPIPS perceptual similarity between two images. Score < 0.45 = similar.",
|
|
search_aliases=["compare", "lpips", "perceptual", "similarity", "distance"],
|
|
inputs=[
|
|
io.Image.Input("image_a", tooltip="First image"),
|
|
io.Image.Input("image_b", tooltip="Second image"),
|
|
],
|
|
outputs=[io.String.Output(display_name="text")],
|
|
)
|
|
|
|
@classmethod
|
|
def execute(cls, image_a, image_b) -> io.NodeOutput:
|
|
from imgutils.metrics import lpips_difference
|
|
pil_a = comfy_to_pil(image_a.numpy() if hasattr(image_a, "numpy") else image_a)
|
|
pil_b = comfy_to_pil(image_b.numpy() if hasattr(image_b, "numpy") else image_b)
|
|
result = lpips_difference(pil_a, pil_b)
|
|
similar = result < 0.45
|
|
return io.NodeOutput(f"LPIPS: {result:.4f} ({'similar' if similar else 'different'}, threshold=0.45)")
|