added vae scaling factor

This commit is contained in:
Saquib Alam 2023-08-04 03:16:38 +05:30 committed by GitHub
parent df0442a521
commit bbd7c6e097
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,9 @@
import torch
from nodes import MAX_RESOLUTION
# diffusers library scale the random noise
vae_scaling_factor = 0.18215
class NoisyLatentImage:
def __init__(self, device="cpu"):
self.device = device
@ -19,7 +22,7 @@ class NoisyLatentImage:
def generate(self, seed, width, height, batch_size=1):
generator = torch.manual_seed(seed)
latent = torch.randn([batch_size, 4, height // 8, width // 8], generator=generator, device=self.device)
latent = torch.randn([batch_size, 4, height // 8, width // 8], generator=generator, device=self.device) / vae_scaling_factor
return ({"samples":latent}, )