feat(nodes): add seed validator

If `seed>SEED_MAX`, we can still continue if we parse the seed as `seed % SEED_MAX`.
This commit is contained in:
psychedelicious 2023-05-24 15:00:32 +10:00 committed by Kent Keirsey
parent 55b3193629
commit 8f393b64b8

View File

@ -140,6 +140,11 @@ 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
def invoke(self, context: InvocationContext) -> NoiseOutput:
device = torch.device(choose_torch_device())
noise = get_noise(self.width, self.height, device, self.seed)