Commit
·
f6f9150
1
Parent(s):
e74281b
Update handler.py
Browse files- handler.py +18 -6
handler.py
CHANGED
|
@@ -1,12 +1,9 @@
|
|
| 1 |
# this is the huggingface handler file
|
| 2 |
-
|
| 3 |
from diffusers import AutoencoderKL, DDPMScheduler, DDIMScheduler
|
| 4 |
from transformers import CLIPTextModel, CLIPTokenizer
|
| 5 |
from omegaconf import OmegaConf
|
| 6 |
-
|
| 7 |
-
from animatediff.pipelines.pipeline_animation import AnimationPipeline
|
| 8 |
-
from animatediff.utils.util import save_videos_grid
|
| 9 |
-
from animatediff.utils.util import load_weights
|
| 10 |
from diffusers.utils.import_utils import is_xformers_available
|
| 11 |
from typing import Any
|
| 12 |
import torch
|
|
@@ -15,6 +12,14 @@ import torchvision
|
|
| 15 |
|
| 16 |
import numpy as np
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
class EndpointHandler():
|
| 19 |
def __init__(self, model_path: str = "models/StableDiffusion/", inference_config_path: str = "configs/inference/inference-v3.yaml", motion_module: str = "models/Motion_Module/mm_sd_v15.ckpt"):
|
| 20 |
|
|
@@ -88,4 +93,11 @@ class EndpointHandler():
|
|
| 88 |
# imageio.mimsave(path, outputs, fps=fps)
|
| 89 |
|
| 90 |
# return a gif file as bytes
|
| 91 |
-
return outputs
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# this is the huggingface handler file
|
| 2 |
+
|
| 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
|
|
|
|
| 12 |
|
| 13 |
import numpy as np
|
| 14 |
|
| 15 |
+
|
| 16 |
+
from animatediff.pipelines.pipeline_animation import AnimationPipeline
|
| 17 |
+
from animatediff.models.unet import UNet3DConditionModel
|
| 18 |
+
from animatediff.pipelines.pipeline_animation import AnimationPipeline
|
| 19 |
+
from animatediff.utils.util import save_videos_grid
|
| 20 |
+
from animatediff.utils.util import load_weights
|
| 21 |
+
|
| 22 |
+
|
| 23 |
class EndpointHandler():
|
| 24 |
def __init__(self, model_path: str = "models/StableDiffusion/", inference_config_path: str = "configs/inference/inference-v3.yaml", motion_module: str = "models/Motion_Module/mm_sd_v15.ckpt"):
|
| 25 |
|
|
|
|
| 93 |
# imageio.mimsave(path, outputs, fps=fps)
|
| 94 |
|
| 95 |
# return a gif file as bytes
|
| 96 |
+
return outputs
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
# This is the entry point for the serverless function.
|
| 100 |
+
# This function will be called during inference time.
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
new_handler = EndpointHandler()
|