ThereforeGames/unprompted

batch init_image not iterating through a directory

gboxentertainment opened this issue · 3 comments

Firstly, I wanted to say that this is the most amazing extension out there and opens up so many possibilities.

I've been trying to experiment with iterating through all the images within a directory and using their filenames as prompts (based on a previous reply to a post that you made explaining this). I did manage to get everything working (prompts are based on each input image filename that it iterates through in a directory) except that the images (init_image) do not change in each iteration. Am I supposed to use the default img2img tab or the "batch" tab in the webgui? I can't seem to get either working properly.

At the moment, I am just testing it in img2img (assuming that prior to the latest update, that was the one you're supposed to use) and setting the batch_count in the webgui to the number of iterations I want.
If I end the init_image path with *, then it selects a random image in the directory, but every iteration in a batch is just that first image it chooses. Maybe its because I am not doing it right?

For debugging purposes, I am simplifying it down to testing the basics. Maybe it is something to do with batch_count?
In the img2img tab on the webgui, if I keep batch_count at the default (1), and in my template, I write [set batch_count]3[/set], I'm expecting it to override the webgui settings and generate 3 images. But it still only generates the 1 image set by the webgui. Am I not using this correctly?
I have also tried adding [enable_multi_images] to the end of the prompt, but it doesn't seem to do anything - is this meant to be [enable_multi_images=1] to turn it on?

so I just did another test by setting the seed to batch_index. i.e. [set seed][get batch_index][/set], running it with a batch of 5, and it turns out that I actually had to set seed in the webgui to 0 for it to iterate through the correct batch numbers.
I thought this might've been the cause of the issue, but seems like it still didn't solve the issue of init_image being assigned to more than one image within the directory during a batch run. Here is my code that I am testing init_image with:
[set r_imgs][filelist "K:\ai\SD\output\redo\test\*.*"][/set]
[set batch_count][length "{get r_imgs}"][/set]
[set c_img][choose _case="{get batch_index}"][get r_imgs][/choose][/set]
[init_image "{get c_img}"]

where "r_imgs" is the directory and "c_img" is the current image that the batch is processing.

I just realised that one of the example templates pretty much does most of what I want, iterating through a folder. I noticed that it doesn't use batch_index but just iterates using [for] and [after]

It sounds like the example template answered your questions, but if you're still having trouble iterating over a folder please let me know. Thanks.