From d5a75eb83301f89a2240f2ca4a9719d04ef574b5 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Mon, 24 Jul 2023 16:34:34 +1000 Subject: [PATCH 1/2] feat: increase seed from int32 to uint32 At some point I typo'd this and set the max seed to signed int32 max. It should be *un*signed int32 max. This restored the seed range to what it was in v2.3. --- invokeai/app/util/misc.py | 2 +- invokeai/frontend/web/src/app/constants.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/invokeai/app/util/misc.py b/invokeai/app/util/misc.py index 7c674674e2..be5b698258 100644 --- a/invokeai/app/util/misc.py +++ b/invokeai/app/util/misc.py @@ -14,7 +14,7 @@ def get_datetime_from_iso_timestamp(iso_timestamp: str) -> datetime.datetime: return datetime.datetime.fromisoformat(iso_timestamp) -SEED_MAX = np.iinfo(np.int32).max +SEED_MAX = np.iinfo(np.uint32).max def get_random_seed(): diff --git a/invokeai/frontend/web/src/app/constants.ts b/invokeai/frontend/web/src/app/constants.ts index 1194ea467b..b8fab16c1c 100644 --- a/invokeai/frontend/web/src/app/constants.ts +++ b/invokeai/frontend/web/src/app/constants.ts @@ -1,2 +1,2 @@ export const NUMPY_RAND_MIN = 0; -export const NUMPY_RAND_MAX = 2147483647; +export const NUMPY_RAND_MAX = 4294967295; From 66cdeba8a1e8ba78f255ea3ca3269c9331a889cf Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Mon, 24 Jul 2023 16:44:32 +1000 Subject: [PATCH 2/2] fix(nodes): fix seed modulus operation This was incorect and resulted in the max seed being one less than intended. --- invokeai/app/invocations/noise.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/invokeai/app/invocations/noise.py b/invokeai/app/invocations/noise.py index 442557520a..fff0f29f14 100644 --- a/invokeai/app/invocations/noise.py +++ b/invokeai/app/invocations/noise.py @@ -119,8 +119,8 @@ class NoiseInvocation(BaseInvocation): @validator("seed", pre=True) def modulo_seed(cls, v): - """Returns the seed modulo SEED_MAX to ensure it is within the valid range.""" - return v % SEED_MAX + """Returns the seed modulo (SEED_MAX + 1) to ensure it is within the valid range.""" + return v % (SEED_MAX + 1) def invoke(self, context: InvocationContext) -> NoiseOutput: noise = get_noise(