stable-diffusion-webui
stable-diffusion-webui copied to clipboard
In Batch img2img - Make seeds continue to increment image to image
Is there an existing issue for this?
- [X] I have searched the existing issues and checked the recent builds/commits
What would your feature do ?
When performing a Batch img2img session on a folder, instead of recycling the seed for each set of batches, continue to increment the seed when moving to the next image in the folder (unless some other setting overrules this behavior).
Right now, batch img2img seems to recycle seeds. When processing three images from a folder, with a Batch count of 3, and with an example start seed of 90, here's what happens: Generating from Image 1: seed(1)=90, seed(2)=91, seed(3)=92 Generating from Image 2: seed(1)=90, seed(2)=91, seed(3)=92 Generating from Image 3: seed(1)=90, seed(2)=91, seed(3)=92
I've found a bug report and a feature request about this same behavior, and on both of them, the person making the request was unable to express the behavior in a way that was clear. If you're unsure that you understand what I'm trying to describe, try this:
Put three copies of the same image in a folder and run a Batch img2img on the folder. You'll end up with 3 sets of nearly identical images. That's because the initial seed is being recycled batch to batch. Likewise, dropping the generated images in the PNG Info tab will show the same 3 seeds over and over.
Another way to test this is to change the Filename Pattern in settings to make the filename simply [seed]. You can run as many batches as you like from three images. You'll only end up with 3 files in the end because the seed is recycling and Automatic1111 overwrites files when there is a name conflict.
Proposed workflow
Here is my probably ignorant pseudo-code. I develop in a language other than Python. INITIAL_SEED=x COUNTER=0 FOR each image in a folder: SEED = INITIAL_SEED + (index*COUNTER) #index here is the index of the for loop COUNTER += 1
The benefits of this change would be more variability between generated images in the Batch img2img tab.
Additional information
Thank you very much for your part in creating such an amazing set of tools. I really appreciate it.
If I remember correctly the setting "Make K-diffusion samplers produce same images in a batch as when making a single image" affects this behavior. Does your proposal take this setting into account?
Regardless I agree that there needs to be more granular seed incrementation settings in img2img and txt2img. Does the seed vary with Batch Number or Position in Batch? What happens if we have a randomized seed and a user defined variation seed? vice versa? The behavior is not very intuitive nor is it evident in the UI without trial and error.
Thanks for your response. I'm thinking that maybe I did not explain it clearly enough. Let me try to explain again.
Let's say that I'm running a Batch img2img on a folder with 4 images in it, and I want three generations from each source image. For this example, I have NOT set the seed. Let's say it randomly starts at 1111111110. I think that, as the source images are being processed, the seed should continue to increment, like this: Source image 1 seeds = 1111111110, 1111111111, 1111111112 Source image 2 seeds = 1111111113, 1111111114, 1111111115 Source image 3 seeds = 1111111116, 1111111117, 1111111118 Source image 4 seeds = 1111111119, 1111111120, 1111111121
Right now, it recycles the seed when it moves on to the next image, like this: Source image 1 seeds = 1111111110, 1111111111, 1111111112 Source image 2 seeds = 1111111110, 1111111111, 1111111112 Source image 3 seeds = 1111111110, 1111111111, 1111111112 Source image 4 seeds = 1111111110, 1111111111, 1111111112
Thanks again.
In my opinion, it should try the same seed on the next image, so I think that be default it keeps the same behavior, and optionally increments. The way I see it, you're crawling the seeds to find one that does good on certain types of images. If I was brute forcing through it, I wouldn't want my image 3 to skip 0 through 5. Having this skip is not much different than random. Having it orderly allows you to compare the outputs from the same seed and decide the strong and week points of the seed, for future reuse.
I'm also looking for a way to either increment the seed on each subsequent image when using Batch img2img, or keep randomizing the seed before each image. Is there an existing workaround, setting or script to accomplish this within the latest version of the web ui?
@Gerschel:
The way I see it, you're crawling the seeds to find one that does good on certain types of images.
That may be your specific use case, but it's not mine, and there's no reason to artificially limit this behavior when it could be controlled easily enough by a setting.
Hi I've got the same issue. Did you find any solution ?
Same issue here but I would already be happy with a random seed per image 🙄
I also need this behavior. My workaround for now is to use ComfyUI with "Load Image Batch" from WAS node suite.