Skip to content

Commit

Permalink
Fix random seed
Browse files Browse the repository at this point in the history
  • Loading branch information
lucataco committed Sep 24, 2023
1 parent 4c4335f commit 59c88d9
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions predict.py
Expand Up @@ -55,7 +55,7 @@ def predict(
n_prompt: str = Input(description="Negative prompt", default=""),
steps: int = Input(description="Number of inference steps", ge=1, le=100, default=25),
guidance_scale: float = Input(description="guidance scale", ge=1, le=10, default=7.5),
seed: int = Input(description="Seed (0 = random, maximum: 2147483647)", default=0),
seed: int = Input(description="Seed (0 = random, maximum: 2147483647)", default=None),
) -> Path:
"""Run a single prediction on the model"""
lora_alpha=0.8
Expand Down Expand Up @@ -118,10 +118,11 @@ def predict(

self.pipeline.to("cuda")

if seed != 0: torch.manual_seed(seed)
else: torch.seed()
if seed is None:
seed = int.from_bytes(os.urandom(4), "big")
print(f"Using seed: {seed}")
torch.manual_seed(seed)

print(f"current seed: {torch.initial_seed()}")
print(f"sampling: {prompt} ...")
outname = "output.gif"
outpath = f"./{outname}"
Expand Down

0 comments on commit 59c88d9

Please sign in to comment.