Five things surfaced by release testing. Node search: ComfyUI's search dialog cuts at 64 results and ranks by [match tier, global popularity, name length], where tier 1 needs the name to START with what was typed. Popularity is a fixed global table in which every node from a new pack scores zero, so tier is the only lever. As "Refine Mask" this node came 121st for "mask" and was never on screen. Renamed to Mask Refine, which is 15th, and kept "refine mask" as an alias. The mapping key is untouched, so saved workflows are unaffected. Aliases alone cannot fix this: the frontend indexes them but drops them from the tier scoring because they are a list rather than a string, so they decide whether a node is findable, not where it lands. Previews: Mask Refine, LaMa Inpaint and Select Frame showed whatever fed their input, which is nothing when a segmentation node is upstream - Mask Refine's panel was blank however the mask turned out. Each now returns its result as a preview and the panel shows that, falling back to the input before the first run. A node does not need to be an OUTPUT_NODE for this; returning a ui payload is enough. ComfyUI's own preview for these nodes is stood down so the picture appears once, in the panel, rather than also underneath the node. That also fixes LaMa finishing a single image with an empty panel: frame previews were only attached for batches over one frame, on the assumption that one image would preview through the output path, which a non-output node does not have. Mask Refine opens on expand and blur with the other five behind MORE. Hidden widgets keep their values and their saved positions. AUTO sets both from the mask's size, scaled off the 8/4 hand-tuned for the watermark workflow at 576px, because a feather is a fraction of the picture rather than a fixed pixel count. Save Video gains nvenc h264/h265, webm av1, ProRes mov, lossless ffv1 mkv, gif and webp, plus pingpong and save_metadata. Every format is encoded and read back in the tests rather than trusted from its table row. fps steps in whole frames but stays FLOAT: an INT would refuse Load Video's fps link and round 29.97 to 30, drifting picture off audio. mov files now carry the embedded workflow, which they silently did not. The reload button is gone - it only re-fetched what was already on screen. Not done: Select Frame's preview updates on a run, not as the number changes. Seeking to a frame needs the source fps, which the browser never learns, so live scrubbing needs a server route - the surface Frame Chooser was just demoted for.
75 lines
2.7 KiB
Python
75 lines
2.7 KiB
Python
from __future__ import annotations
|
|
|
|
import sys
|
|
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
from unittest.mock import patch
|
|
|
|
import torch
|
|
from PIL import Image
|
|
|
|
ROOT = Path(__file__).resolve().parent.parent
|
|
sys.path.insert(0, str(ROOT))
|
|
if "nodes" in sys.modules and not hasattr(sys.modules["nodes"], "__path__"):
|
|
del sys.modules["nodes"]
|
|
|
|
from nodes import _preview_helpers
|
|
from nodes.node_compare import AusBossCompare, first_frame_to_pil
|
|
|
|
|
|
def fake_folder_paths(temp_dir: str):
|
|
class FakeFolderPaths:
|
|
@staticmethod
|
|
def get_temp_directory():
|
|
return temp_dir
|
|
|
|
@staticmethod
|
|
def get_save_image_path(prefix, output_dir, _width, _height):
|
|
folder = Path(output_dir) / "ausboss"
|
|
folder.mkdir(parents=True, exist_ok=True)
|
|
return str(folder), prefix, 1, "ausboss", prefix
|
|
|
|
return FakeFolderPaths
|
|
|
|
|
|
class CompareNodeTests(unittest.TestCase):
|
|
def test_first_frame_conversion_and_validation(self):
|
|
batch = torch.zeros(3, 4, 6, 3)
|
|
batch[0, :, :, 0] = 1.0 # first frame is pure red
|
|
preview = first_frame_to_pil(batch)
|
|
self.assertEqual((preview.width, preview.height), (6, 4))
|
|
self.assertEqual(preview.getpixel((0, 0)), (255, 0, 0))
|
|
with self.assertRaisesRegex(ValueError, "BHWC"):
|
|
first_frame_to_pil(torch.zeros(4, 6, 3))
|
|
with self.assertRaisesRegex(ValueError, "empty"):
|
|
first_frame_to_pil(torch.zeros(0, 4, 6, 3))
|
|
|
|
def test_compare_saves_temp_previews_and_passes_a_through(self):
|
|
image_a = torch.rand(2, 8, 12, 3)
|
|
image_b = torch.rand(1, 8, 12, 3)
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
# folder_paths is imported by the shared preview helper now, which
|
|
# is where every node's temp preview is written.
|
|
with patch.object(_preview_helpers, "folder_paths", fake_folder_paths(tmp)):
|
|
result = AusBossCompare().compare(image_a, image_b)
|
|
|
|
self.assertIs(result["result"][0], image_a)
|
|
for key in ("a_images", "b_images"):
|
|
(ref,) = result["ui"][key]
|
|
self.assertEqual(ref["type"], "temp")
|
|
self.assertEqual(ref["subfolder"], "ausboss")
|
|
self.assertEqual((ref["width"], ref["height"]), (12, 8))
|
|
saved = Path(tmp) / "ausboss" / ref["filename"]
|
|
with Image.open(saved) as png:
|
|
self.assertEqual(png.size, (12, 8))
|
|
|
|
def test_two_nodes_use_distinct_temp_prefixes(self):
|
|
# Prefixes are randomized per instance so parallel Compare nodes
|
|
# never overwrite each other's previews.
|
|
self.assertNotEqual(AusBossCompare()._prefix, AusBossCompare()._prefix)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|