Manjushri commited on
Commit
2cf2468
·
verified ·
1 Parent(s): 8cee0dc

Update app.py

Browse files

Making memory work

Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -28,11 +28,11 @@ def genie (Model, Prompt, negative_prompt, height, width, scale, steps, seed, re
28
  torch.cuda.empty_cache()
29
 
30
  if upscale == "Yes":
31
- upscaler = DiffusionPipeline.from_pretrained("stabilityai/sd-x2-latent-upscaler", torch_dtype=torch.float16, use_safetensors=True)
32
- upscaler.enable_xformers_memory_efficient_attention()
33
- upscaler = upscaler.to(device)
34
  torch.cuda.empty_cache()
35
- upscaled = upscaler(prompt=Prompt, negative_prompt=negative_prompt, image=image, num_inference_steps=15, guidance_scale=0).images[0]
36
  torch.cuda.empty_cache()
37
  return upscaled
38
  else:
 
28
  torch.cuda.empty_cache()
29
 
30
  if upscale == "Yes":
31
+ refiner = DiffusionPipeline.from_pretrained("stabilityai/sd-x2-latent-upscaler", torch_dtype=torch.float16, use_safetensors=True)
32
+ refiner.enable_xformers_memory_efficient_attention()
33
+ refiner = upscaler.to(device)
34
  torch.cuda.empty_cache()
35
+ upscaled = refiner(prompt=Prompt, negative_prompt=negative_prompt, image=image, num_inference_steps=15, guidance_scale=0).images[0]
36
  torch.cuda.empty_cache()
37
  return upscaled
38
  else: