Spaces:
Runtime error
Runtime error
Commit
·
09bc5a3
1
Parent(s):
bdbd893
Update app.py
Browse files
app.py
CHANGED
@@ -1,21 +1,25 @@
|
|
|
|
1 |
import torch
|
2 |
-
from diffusers import StableDiffusionPipeline
|
3 |
-
from PIL import Image
|
4 |
-
import io
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
8 |
pipe = pipe.to("cuda")
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
-
|
15 |
-
prompt = input("Enter a prompt: ")
|
16 |
|
17 |
-
|
18 |
-
generated_image = generate_image(prompt)
|
19 |
|
20 |
-
|
21 |
-
generated_image.show()
|
|
|
1 |
+
from diffusers import StableDiffusionPipeline, EulerDiscreteScheduler
|
2 |
import torch
|
|
|
|
|
|
|
3 |
|
4 |
+
model_id = "stabilityai/stable-diffusion-2"
|
5 |
+
|
6 |
+
# Use the Euler scheduler here instead
|
7 |
+
scheduler = EulerDiscreteScheduler.from_pretrained(model_id, subfolder="scheduler")
|
8 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_id, scheduler=scheduler, revision="fp16", torch_dtype=torch.float16)
|
9 |
pipe = pipe.to("cuda")
|
10 |
|
11 |
+
prompt = "realistic photo of 3d cartoon style of a cat in a space suit with milky way background"
|
12 |
+
|
13 |
+
def txt2img(prompt):
|
14 |
+
|
15 |
+
image = pipe(prompt, height=768, width=768, guidance_scale = 10).images[0]
|
16 |
+
|
17 |
+
image.save("sd_image.png")
|
18 |
+
|
19 |
+
return image
|
20 |
|
21 |
+
txt2img(prompt)
|
|
|
22 |
|
23 |
+
import gradio as gr
|
|
|
24 |
|
25 |
+
gr.Interface(txt2img, gr.Text(), gr.Image(), title = 'Stable Diffusion 2.0 Colab with Gradio UI').launch(share = True, debug = True)
|
|