Manjushri commited on
Commit
7b932b1
1 Parent(s): 139a1c6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -12,6 +12,7 @@ login(token=os.environ.get('HF_KEY'))
12
  device = "cuda" if torch.cuda.is_available() else "cpu"
13
 
14
  torch.cuda.max_memory_allocated(device=device)
 
15
  pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-0.9", torch_dtype=torch.float16, variant="fp16", use_safetensors=True)
16
  pipe = pipe.to(device)
17
  pipe.enable_xformers_memory_efficient_attention()
@@ -27,10 +28,13 @@ def genie (prompt, negative_prompt, scale, steps, seed):
27
  torch.cuda.empty_cache()
28
  generator = torch.Generator(device=device).manual_seed(seed)
29
  int_image = pipe(prompt, negative_prompt=negative_prompt, num_inference_steps=steps, guidance_scale=scale, num_images_per_prompt=1, generator=generator).images[0]
30
- image = refiner(prompt=prompt, image=int_image).images[0]
31
- return image
32
 
 
 
 
 
33
 
34
 
35
- 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)
36
- gr.Interface(fn=refiner, inputs='image', outputs='image').launch(debug=True)
 
12
  device = "cuda" if torch.cuda.is_available() else "cpu"
13
 
14
  torch.cuda.max_memory_allocated(device=device)
15
+
16
  pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-0.9", torch_dtype=torch.float16, variant="fp16", use_safetensors=True)
17
  pipe = pipe.to(device)
18
  pipe.enable_xformers_memory_efficient_attention()
 
28
  torch.cuda.empty_cache()
29
  generator = torch.Generator(device=device).manual_seed(seed)
30
  int_image = pipe(prompt, negative_prompt=negative_prompt, num_inference_steps=steps, guidance_scale=scale, num_images_per_prompt=1, generator=generator).images[0]
31
+ return int_image
 
32
 
33
+ def refiner (prompt, negative_prompt, scale, steps, seed):
34
+ int_image = genie(prompt, negative_prompt, scale, steps, seed)
35
+ image = refiner(prompt=prompt, image=int_image).images[0]
36
+ return image
37
 
38
 
39
+ gr.Interface(fn=refiner, 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)
40
+ #gr.Interface(fn=refiner, inputs='image', outputs='image').launch(debug=True)