bluestarburst commited on
Commit
d1f4ed8
1 Parent(s): 1a070e2

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. handler.py +12 -9
handler.py CHANGED
@@ -3,16 +3,13 @@
3
  from diffusers import AutoencoderKL, DDPMScheduler, DDIMScheduler
4
  from transformers import CLIPTextModel, CLIPTokenizer
5
  from omegaconf import OmegaConf
 
 
6
 
7
  from diffusers.utils.import_utils import is_xformers_available
8
  from typing import Any
9
  import torch
10
- import einops
11
- import torchvision
12
-
13
- import numpy as np
14
-
15
- from diffusers import AutoPipelineForText2Image
16
 
17
  from animatediff.models.unet import UNet3DConditionModel
18
  from animatediff.pipelines.pipeline_animation import AnimationPipeline
@@ -21,7 +18,7 @@ from animatediff.utils.util import load_weights
21
 
22
 
23
  class EndpointHandler():
24
- def __init__(self, model_path: str = "bluestarburst/AnimateDiff-SceneFusion", inference_config_path: str = "configs/inference/inference-v3.yaml", motion_module: str = "models/Motion_Module/mm_sd_v15.ckpt"):
25
 
26
  # inference_config = OmegaConf.load(inference_config_path)
27
 
@@ -38,8 +35,14 @@ class EndpointHandler():
38
 
39
  self.pipeline = AnimationPipeline(
40
  vae=vae, text_encoder=text_encoder, tokenizer=tokenizer, unet=unet,
41
- scheduler=DDIMScheduler(**OmegaConf.to_container(inference_config.noise_scheduler_kwargs.DDIMScheduler)),
42
  ).to("cuda")
 
 
 
 
 
 
43
 
44
  self.pipeline = load_weights(
45
  self.pipeline,
@@ -67,7 +70,7 @@ class EndpointHandler():
67
  video_length= 5,
68
  ).videos
69
 
70
- videos = einops.rearrange(vids, "b c t h w -> t b c h w")
71
  n_rows=6
72
  fps=1
73
  loop = True
 
3
  from diffusers import AutoencoderKL, DDPMScheduler, DDIMScheduler
4
  from transformers import CLIPTextModel, CLIPTokenizer
5
  from omegaconf import OmegaConf
6
+ from huggingface_hub import hf_hub_download
7
+
8
 
9
  from diffusers.utils.import_utils import is_xformers_available
10
  from typing import Any
11
  import torch
12
+ from einops import rearrange
 
 
 
 
 
13
 
14
  from animatediff.models.unet import UNet3DConditionModel
15
  from animatediff.pipelines.pipeline_animation import AnimationPipeline
 
18
 
19
 
20
  class EndpointHandler():
21
+ def __init__(self, model_path: str = "bluestarburst/AnimateDiff-SceneFusion"):
22
 
23
  # inference_config = OmegaConf.load(inference_config_path)
24
 
 
35
 
36
  self.pipeline = AnimationPipeline(
37
  vae=vae, text_encoder=text_encoder, tokenizer=tokenizer, unet=unet,
38
+ scheduler=DDIMScheduler(**OmegaConf.to_container(inference_config['noise_scheduler_kwargs']['DDIMScheduler']'])),
39
  ).to("cuda")
40
+
41
+ # huggingface download motion module from bluestarburst/AnimateDiff-SceneFusion/models/Motion_Module/mm_sd_v15.ckpt
42
+
43
+ motion_module = "models/Motion_Module/mm_sd_v15.ckpt"
44
+ hf_hub_download(repo_id="bluestarburst/AnimateDiff-SceneFusion", filename="models/Motion_Module/mm_sd_v15.ckpt", output_dir="models/Motion_Module")
45
+
46
 
47
  self.pipeline = load_weights(
48
  self.pipeline,
 
70
  video_length= 5,
71
  ).videos
72
 
73
+ videos = rearrange(vids, "b c t h w -> t b c h w")
74
  n_rows=6
75
  fps=1
76
  loop = True