Yaron Koresh commited on
Commit
7474c0a
·
verified ·
1 Parent(s): fb48484

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -11
app.py CHANGED
@@ -24,7 +24,10 @@ from lxml.html import fromstring
24
  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 AnimateDiffPipeline, MotionAdapter, DDIMScheduler, StableDiffusionPipeline
 
 
 
28
  from PIL import Image, ImageDraw, ImageFont
29
 
30
  # logging
@@ -49,6 +52,10 @@ else:
49
 
50
  #base = "emilianJR/epiCRealism"
51
  base = "SG161222/Realistic_Vision_V5.1_noVAE"
 
 
 
 
52
 
53
  # variable data
54
 
@@ -108,9 +115,27 @@ function custom(){
108
 
109
  # torch pipes
110
 
111
- adapter = MotionAdapter.from_pretrained("guoyww/animatediff-motion-adapter-v1-5-2", torch_dtype=dtype, device=device, safety_checker=None)
112
  image_pipe = StableDiffusionPipeline.from_pretrained(base, torch_dtype=dtype, safety_checker=None).to(device)
113
- pipe = AnimateDiffPipeline.from_pretrained(base, torch_dtype=dtype, motion_adapter=adapter).to(device)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  pipe.scheduler = DDIMScheduler.from_pretrained(
115
  base,
116
  subfolder="scheduler",
@@ -303,14 +328,14 @@ def ui():
303
  container=False,
304
  choices=[
305
  ("(No Effect)", ""),
306
- ("Zoom in", "guoyww/#animatediff-motion-lora-zoom-in"),
307
- ("Zoom out", "guoyww/#animatediff-motion-lora-zoom-out"),
308
- ("Tilt up", "guoyww/#animatediff-motion-lora-tilt-up"),
309
- ("Tilt down", "guoyww/#animatediff-motion-lora-tilt-down"),
310
- ("Pan left", "guoyww/#animatediff-motion-lora-pan-left"),
311
- ("Pan right", "guoyww/#animatediff-motion-lora-pan-right"),
312
- ("Roll left", "guoyww/#animatediff-motion-lora-rolling-anticlockwise"),
313
- ("Roll right", "guoyww/#animatediff-motion-lora-rolling-clockwise"),
314
  ],
315
  value="",
316
  interactive=True
 
24
  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 AnimateDiffSparseControlNetPipeline
29
+ from diffusers.models import AutoencoderKL, MotionAdapter, SparseControlNetModel
30
+ from diffusers.schedulers import DPMSolverMultistepScheduler
31
  from PIL import Image, ImageDraw, ImageFont
32
 
33
  # logging
 
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
 
60
  # variable data
61
 
 
115
 
116
  # torch pipes
117
 
 
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
+ model_id,
125
+ subfolder="scheduler",
126
+ beta_schedule="linear",
127
+ algorithm_type="dpmsolver++",
128
+ use_karras_sigmas=True,
129
+ )
130
+ pipe = AnimateDiffSparseControlNetPipeline.from_pretrained(
131
+ model_id,
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",
 
328
  container=False,
329
  choices=[
330
  ("(No Effect)", ""),
331
+ ("Zoom in", "guoyww/animatediff-motion-lora-zoom-in"),
332
+ ("Zoom out", "guoyww/animatediff-motion-lora-zoom-out"),
333
+ ("Tilt up", "guoyww/animatediff-motion-lora-tilt-up"),
334
+ ("Tilt down", "guoyww/animatediff-motion-lora-tilt-down"),
335
+ ("Pan left", "guoyww/animatediff-motion-lora-pan-left"),
336
+ ("Pan right", "guoyww/animatediff-motion-lora-pan-right"),
337
+ ("Roll left", "guoyww/animatediff-motion-lora-rolling-anticlockwise"),
338
+ ("Roll right", "guoyww/animatediff-motion-lora-rolling-clockwise"),
339
  ],
340
  value="",
341
  interactive=True