Yaron Koresh commited on
Commit
8d20a09
·
verified ·
1 Parent(s): 8e30a8b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -7
app.py CHANGED
@@ -18,19 +18,29 @@ from safetensors.torch import load_file
18
  device = "cuda" if torch.cuda.is_available() else "cpu"
19
  dtype = torch.float16
20
 
21
- step = 4
22
- model_id = "black-forest-labs/FLUX.1-dev"
 
 
23
 
24
- adapter = MotionAdapter.from_pretrained("guoyww/animatediff-motion-adapter-v1-5-2")
 
25
 
26
  pipe = AnimateDiffPipeline.from_pretrained(
27
- model_id, motion_adapter=adapter
28
- ,token=os.getenv("hf_token")
 
29
  )
 
30
  scheduler = DDIMScheduler.from_pretrained(
31
- model_id, subfolder="scheduler", clip_sample=False, timestep_spacing="linspace", steps_offset=1
32
- ,token=os.getenv("hf_token")
 
 
 
 
33
  )
 
34
  pipe.scheduler = scheduler
35
  pipe.enable_vae_slicing()
36
  pipe.enable_vae_tiling()
 
18
  device = "cuda" if torch.cuda.is_available() else "cpu"
19
  dtype = torch.float16
20
 
21
+ step = 2
22
+ repo = "ByteDance/AnimateDiff-Lightning"
23
+ ckpt = f"animatediff_lightning_{step}step_diffusers.safetensors"
24
+ model_id = "black-forest-labs/FLUX.1-schnell"
25
 
26
+ adapter = MotionAdapter().to(device, dtype)
27
+ adapter.load_state_dict(load_file(hf_hub_download(repo ,ckpt), device=device))
28
 
29
  pipe = AnimateDiffPipeline.from_pretrained(
30
+ model_id,
31
+ motion_adapter=adapter,
32
+ token=os.getenv("hf_token")
33
  )
34
+
35
  scheduler = DDIMScheduler.from_pretrained(
36
+ model_id,
37
+ subfolder="scheduler",
38
+ clip_sample=False,
39
+ timestep_spacing="linspace",
40
+ steps_offset=1,
41
+ token=os.getenv("hf_token")
42
  )
43
+
44
  pipe.scheduler = scheduler
45
  pipe.enable_vae_slicing()
46
  pipe.enable_vae_tiling()