Spaces:
Sleeping
Sleeping
Yaron Koresh
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -25,8 +25,8 @@ from diffusers.utils import export_to_gif, load_image
|
|
25 |
from huggingface_hub import hf_hub_download
|
26 |
from safetensors.torch import load_file, save_file
|
27 |
from diffusers import StableDiffusionPipeline
|
28 |
-
from diffusers import
|
29 |
-
from diffusers.models import AutoencoderKL, MotionAdapter
|
30 |
from diffusers.schedulers import DPMSolverMultistepScheduler
|
31 |
from PIL import Image, ImageDraw, ImageFont
|
32 |
|
@@ -52,8 +52,6 @@ else:
|
|
52 |
|
53 |
#base = "emilianJR/epiCRealism"
|
54 |
base = "SG161222/Realistic_Vision_V5.1_noVAE"
|
55 |
-
controlnet_id = "guoyww/animatediff-sparsectrl-scribble"
|
56 |
-
lora_adapter_id = "guoyww/animatediff-motion-lora-v1-5-3"
|
57 |
vae_id = "stabilityai/sd-vae-ft-mse"
|
58 |
motion_adapter = "guoyww/animatediff-motion-adapter-v1-5-3"
|
59 |
|
@@ -118,8 +116,8 @@ function custom(){
|
|
118 |
image_pipe = StableDiffusionPipeline.from_pretrained(base, torch_dtype=dtype, safety_checker=None).to(device)
|
119 |
|
120 |
adapter = MotionAdapter.from_pretrained(motion_adapter, torch_dtype=dtype, safety_checker=None).to(device)
|
121 |
-
controlnet = SparseControlNetModel.from_pretrained(controlnet_id, torch_dtype=torch.float16).to(device)
|
122 |
vae = AutoencoderKL.from_pretrained(vae_id, torch_dtype=torch.float16).to(device)
|
|
|
123 |
scheduler = DPMSolverMultistepScheduler.from_pretrained(
|
124 |
base,
|
125 |
subfolder="scheduler",
|
@@ -127,16 +125,7 @@ scheduler = DPMSolverMultistepScheduler.from_pretrained(
|
|
127 |
algorithm_type="dpmsolver++",
|
128 |
use_karras_sigmas=True
|
129 |
)
|
130 |
-
|
131 |
-
base,
|
132 |
-
motion_adapter=motion_adapter,
|
133 |
-
controlnet=controlnet,
|
134 |
-
vae=vae,
|
135 |
-
scheduler=scheduler,
|
136 |
-
torch_dtype=torch.float16
|
137 |
-
).to(device)
|
138 |
-
|
139 |
-
pipe.scheduler = DDIMScheduler.from_pretrained(
|
140 |
base,
|
141 |
subfolder="scheduler",
|
142 |
clip_sample=False,
|
@@ -144,6 +133,15 @@ pipe.scheduler = DDIMScheduler.from_pretrained(
|
|
144 |
beta_schedule="linear",
|
145 |
steps_offset=1,
|
146 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
pipe.enable_vae_slicing()
|
148 |
pipe.load_ip_adapter("h94/IP-Adapter", subfolder="models", weight_name="ip-adapter_sd15.bin")
|
149 |
pipe.enable_model_cpu_offload()
|
|
|
25 |
from huggingface_hub import hf_hub_download
|
26 |
from safetensors.torch import load_file, save_file
|
27 |
from diffusers import StableDiffusionPipeline
|
28 |
+
from diffusers import AnimateDiffPipeline
|
29 |
+
from diffusers.models import AutoencoderKL, MotionAdapter
|
30 |
from diffusers.schedulers import DPMSolverMultistepScheduler
|
31 |
from PIL import Image, ImageDraw, ImageFont
|
32 |
|
|
|
52 |
|
53 |
#base = "emilianJR/epiCRealism"
|
54 |
base = "SG161222/Realistic_Vision_V5.1_noVAE"
|
|
|
|
|
55 |
vae_id = "stabilityai/sd-vae-ft-mse"
|
56 |
motion_adapter = "guoyww/animatediff-motion-adapter-v1-5-3"
|
57 |
|
|
|
116 |
image_pipe = StableDiffusionPipeline.from_pretrained(base, torch_dtype=dtype, safety_checker=None).to(device)
|
117 |
|
118 |
adapter = MotionAdapter.from_pretrained(motion_adapter, torch_dtype=dtype, safety_checker=None).to(device)
|
|
|
119 |
vae = AutoencoderKL.from_pretrained(vae_id, torch_dtype=torch.float16).to(device)
|
120 |
+
|
121 |
scheduler = DPMSolverMultistepScheduler.from_pretrained(
|
122 |
base,
|
123 |
subfolder="scheduler",
|
|
|
125 |
algorithm_type="dpmsolver++",
|
126 |
use_karras_sigmas=True
|
127 |
)
|
128 |
+
scheduler2 = DDIMScheduler.from_pretrained(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
base,
|
130 |
subfolder="scheduler",
|
131 |
clip_sample=False,
|
|
|
133 |
beta_schedule="linear",
|
134 |
steps_offset=1,
|
135 |
)
|
136 |
+
|
137 |
+
pipe = AnimateDiffPipeline.from_pretrained(
|
138 |
+
base,
|
139 |
+
motion_adapter=motion_adapter,
|
140 |
+
vae=vae,
|
141 |
+
scheduler=scheduler,
|
142 |
+
torch_dtype=torch.float16
|
143 |
+
).to(device)
|
144 |
+
|
145 |
pipe.enable_vae_slicing()
|
146 |
pipe.load_ip_adapter("h94/IP-Adapter", subfolder="models", weight_name="ip-adapter_sd15.bin")
|
147 |
pipe.enable_model_cpu_offload()
|