Spaces:
Running
on
T4
Running
on
T4
Update app.py
Browse files
app.py
CHANGED
@@ -1,25 +1,22 @@
|
|
1 |
-
from stable_diffusion_tf.stable_diffusion import Text2Image
|
2 |
-
from PIL import Image
|
3 |
import gradio as gr
|
|
|
|
|
4 |
import modin.pandas as pd
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
jit_compile=False)
|
10 |
-
|
11 |
-
def txt2img(prompt, guide, steps, Temp):
|
12 |
-
img = generator.generate(prompt,
|
13 |
-
num_steps=steps,
|
14 |
-
unconditional_guidance_scale=guide,
|
15 |
-
temperature=Temp,
|
16 |
-
batch_size=1)
|
17 |
-
image=Image.fromarray(img[0])
|
18 |
-
return image
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import torch
|
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, num_inference_steps=steps, guidance_scale=scale, 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, maximum=15, value=10, step=.25),
|
19 |
+
gr.Slider(1, maximum=50, value=25, step=1),
|
20 |
+
gr.Slider(minimum=1, step=1, maximum=987654321, randomize=True)],
|
21 |
+
outputs='image', title="OpenJourney V2 CPU", description="OJ V2 CPU. <b>WARNING:</b> Extremely Slow. 35s/Iteration. Expect 8-16mins an image for 15-30 iterations respectively. 50 iterations takes ~28mins.",
|
22 |
+
article = "Code Monkey: <a href=\"https://huggingface.co/Manjushri\">Manjushri</a>").launch(debug=True, max_threads=True)
|