Iterating through a list #166
Replies: 4 comments 1 reply
-
Hi @Speusippus, Thank you for reaching out. While I am not familiar with the intricacies of the "combinatorial generations" setting in Dynamic Prompting, it sounds like you can achieve something similar in Unprompted by setting the For example:
This will return the following:
The only "gotcha" here is that you must manually set your Batch Count equal to the length of your choose list (3). (I mean, you could maybe automate it by defining your We can extend our code to fulfill your Red/Yellow/Blue question:
The benefit of doing it this way (vs a global "combinatorial" setting) is that our second I hope that helps. Let me know if you need any further clarification. :) |
Beta Was this translation helpful? Give feedback.
-
Amazing, I knew unprompted gives access to variables like batch number but it just didn't occur to me to use the batch number. Sheesh. Every time I return to anything resembling coding I get both "I should have done this for a living" feelings and "I am so stupid" feelings at the same time. Thank you!
…________________________________
From: ThereforeGames ***@***.***>
Sent: Thursday, July 20, 2023 1:16 AM
To: ThereforeGames/unprompted ***@***.***>
Cc: Speusippus ***@***.***>; Mention ***@***.***>
Subject: Re: [ThereforeGames/unprompted] Iterating through a list (Discussion #166)
Hi @Speusippus<https://github.com/Speusippus>,
Thank you for reaching out.
While I am not familiar with the intricacies of the "combinatorial generations" setting in Dynamic Prompting, it sounds like you can achieve something similar in Unprompted by setting the _case paramter of [choose] to batch_index.
For example:
[choose _case="{get batch_index}"]pig|cat|dog[/choose]
This will return the following:
Prompt 0: pig
Prompt 1: cat
Prompt 2: dog
The only "gotcha" here is that you must manually set your Batch Count equal to the length of your choose list (3).
(I mean, you could maybe automate it by defining your [choose] list as [array your_array] and then [set batch_count] to [length your_array] but that's getting into more complicated/untested territory.)
We can extend our code to fulfill your Red/Yellow/Blue question:
[choose _case="{get batch_index}"]Red|Yellow|Blue[/choose] [choose]Red|Yellow|Blue[/choose]
The benefit of doing it this way (vs a global "combinatorial" setting) is that our second [choose] block will remain randomized per the seed.
I hope that helps. Let me know if you need any further clarification. :)
—
Reply to this email directly, view it on GitHub<#166 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ABWYMATGBOXD64RNB566JWDXRC5LLANCNFSM6AAAAAA2BI4UJU>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Unfortunately, this doesn't seem to work. I typed:
[choose _case="{get batch_index}"]Red|Yellow|Blue[/choose] [choose]flower|ball|house[/choose]
I set batch count to 3, and batch size to 4.
Expected output--
Twelve images:
the first four being all red and randomly either a flower, ball or house
The next four being all yellow, and either a flower ball or house in the same order as the red selections
The final four being all blue, and either a flower ball or house in the same order again.
Actual output--
Twelve images:
the first four being all red, all balls
the second four being all yellow, all flowers
the third four being all blue, all flowers
Is there a way to get that first output instead, using a similar technique?
(I tried it with "syncronize with main seed" both selected and deselected, this did not seem to make a difference.)
…________________________________
From: ThereforeGames ***@***.***>
Sent: Thursday, July 20, 2023 1:16 AM
To: ThereforeGames/unprompted ***@***.***>
Cc: Speusippus ***@***.***>; Mention ***@***.***>
Subject: Re: [ThereforeGames/unprompted] Iterating through a list (Discussion #166)
Hi @Speusippus<https://github.com/Speusippus>,
Thank you for reaching out.
While I am not familiar with the intricacies of the "combinatorial generations" setting in Dynamic Prompting, it sounds like you can achieve something similar in Unprompted by setting the _case paramter of [choose] to batch_index.
For example:
[choose _case="{get batch_index}"]pig|cat|dog[/choose]
This will return the following:
Prompt 0: pig
Prompt 1: cat
Prompt 2: dog
The only "gotcha" here is that you must manually set your Batch Count equal to the length of your choose list (3).
(I mean, you could maybe automate it by defining your [choose] list as [array your_array] and then [set batch_count] to [length your_array] but that's getting into more complicated/untested territory.)
We can extend our code to fulfill your Red/Yellow/Blue question:
[choose _case="{get batch_index}"]Red|Yellow|Blue[/choose] [choose]Red|Yellow|Blue[/choose]
The benefit of doing it this way (vs a global "combinatorial" setting) is that our second [choose] block will remain randomized per the seed.
I hope that helps. Let me know if you need any further clarification. :)
—
Reply to this email directly, view it on GitHub<#166 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ABWYMATGBOXD64RNB566JWDXRC5LLANCNFSM6AAAAAA2BI4UJU>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Hi @Speusippus, Unprompted v9.13.0 adds a slew of features that will hopefully let you achieve what you set out to do. How does this look? To do this, you'll need to update your template in a couple places:
The new At the dawn of the next batch, the Meanwhile, the Red|Blue|Yellow choice block is determined by Anyhow, hopefully that makes sense and does the job. Let me know if you have any further questions. |
Beta Was this translation helpful? Give feedback.
-
Sorry for the basic question.
In the Dynamic Prompting extension if I turn "combinatorial generations" on and type into the prompt field "{pig|cat|dog}", this produces three prompts, "pig", "cat", and "dog".
What's the easiest way to do this (assuming there is a way) using unprompted?
Looking through the shortcodes I'm getting visions of arrays and fors and gets, but it feels like I have to be overcomplicating it once I start going into that direction. Is there maybe some simple single shortcode I'm accidentally skipping that would do this more succinctly?
My big hope is to find a way, using some extension or other, to do both iteration through a list and randomly choosing from a list -- while having the random choice be determined by the seed -- all in one single script.* Dynamic Prompts doesn't work for this because you have to have it either in "combinatorial generation" mode or not--can't do both in one script. Jinja2 doesn't work for this either, because its random chooser isn't determined by the seed. (Seems, in other words, to use its own separate inaccessible seed). So the same script yields different results. I thought hopefully Unprompted would get me there but I'm having trouble seeing a simple way to do the iteration through a list bit. (But random choosing is determined by the seed, so that's good.)
*Example, something like
FOR EACH of these: Red, Yellow, Blue
generate a prompt concatenating that color with ONE RANDOMLY CHOSEN PHRASE FROM THE FOLLOWING: Pig, Cat, Dog
I would like to thereby generate three prompts, for example
Red Pig
Yellow Pig
Blue Cat
Where each color is iterated through, followed by a randomly chosen animal.
But importantly, I would like the "generate" button to produce EXACTLY THE SAME images every time, if I set the seed and script identically. In other words, given the same seed, I'd like it to choose the same animals it chose the prior time I used that seed, in the same order.
Beta Was this translation helpful? Give feedback.
All reactions