Yaron Koresh commited on
Commit
9a43a98
·
verified ·
1 Parent(s): 6d985a6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -15
app.py CHANGED
@@ -18,17 +18,17 @@ from diffusers.utils import export_to_gif, load_image
18
  from diffusers.models.modeling_utils import ModelMixin
19
  from huggingface_hub import hf_hub_download
20
  from safetensors.torch import load_file, save_file
21
- from diffusers import DiffusionPipeline, AnimateDiffPipeline, MotionAdapter, EulerDiscreteScheduler, StableDiffusionXLPipeline, UNet2DConditionModel, AutoencoderKL, UNet3DConditionModel
22
  import jax
23
  import jax.numpy as jnp
24
 
25
  last_motion=None
26
  fps=15
27
- time=5
28
  device = "cuda"
29
  dtype = torch.float16
30
  result=[]
31
- step = 2
32
  #repo = "ByteDance/AnimateDiff-Lightning"
33
  #ckpt = f"animatediff_lightning_{step}step_diffusers.safetensors"
34
  #base = "emilianJR/epiCRealism"
@@ -142,18 +142,15 @@ def Piper(image,positive,negative,motion):
142
  last_motion = motion
143
 
144
  pipe.to(device)
145
-
146
- if negative == "":
147
- negative = None
148
-
149
  return pipe(
150
- positive,
151
  negative_prompt=negative,
152
  height=1024,
153
  width=576,
154
  ip_adapter_image=image.convert("RGB").resize((576,1024)),
155
  num_inference_steps=step,
156
- guidance_scale=1,
157
  num_frames=(fps*time)
158
  )
159
 
@@ -194,12 +191,13 @@ def run(i,m,p1,p2,*result):
194
  return out
195
 
196
  pipe = AnimateDiffPipeline.from_pretrained(base, motion_adapter=adapter, torch_dtype=dtype).to(device)
197
- pipe.scheduler = EulerDiscreteScheduler(
198
- beta_start=0.00085,
199
- beta_end=0.012,
200
- beta_schedule="linear",
201
- timestep_spacing="trailing",
202
- steps_offset=1
 
203
  )
204
  pipe.load_ip_adapter("h94/IP-Adapter", subfolder="models", weight_name="ip-adapter_sd15.bin")
205
  pipe.enable_vae_slicing()
 
18
  from diffusers.models.modeling_utils import ModelMixin
19
  from huggingface_hub import hf_hub_download
20
  from safetensors.torch import load_file, save_file
21
+ from diffusers import DiffusionPipeline, AnimateDiffPipeline, MotionAdapter, EulerDiscreteScheduler, DDIMScheduler, StableDiffusionXLPipeline, UNet2DConditionModel, AutoencoderKL, UNet3DConditionModel
22
  import jax
23
  import jax.numpy as jnp
24
 
25
  last_motion=None
26
  fps=15
27
+ time=2
28
  device = "cuda"
29
  dtype = torch.float16
30
  result=[]
31
+ step = 30
32
  #repo = "ByteDance/AnimateDiff-Lightning"
33
  #ckpt = f"animatediff_lightning_{step}step_diffusers.safetensors"
34
  #base = "emilianJR/epiCRealism"
 
142
  last_motion = motion
143
 
144
  pipe.to(device)
145
+
 
 
 
146
  return pipe(
147
+ prompt=positive,
148
  negative_prompt=negative,
149
  height=1024,
150
  width=576,
151
  ip_adapter_image=image.convert("RGB").resize((576,1024)),
152
  num_inference_steps=step,
153
+ guidance_scale=7.5,
154
  num_frames=(fps*time)
155
  )
156
 
 
191
  return out
192
 
193
  pipe = AnimateDiffPipeline.from_pretrained(base, motion_adapter=adapter, torch_dtype=dtype).to(device)
194
+ pipe.scheduler = DDIMScheduler(
195
+ clip_sample=False,
196
+ beta_start=0.00085,
197
+ beta_end=0.012,
198
+ beta_schedule="linear",
199
+ timestep_spacing="trailing",
200
+ steps_offset=1
201
  )
202
  pipe.load_ip_adapter("h94/IP-Adapter", subfolder="models", weight_name="ip-adapter_sd15.bin")
203
  pipe.enable_vae_slicing()