Linoy Tsaban commited on
Commit
dcf7f47
1 Parent(s): 4809200

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -10,6 +10,7 @@ from tokenflow_utils import *
10
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
11
  model_id = "stabilityai/stable-diffusion-2-1-base"
12
 
 
13
  scheduler = DDIMScheduler.from_pretrained(model_id, subfolder="scheduler")
14
  vae = AutoencoderKL.from_pretrained(model_id, subfolder="vae", revision="fp16",
15
  torch_dtype=torch.float16).to(device)
@@ -19,6 +20,10 @@ text_encoder = CLIPTextModel.from_pretrained(model_id, subfolder="text_encoder",
19
  unet = UNet2DConditionModel.from_pretrained(model_id, subfolder="unet", revision="fp16",
20
  torch_dtype=torch.float16).to(device)
21
 
 
 
 
 
22
  def randomize_seed_fn():
23
  seed = random.randint(0, np.iinfo(np.int32).max)
24
  return seed
@@ -200,7 +205,7 @@ def edit_with_pnp(input_video,
200
  seed_everything(seed)
201
 
202
 
203
- editor = TokenFlow(config=config, frames=frames.value, inverted_latents=inverted_latents.value)
204
  edited_frames = editor.edit_video()
205
 
206
  save_video(edited_frames, 'tokenflow_PnP_fps_30.mp4', fps=n_fps)
 
10
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
11
  model_id = "stabilityai/stable-diffusion-2-1-base"
12
 
13
+ # components for the Preprocessor
14
  scheduler = DDIMScheduler.from_pretrained(model_id, subfolder="scheduler")
15
  vae = AutoencoderKL.from_pretrained(model_id, subfolder="vae", revision="fp16",
16
  torch_dtype=torch.float16).to(device)
 
20
  unet = UNet2DConditionModel.from_pretrained(model_id, subfolder="unet", revision="fp16",
21
  torch_dtype=torch.float16).to(device)
22
 
23
+ # pipe for TokenFlow
24
+ pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16).to("cuda")
25
+ pipe.enable_xformers_memory_efficient_attention()
26
+
27
  def randomize_seed_fn():
28
  seed = random.randint(0, np.iinfo(np.int32).max)
29
  return seed
 
205
  seed_everything(seed)
206
 
207
 
208
+ editor = TokenFlow(config=config,pipe=pipe, frames=frames.value, inverted_latents=inverted_latents.value)
209
  edited_frames = editor.edit_video()
210
 
211
  save_video(edited_frames, 'tokenflow_PnP_fps_30.mp4', fps=n_fps)