Manjushri commited on
Commit
15a23dd
1 Parent(s): 700b834

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -7,13 +7,17 @@ from diffusers import DiffusionPipeline, StableDiffusionLatentUpscalePipeline
7
 
8
  device = 'cuda' if torch.cuda.is_available() else 'cpu'
9
  torch.cuda.max_memory_allocated(device=device)
10
- refiner = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-1.0", use_safetensors=True, torch_dtype=torch.float16, variant="fp16") if torch.cuda.is_available() else DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-1.0")
11
- refiner.enable_xformers_memory_efficient_attention()
12
- refiner = refiner.to(device)
13
  torch.cuda.empty_cache()
14
 
15
  def genie (Model, Prompt, negative_prompt, height, width, scale, steps, seed, upscale, high_noise_frac):
16
  generator = np.random.seed(0) if seed == 0 else torch.manual_seed(seed)
 
 
 
 
 
 
 
17
  if Model == "PhotoReal":
18
  pipe = DiffusionPipeline.from_pretrained("circulus/canvers-real-v3.8.1", torch_dtype=torch.float16, safety_checker=None) if torch.cuda.is_available() else DiffusionPipeline.from_pretrained("circulus/canvers-real-v3.8.1")
19
  pipe = pipe.to(device)
 
7
 
8
  device = 'cuda' if torch.cuda.is_available() else 'cpu'
9
  torch.cuda.max_memory_allocated(device=device)
 
 
 
10
  torch.cuda.empty_cache()
11
 
12
  def genie (Model, Prompt, negative_prompt, height, width, scale, steps, seed, upscale, high_noise_frac):
13
  generator = np.random.seed(0) if seed == 0 else torch.manual_seed(seed)
14
+
15
+ if upscale == "Yes":
16
+ refiner = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-1.0", use_safetensors=True, torch_dtype=torch.float16, variant="fp16") if torch.cuda.is_available() else DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-1.0")
17
+ refiner.enable_xformers_memory_efficient_attention()
18
+ refiner = refiner.to(device)
19
+ torch.cuda.empty_cache()
20
+
21
  if Model == "PhotoReal":
22
  pipe = DiffusionPipeline.from_pretrained("circulus/canvers-real-v3.8.1", torch_dtype=torch.float16, safety_checker=None) if torch.cuda.is_available() else DiffusionPipeline.from_pretrained("circulus/canvers-real-v3.8.1")
23
  pipe = pipe.to(device)