MohamedRashad commited on
Commit
5cf0d23
1 Parent(s): 8c0e5a7

chore: Refactor CUDA device usage in app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -117,8 +117,8 @@ def process(input_fg, prompt, input_undo_steps, image_width, image_height, seed,
117
  rng = torch.Generator(device="cuda").manual_seed(int(seed))
118
 
119
  fg = resize_and_center_crop(input_fg, image_width, image_height)
120
- concat_conds = numpy2pytorch([fg]).to(device="cuda", dtype=vae.dtype)
121
- concat_conds = vae.encode(torch.tensor(concat_conds)).latent_dist.mode() * vae.config.scaling_factor
122
 
123
  conds = encode_cropped_prompt_77tokens(prompt)
124
  unconds = encode_cropped_prompt_77tokens(n_prompt)
 
117
  rng = torch.Generator(device="cuda").manual_seed(int(seed))
118
 
119
  fg = resize_and_center_crop(input_fg, image_width, image_height)
120
+ concat_conds = numpy2pytorch([fg]).clone().detach().to(device="cuda", dtype=vae.dtype)
121
+ concat_conds = vae.encode(concat_conds).latent_dist.mode() * vae.config.scaling_factor
122
 
123
  conds = encode_cropped_prompt_77tokens(prompt)
124
  unconds = encode_cropped_prompt_77tokens(n_prompt)