MCPcopy Create free account
hub / github.com/WainWong/ComfyUI-Loop-image / SingleImageLoopOpen

Class SingleImageLoopOpen

flow_control.py:339–381  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

337
338@VariantSupport()
339class SingleImageLoopOpen:
340 def __init__(self):
341 pass
342
343 @classmethod
344 def INPUT_TYPES(cls):
345 inputs = {
346 "required": {
347 "image": ("IMAGE",),
348 "max_iterations": ("INT", {"default": 5, "min": 1, "max": 100}),
349 },
350 "optional": {
351 "mask": ("MASK",),
352 },
353 "hidden": {
354 "unique_id": "UNIQUE_ID",
355 "iteration_count": ("INT", {"default": 0}),
356 "previous_image": ("IMAGE",),
357 "previous_mask": ("MASK",),
358 }
359 }
360 return inputs
361
362 RETURN_TYPES = tuple(["FLOW_CONTROL", "IMAGE", "MASK", "INT", "INT"])
363 RETURN_NAMES = tuple(["FLOW_CONTROL", "current_image", "current_mask", "max_iterations", "iteration_count"])
364 FUNCTION = "loop_open"
365 CATEGORY = "CyberEveLoop🐰"
366
367 def loop_open(self, image, max_iterations, mask=None, unique_id=None,
368 iteration_count=0, previous_image=None, previous_mask=None):
369 print(f"SingleImageLoopOpen Processing iteration {iteration_count}")
370
371 # 确保维度正确
372 if len(image.shape) == 3:
373 image = image.unsqueeze(0)
374 if mask is not None and len(mask.shape) == 2:
375 mask = mask.unsqueeze(0)
376
377 # 使用上一次循环的结果(如果有)
378 current_image = previous_image if previous_image is not None and iteration_count > 0 else image
379 current_mask = previous_mask if previous_mask is not None and iteration_count > 0 else mask
380
381 return tuple(["stub", current_image, current_mask, max_iterations, iteration_count])
382
383@VariantSupport()
384class SingleImageLoopClose:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected