Manjushri commited on
Commit
83f0961
1 Parent(s): 2e24d26

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -19,11 +19,14 @@ pipe.enable_xformers_memory_efficient_attention()
19
  torch.cuda.empty_cache()
20
 
21
 
22
-
23
  def genie (prompt, negative_prompt, scale, steps, seed):
24
  torch.cuda.empty_cache()
25
  generator = torch.Generator(device=device).manual_seed(seed)
26
- int_image = pipe(prompt, negative_prompt=negative_prompt, num_inference_steps=steps, guidance_scale=scale, num_images_per_prompt=1, generator=generator, width=768, height=768, output_type="latent").images
 
 
 
 
27
  refiner = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-0.9", torch_dtype=torch.float16, variant="fp16", use_safetensors=True)
28
  refiner = refiner.to(device)
29
  refiner.enable_xformers_memory_efficient_attention()
@@ -31,4 +34,5 @@ def genie (prompt, negative_prompt, scale, steps, seed):
31
  image = refiner(prompt=prompt, image=int_image).images[0]
32
  return image
33
 
34
- gr.Interface(fn=genie, inputs=[gr.Textbox(label='What you want the AI to generate. 77 Token Limit.'), gr.Textbox(label='What you Do Not want the AI to generate.'), gr.Slider(1, 15, 10), gr.Slider(25, maximum=50, value=25, step=1), gr.Slider(minimum=1, step=1, maximum=999999999999999999, randomize=True)], outputs='image', title="Stable Diffusion XL .9 CPU", description="SDXL .9 CPU. <b>WARNING:</b> Extremely Slow. 65s/Iteration. Expect 25-50mins an image for 25-50 iterations respectively.", article = "Code Monkey: <a href=\"https://huggingface.co/Manjushri\">Manjushri</a>").launch(debug=True, max_threads=80)
 
 
19
  torch.cuda.empty_cache()
20
 
21
 
 
22
  def genie (prompt, negative_prompt, scale, steps, seed):
23
  torch.cuda.empty_cache()
24
  generator = torch.Generator(device=device).manual_seed(seed)
25
+ int_image = pipe(prompt, negative_prompt=negative_prompt, num_inference_steps=steps, guidance_scale=scale, num_images_per_prompt=1, generator=generator).images[0]
26
+ return int_image
27
+
28
+ def refiner(int_image):
29
+ torch.cuda.empty_cache()
30
  refiner = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-0.9", torch_dtype=torch.float16, variant="fp16", use_safetensors=True)
31
  refiner = refiner.to(device)
32
  refiner.enable_xformers_memory_efficient_attention()
 
34
  image = refiner(prompt=prompt, image=int_image).images[0]
35
  return image
36
 
37
+ gr.Interface(fn=genie, inputs=[gr.Textbox(label='What you want the AI to generate. 77 Token Limit.'), gr.Textbox(label='What you Do Not want the AI to generate.'), gr.Slider(1, 15, 10), gr.Slider(25, maximum=50, value=25, step=1), gr.Slider(minimum=1, step=1, maximum=999999999999999999, randomize=True)], outputs='image', title="Stable Diffusion XL .9 CPU", description="SDXL .9 CPU. <b>WARNING:</b> Extremely Slow. 65s/Iteration. Expect 25-50mins an image for 25-50 iterations respectively.", article = "Code Monkey: <a href=\"https://huggingface.co/Manjushri\">Manjushri</a>").launch(debug=True, max_threads=80)
38
+ gr.Interface(fn=refiner, inputs='image', outputs='image').launch(debug=True)