Yaron Koresh commited on
Commit
263cf43
·
verified ·
1 Parent(s): 0fc6336

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -23,18 +23,18 @@ import jax
23
  import jax.numpy as jnp
24
 
25
  last_motion=None
26
- fps=15
27
- time=1
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"
35
- #base = "SG161222/Realistic_Vision_V6.0_B1_noVAE"
36
  #adapter = MotionAdapter.from_pretrained("guoyww/animatediff-motion-adapter-v1-5-3")
37
- #vae = AutoencoderKL.from_single_file("https://huggingface.co/stabilityai/sd-vae-ft-mse-original/vae-ft-mse-840000-ema-pruned.safetensors")
38
  #unet = UNet2DConditionModel.from_config("emilianJR/epiCRealism",subfolder="unet").to(device, dtype).load_state_dict(load_file(hf_hub_download("emilianJR/epiCRealism", "unet/diffusion_pytorch_model.safetensors"), device=device), strict=False)
39
 
40
  css="""
@@ -128,7 +128,7 @@ def generate_random_string(length):
128
  return ''.join(random.choice(characters) for _ in range(length))
129
 
130
  @spaces.GPU(duration=65)
131
- def Piper(name,positive_prompt,negative,motion):
132
  global last_motion
133
 
134
  pipe.unet.load_state_dict(load_file(hf_hub_download(repo, ckpt), device=device), strict=False)
@@ -141,12 +141,12 @@ def Piper(name,positive_prompt,negative,motion):
141
  last_motion = motion
142
 
143
  return pipe(
144
- positive_prompt,
145
  negative_prompt=negative,
146
  height=1024,
147
  width=576,
148
  num_inference_steps=step,
149
- guidance_scale=7,
150
  num_frames=(fps*time)
151
  )
152
 
@@ -162,7 +162,7 @@ def infer(pm):
162
  _do.append(f'{p1}')
163
  posi = " ".join(_do)
164
 
165
- out = Piper(name,posi,neg,pm["m"])
166
  export_to_gif(out.frames[0],name,fps=fps)
167
  return name
168
 
@@ -184,7 +184,7 @@ def run(m,p1,p2,*result):
184
 
185
  return out
186
 
187
- pipe = AnimateDiffPipeline.from_pretrained(base, torch_dtype=dtype).to(device)
188
  pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config, timestep_spacing="trailing", beta_schedule="linear")
189
  pipe.enable_free_init(method="butterworth", use_fast_sampling=False)
190
 
 
23
  import jax.numpy as jnp
24
 
25
  last_motion=None
26
+ fps=25
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"
35
+ base = "SG161222/Realistic_Vision_V6.0_B1_noVAE"
36
  #adapter = MotionAdapter.from_pretrained("guoyww/animatediff-motion-adapter-v1-5-3")
37
+ vae = AutoencoderKL.from_single_file("https://huggingface.co/stabilityai/sd-vae-ft-mse-original/vae-ft-mse-840000-ema-pruned.safetensors")
38
  #unet = UNet2DConditionModel.from_config("emilianJR/epiCRealism",subfolder="unet").to(device, dtype).load_state_dict(load_file(hf_hub_download("emilianJR/epiCRealism", "unet/diffusion_pytorch_model.safetensors"), device=device), strict=False)
39
 
40
  css="""
 
128
  return ''.join(random.choice(characters) for _ in range(length))
129
 
130
  @spaces.GPU(duration=65)
131
+ def Piper(positive,negative,motion):
132
  global last_motion
133
 
134
  pipe.unet.load_state_dict(load_file(hf_hub_download(repo, ckpt), device=device), strict=False)
 
141
  last_motion = motion
142
 
143
  return pipe(
144
+ positive,
145
  negative_prompt=negative,
146
  height=1024,
147
  width=576,
148
  num_inference_steps=step,
149
+ guidance_scale=1,
150
  num_frames=(fps*time)
151
  )
152
 
 
162
  _do.append(f'{p1}')
163
  posi = " ".join(_do)
164
 
165
+ out = Piper(posi,neg,pm["m"])
166
  export_to_gif(out.frames[0],name,fps=fps)
167
  return name
168
 
 
184
 
185
  return out
186
 
187
+ pipe = AnimateDiffPipeline.from_pretrained(base, vae=vae, torch_dtype=dtype).to(device)
188
  pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config, timestep_spacing="trailing", beta_schedule="linear")
189
  pipe.enable_free_init(method="butterworth", use_fast_sampling=False)
190