Add images passthrough output to VFI Optimizer
Avoids needing a dual link from the image source — the optimizer passes images through so they can be connected directly to the Interpolate node. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
16
nodes.py
16
nodes.py
@@ -747,14 +747,14 @@ class VFIOptimizer:
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
RETURN_TYPES = ("VFI_SETTINGS",)
|
RETURN_TYPES = ("VFI_SETTINGS", "IMAGE")
|
||||||
RETURN_NAMES = ("settings",)
|
RETURN_NAMES = ("settings", "images")
|
||||||
FUNCTION = "optimize"
|
FUNCTION = "optimize"
|
||||||
CATEGORY = "video/Tween"
|
CATEGORY = "video/Tween"
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _conservative_defaults():
|
def _conservative_defaults(images):
|
||||||
"""Return safe fallback settings."""
|
"""Return safe fallback settings with image passthrough."""
|
||||||
return ({
|
return ({
|
||||||
"batch_size": 1,
|
"batch_size": 1,
|
||||||
"chunk_size": 0,
|
"chunk_size": 0,
|
||||||
@@ -762,12 +762,12 @@ class VFIOptimizer:
|
|||||||
"all_on_gpu": False,
|
"all_on_gpu": False,
|
||||||
"clear_cache_after_n_frames": 5,
|
"clear_cache_after_n_frames": 5,
|
||||||
"_info": {"source": "conservative_defaults"},
|
"_info": {"source": "conservative_defaults"},
|
||||||
},)
|
}, images)
|
||||||
|
|
||||||
def optimize(self, images, model, min_free_vram_gb, force_batch_size=0):
|
def optimize(self, images, model, min_free_vram_gb, force_batch_size=0):
|
||||||
if images.shape[0] < 2 or not torch.cuda.is_available():
|
if images.shape[0] < 2 or not torch.cuda.is_available():
|
||||||
logger.info("VFI Optimizer: <2 frames or no CUDA, returning conservative defaults")
|
logger.info("VFI Optimizer: <2 frames or no CUDA, returning conservative defaults")
|
||||||
return self._conservative_defaults()
|
return self._conservative_defaults(images)
|
||||||
|
|
||||||
device = torch.device("cuda")
|
device = torch.device("cuda")
|
||||||
|
|
||||||
@@ -805,7 +805,7 @@ class VFIOptimizer:
|
|||||||
model.to("cpu")
|
model.to("cpu")
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
return self._conservative_defaults()
|
return self._conservative_defaults(images)
|
||||||
finally:
|
finally:
|
||||||
_clear_model_cache(model)
|
_clear_model_cache(model)
|
||||||
model.to("cpu")
|
model.to("cpu")
|
||||||
@@ -881,7 +881,7 @@ class VFIOptimizer:
|
|||||||
f"calibration={elapsed*1000:.0f}ms, res={W}x{H}"
|
f"calibration={elapsed*1000:.0f}ms, res={W}x{H}"
|
||||||
)
|
)
|
||||||
|
|
||||||
return (settings,)
|
return (settings, images)
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user