mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-01-28 15:20:25 +08:00
Update ReplaceVideoLatentFrames
Add tooltips Make source optional Better handle negative index
This commit is contained in:
parent
e3675d8175
commit
ce079b0cf5
@ -395,9 +395,9 @@ class ReplaceVideoLatentFrames(io.ComfyNode):
|
|||||||
node_id="ReplaceVideoLatentFrames",
|
node_id="ReplaceVideoLatentFrames",
|
||||||
category="latent/batch",
|
category="latent/batch",
|
||||||
inputs=[
|
inputs=[
|
||||||
io.Latent.Input("destination"),
|
io.Latent.Input("destination", tooltip="The destination latent where frames will be replaced."),
|
||||||
io.Latent.Input("source"),
|
io.Latent.Input("source", optional=True, tooltip="The source latent providing frames to insert into the destination latent. If not provided, the destination latent is returned unchanged."),
|
||||||
io.Int.Input("index", default=0, min=-nodes.MAX_RESOLUTION, max=nodes.MAX_RESOLUTION, step=1),
|
io.Int.Input("index", default=0, min=-nodes.MAX_RESOLUTION, max=nodes.MAX_RESOLUTION, step=1, tooltip="The starting latent frame index in the destination latent where the source latent frames will be placed. Negative values count from the end."),
|
||||||
],
|
],
|
||||||
outputs=[
|
outputs=[
|
||||||
io.Latent.Output(),
|
io.Latent.Output(),
|
||||||
@ -405,12 +405,18 @@ class ReplaceVideoLatentFrames(io.ComfyNode):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def execute(cls, source, destination, index) -> io.NodeOutput:
|
def execute(cls, destination, index, source=None) -> io.NodeOutput:
|
||||||
if index > destination["samples"].shape[2]:
|
if source is None:
|
||||||
logging.warning(f"ReplaceVideoLatentFrames: Index {index} is out of bounds for destination latent frames {destination['samples'].shape[2]}.")
|
|
||||||
return io.NodeOutput(destination)
|
return io.NodeOutput(destination)
|
||||||
if index + source["samples"].shape[2] > destination["samples"].shape[2]:
|
dest_frames = destination["samples"].shape[2]
|
||||||
logging.warning(f"ReplaceVideoLatentFrames: Source latent frames {source['samples'].shape[2]} do not fit within destination latent frames {destination['samples'].shape[2]} at the specified index {index}.")
|
source_frames = source["samples"].shape[2]
|
||||||
|
if index < 0:
|
||||||
|
index = dest_frames + index
|
||||||
|
if index > dest_frames:
|
||||||
|
logging.warning(f"ReplaceVideoLatentFrames: Index {index} is out of bounds for destination latent frames {dest_frames}.")
|
||||||
|
return io.NodeOutput(destination)
|
||||||
|
if index + source_frames > dest_frames:
|
||||||
|
logging.warning(f"ReplaceVideoLatentFrames: Source latent frames {source_frames} do not fit within destination latent frames {dest_frames} at the specified index {index}.")
|
||||||
return io.NodeOutput(destination)
|
return io.NodeOutput(destination)
|
||||||
s = source.copy()
|
s = source.copy()
|
||||||
s_source = source["samples"]
|
s_source = source["samples"]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user