Repository navigation
How to vary prompts across frames (keep previous prompt when no new one is defined) #10735
Unanswered
kaitoyonde
asked this question in
Q&A
Replies: 1 comment
|
The lookup you need is a previous-keyframe lookup, not an exact Dict lookup: choose the largest numeric key that is less than or equal to the current frame. With keys 0, 5, and 10, frame 7 should return the entry for key 5. Add key 0 as a default so frames before the first change have a value. If your Dict node only supports exact keys, the simple workaround is to expand the schedule to one entry per frame; the cleaner option is a small helper node that sorts numeric keys and returns the last key at or before the frame. Make sure the keys and frame counter are both numbers, not strings, and read the counter before the current iteration generates its frame. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi,
I’m working on a morphing image generation loop in ComfyUI, and I’m trying to figure out a clean way to handle changing prompts across frames, while keeping the previous prompt active when there’s no new one defined.
Here’s my setup:
My current approach
I use an INT node to track the frame number, with “Control After Generate” set to Increment, so the frame value automatically increases after each generation.
For each frame, I want to apply a different positive prompt depending on the frame number. For example:
{ 0: "a cat on a chair", 5: "a cat jumping", 10: "a cat flying" }That means I want this behavior:
Right now, I’m testing this using a custom Dict node from the Basic Data Handling plugin, where each key = frame number and value = prompt.
But since not all frame numbers exist in the dict, I need a way to use the previous value for missing frames.
What I need
I want something that, for a given frame, returns the prompt for:
Basically: “use the most recent defined prompt up to this frame.”\
Example result
Here’s an example of what I’ve achieved so far with this setup (loopback + ControlNet + Canny) but i literally directed (change it on the go, using 'Run after change') the prompt manually across.
Youtube
You can see how it morphs smoothly when the prompts align.
Any advice, node examples, or alternative workflows are very welcome
All reactions