Created
August 27, 2023 06:07
-
-
Save opparco/a36eaba42cb5712b04c0c143775524b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/scripts/animatediff.py b/scripts/animatediff.py | |
index 9696b5a..37e1705 100644 | |
--- a/scripts/animatediff.py | |
+++ b/scripts/animatediff.py | |
@@ -137,6 +137,22 @@ class AnimateDiffScript(scripts.Script): | |
p.batch_size = video_length | |
self.inject_motion_modules(p, model) | |
+ beta_start = 0.00085 | |
+ beta_end = 0.012 | |
+ # beta_schedule = "linear" | |
+ # num_train_timesteps = 1000 # default | |
+ | |
+ betas = torch.linspace(beta_start, beta_end, p.sd_model.num_timesteps, dtype=torch.float32, device=device) | |
+ | |
+ alphas = 1.0 - betas | |
+ alphas_cumprod = torch.cumprod(alphas, dim=0) | |
+ alphas_cumprod_prev = torch.cat( | |
+ (torch.tensor([1.0], dtype=torch.float32, device=device), alphas_cumprod[:-1])) | |
+ | |
+ p.sd_model.betas = betas | |
+ p.sd_model.alphas_cumprod = alphas_cumprod | |
+ p.sd_model.alphas_cumprod_prev = alphas_cumprod_prev | |
+ | |
def postprocess(self, p: StableDiffusionProcessing, res: Processed, enable_animatediff=False, loop_number=0, video_length=16, fps=8, model="mm_sd_v15.ckpt"): | |
if enable_animatediff: | |
self.remove_motion_modules(p) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment