From 39fb4db4868dc94db120c44b63350a13bfdd7f64 Mon Sep 17 00:00:00 2001 From: robertvoy Date: Thu, 11 Sep 2025 14:25:57 +1000 Subject: [PATCH] warning for non-WAN compatible frame count and WanVideo Closest Frame Count --- __init__.py | 12 +++++++++--- distributed_upscale.py | 16 +++++++++++++++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/__init__.py b/__init__.py index 18d9765..5c8a98d 100644 --- a/__init__.py +++ b/__init__.py @@ -50,16 +50,22 @@ from .distributed_upscale import ( NODE_DISPLAY_NAME_MAPPINGS as UPSCALE_DISPLAY_NAME_MAPPINGS ) +# Import WAN helpers +from .wan_helpers import ( + NODE_CLASS_MAPPINGS as WAN_HELPERS_CLASS_MAPPINGS, + NODE_DISPLAY_NAME_MAPPINGS as WAN_HELPERS_DISPLAY_NAME_MAPPINGS, +) + WEB_DIRECTORY = "./web" ensure_config_exists() # Merge node mappings -NODE_CLASS_MAPPINGS = {**DISTRIBUTED_CLASS_MAPPINGS, **UPSCALE_CLASS_MAPPINGS} -NODE_DISPLAY_NAME_MAPPINGS = {**DISTRIBUTED_DISPLAY_NAME_MAPPINGS, **UPSCALE_DISPLAY_NAME_MAPPINGS} +NODE_CLASS_MAPPINGS = {**DISTRIBUTED_CLASS_MAPPINGS, **UPSCALE_CLASS_MAPPINGS, **WAN_HELPERS_CLASS_MAPPINGS} +NODE_DISPLAY_NAME_MAPPINGS = {**DISTRIBUTED_DISPLAY_NAME_MAPPINGS, **UPSCALE_DISPLAY_NAME_MAPPINGS, **WAN_HELPERS_DISPLAY_NAME_MAPPINGS} __all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS'] debug_log("Loaded Distributed nodes.") debug_log(f"Config file: {CONFIG_FILE}") -debug_log(f"Available nodes: {list(NODE_CLASS_MAPPINGS.keys())}") \ No newline at end of file +debug_log(f"Available nodes: {list(NODE_CLASS_MAPPINGS.keys())}") diff --git a/distributed_upscale.py b/distributed_upscale.py index 34538c2..8f9c6a8 100644 --- a/distributed_upscale.py +++ b/distributed_upscale.py @@ -83,12 +83,14 @@ class UltimateSDUpscaleDistributed: Threshold: dynamic_threshold input controls mode switch (default 8) """ - + def __init__(self): """Initialize the node and ensure persistent storage exists.""" # Pre-initialize the persistent storage on node creation ensure_tile_jobs_initialized() debug_log("UltimateSDUpscaleDistributed - Node initialized") + + # WAN/FLOW detection removed per user request; enforcing 4n+1 for any batch > 1. @classmethod def INPUT_TYPES(s): @@ -139,6 +141,18 @@ class UltimateSDUpscaleDistributed: multi_job_id="", is_worker=False, master_url="", enabled_worker_ids="[]", worker_id="", tile_indices="", dynamic_threshold=8): """Entry point - runs SYNCHRONOUSLY like Ultimate SD Upscaler.""" + # Strict WAN/FLOW batching: error if batch is not 4n+1 (except allow 1) + try: + batch_size = int(getattr(upscaled_image, 'shape', [1])[0]) + except Exception: + batch_size = 1 + # Enforce 4n+1 batches globally for any model when batch > 1 (master only) + if not is_worker and batch_size != 1 and (batch_size % 4 != 1): + raise ValueError( + f"Batch size {batch_size} is not of the form 4n+1. " + "This node requires batch sizes of 1 or 4n+1 (1, 5, 9, 13, ...). " + "Please adjust the batch size." + ) if not multi_job_id: # No distributed processing, run single GPU version return self.process_single_gpu(upscaled_image, model, positive, negative, vae,