Manjushri commited on
Commit
46c84e7
1 Parent(s): 9535f4e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -3,19 +3,19 @@ import torch
3
  import numpy as np
4
  import modin.pandas as pd
5
  from PIL import Image
6
- #from diffusers import DiffusionPipeline #EulerDiscreteScheduler
7
-
8
- device = "cuda" if torch.cuda.is_available() else "cpu"
9
  from diffusers import DiffusionPipeline
10
 
 
11
  pipe = DiffusionPipeline.from_pretrained("prompthero/openjourney-v2", safety_checker=None)
12
- #scheduler = EulerDiscreteScheduler.from_pretrained("stabilityai/stable-diffusion-2-1", subfolder="scheduler", prediction_type="v_prediction")
13
- #pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2-1", safety_checker=None)
14
  pipe = pipe.to(device)
15
 
16
- def genie (prompt, negative_prompt, scale, steps, seed):
17
  generator = torch.Generator(device=device).manual_seed(seed)
18
- images = pipe(prompt, negative_prompt=negative_prompt, width=768, height=768, num_inference_steps=steps, guidance_scale=scale, num_images_per_prompt=1, generator=generator).images[0]
19
  return images
20
 
21
- 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, 25, 10), gr.Slider(1, maximum=20, value=10, step=1), gr.Slider(minimum=1, step=1, maximum=999999999999999999, randomize=True)], outputs='image', title="Stable Diffusion 2.1 CPU", description="SD 2.1 CPU. <b>WARNING:</b> Extremely Slow. 130s/Iteration. Expect 14-28mins an image for 10-20 iterations respectively.", article = "Code Monkey: <a href=\"https://huggingface.co/Manjushri\">Manjushri</a>").launch(debug=True, max_threads=True)
 
 
 
 
 
3
  import numpy as np
4
  import modin.pandas as pd
5
  from PIL import Image
 
 
 
6
  from diffusers import DiffusionPipeline
7
 
8
+ device = "cuda" if torch.cuda.is_available() else "cpu"
9
  pipe = DiffusionPipeline.from_pretrained("prompthero/openjourney-v2", safety_checker=None)
 
 
10
  pipe = pipe.to(device)
11
 
12
+ def genie (prompt, scale, steps, seed):
13
  generator = torch.Generator(device=device).manual_seed(seed)
14
+ images = pipe(prompt, width=768, height=768, num_inference_steps=steps, guidance_scale=scale, num_images_per_prompt=1, generator=generator).images[0]
15
  return images
16
 
17
+ gr.Interface(fn=genie, inputs=[gr.Textbox(label='What you want the AI to generate. 77 Token Limit.'),
18
+ gr.Slider(1, 25, 10), gr.Slider(1, maximum=20, value=10, step=1),
19
+ gr.Slider(minimum=1, step=1, maximum=999999999999999999, randomize=True)],
20
+ outputs='image', title="Stable Diffusion 2.1 CPU", description="SD 2.1 CPU. <b>WARNING:</b> Extremely Slow. 130s/Iteration. Expect 14-28mins an image for 10-20 iterations respectively.",
21
+ article = "Code Monkey: <a href=\"https://huggingface.co/Manjushri\">Manjushri</a>").launch(debug=True, max_threads=True)