Manjushri commited on
Commit
6c562f3
1 Parent(s): 35554ee

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -14,19 +14,19 @@ pipe.enable_xformers_memory_efficient_attention()
14
  pipe = pipe.to(device)
15
  torch.cuda.empty_cache()
16
 
17
- #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")
18
- #refiner.enable_xformers_memory_efficient_attention()
19
- #refiner = refiner.to(device)
20
- #torch.cuda.empty_cache()
21
 
22
  def genie (Prompt, negative_prompt, height, width, scale, steps, seed, upscale):
23
  generator = np.random.seed(0) if seed == 0 else torch.manual_seed(seed)
24
  torch.cuda.empty_cache()
25
- int_image = pipe(prompt=Prompt, negative_prompt=negative_prompt, num_inference_steps=steps, guidance_scale=scale, width=width, height=height, ).images[0] #output_type="latent"
 
 
26
  torch.cuda.empty_cache()
27
- #image = refiner(Prompt, negative_prompt=negative_prompt, image=int_image, denoising_start=.99).images[0]
28
- #torch.cuda.empty_cache()
29
- return int_image
30
 
31
  gr.Interface(fn=genie, inputs=[gr.Textbox(label='What you want the AI to generate. 77 Token Limit.'),
32
  gr.Textbox(label='What you Do Not want the AI to generate. 77 Token Limit'),
 
14
  pipe = pipe.to(device)
15
  torch.cuda.empty_cache()
16
 
17
+ 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")
18
+ refiner.enable_xformers_memory_efficient_attention()
19
+ refiner = refiner.to(device)
20
+ torch.cuda.empty_cache()
21
 
22
  def genie (Prompt, negative_prompt, height, width, scale, steps, seed, upscale):
23
  generator = np.random.seed(0) if seed == 0 else torch.manual_seed(seed)
24
  torch.cuda.empty_cache()
25
+ int_image = pipe(prompt=Prompt, negative_prompt=negative_prompt, num_inference_steps=steps, guidance_scale=scale, width=width, height=height, output_type="latent").images #
26
+ torch.cuda.empty_cache()
27
+ image = refiner(Prompt, negative_prompt=negative_prompt, image=int_image, denoising_start=.99).images[0]
28
  torch.cuda.empty_cache()
29
+ return image
 
 
30
 
31
  gr.Interface(fn=genie, inputs=[gr.Textbox(label='What you want the AI to generate. 77 Token Limit.'),
32
  gr.Textbox(label='What you Do Not want the AI to generate. 77 Token Limit'),