How to print out the seed used

#41
by Aporetic - opened

I have commented out the line of code within dml_onx.py, "torch.manual_seed(42)" to manually set the seed.
Thus, seeds are randomized. After doing this, is there some way to print out the seed that's used for a prompt to the console,
or any other means of determining which seed a generated image used?

Solution:
Instead of removing the line in dml_onx.py, "torch.manual_seed(42)" to manually set the seed, I simply input a random number into the manual_seed as detailed in the reddit post below:
https://www.reddit.com/r/StableDiffusion/comments/wu1gg6/randomizing_seeds_when_running_locally/
After importing random, you can simply replace the "torch.manual_seed(42)" with the following three lines of code to use then print out a random seed value:
seedValue=random.randint(0,4294967295)
torch.manual_seed(seedValue)
print("Seed value: ", seedValue)

note: 4294967295 is used as it is reportedly the upper bound of Stable Diffusion's seed value. However, I have tested the value 4294967296 (one higher than previous) which works fine, so I am unsure.

Sign up or log in to comment