dream-textures icon indicating copy to clipboard operation
dream-textures copied to clipboard

Seed resets to Int32.MinValue if seed value is over Int32.Max, even though it's a valid seed number from Stable Diffusion generator

Open nikolatesla20 opened this issue 3 years ago • 3 comments

Is this a known issue? I don't believe so

Describe the bug Quite often when I try to copy and paste the seed for an image I want to further refine, the Dream Texture UI will replace the seed with the maximum negative integer instead (-2147xxxxxxx)

To Reproduce

  1. Create a new random image
  2. Copy the seed to the clipboard (the seed is the image filename in the blender UI)
  3. Paste the new seed into Dream Texture UI, into the seed text field
  4. Note the value the seed text field indicates

version 0.0.5

Expected behavior The seed text field should be the seed value I pasted

It seems to work sometimes for certain seed values, but perhaps my seed value starts to get out of range of an integer? So it just replaces it with MinValue

Screenshots Here is the negative number I'm talking about image

Here is an example, I generated a brand new image. Notice the seed value at the top of the screen image

Now look at seed value on the UI, this is what value it turned into when I tried to paste the seed number of the image into the field.

If you paste this seed value into the Seed text field it will be converted to large negative number which appears to be in32.MinValue or such. So the seed is unusable/uncopyable, and you cannot refine this image anymore

It looks like the seed value is probably out of range of Int and the text field needs to use Long or something

This code seems to destroy a seed value if it's higher than In32.MaxValue, which happens quite often (this is the code 0.0.5 uses) image

I see newer versions of the code use a Seed_Clamp funcion (newly added) but they try to clamp to an int range. This won't work! Stable diffusion seeds can be 10 digits long, I don't think we can compare against 2^32-1. Instead maybe just count the digits from right to left or something. Or just don't restrict the value at all

System (please complete the following information):

  • OS
    • [x] Windows
    • [ ] macOS
    • [ ] Other
  • GPU
    • [x] NVIDIA
    • [ ] NVIDIA 16XX
    • [ ] Apple Silicon
    • [ ] AMD
  • Addon Version
    • Latest

Additional context Add any other context about the problem here.

nikolatesla20 avatar Sep 26 '22 23:09 nikolatesla20

I see newer versions of the code use a Seed_Clamp funcion (newly added) but they try to clamp to an int range. This won't work! Stable diffusion seeds can be 10 digits long, I don't think we can compare against 2^32-1.

2^32-1 is 10 digits: 4,294,967,295

This is a limit from pytorch lightning's seed_everything() which limits seeds within a uint32 range. Anything outside of that range leads to the function randomly selecting a new seed which is within that range. The stable-diffusion fork this addon uses and the original from CompVis use this function to handle their seeds.

NullSenseStudio avatar Sep 27 '22 17:09 NullSenseStudio

I see newer versions of the code use a Seed_Clamp funcion (newly added) but they try to clamp to an int range. This won't work! Stable diffusion seeds can be 10 digits long, I don't think we can compare against 2^32-1.

2^32-1 is 10 digits: 4,294,967,295

This is a limit from pytorch lightning's seed_everything() which limits seeds within a uint32 range. Anything outside of that range leads to the function randomly selecting a new seed which is within that range. The stable-diffusion fork this addon uses and the original from CompVis use this function to handle their seeds.

it's quite possible the latest version 0.0.6 may fix my issue but I want to avoid other possible bugs that may be in that release.

For now I have managed to fix the problem locally on my machine by switching the input field and handling of that value to be a text field instead and just pass the seed around directly as text. I don't think we should worry so much about validating this field, most people are going to be copy/pasting into it.

nikolatesla20 avatar Sep 27 '22 17:09 nikolatesla20

I don't think we should worry so much about validating this field

It absolutely should be validated. If someone is wanting to reuse the seed but it's outside a usable range it'll completely change the result, making copying and pasting pointless. There is no reason to allow manually inserting a seed if the underlying system completely discards it.

NullSenseStudio avatar Sep 27 '22 19:09 NullSenseStudio

This issue is stale because it has been open for 60 days with no activity.

github-actions[bot] avatar Apr 22 '23 01:04 github-actions[bot]

This issue was closed because it has been inactive for 7 days since being marked as stale.

github-actions[bot] avatar Apr 29 '23 01:04 github-actions[bot]