Spaces:
Runtime error
Runtime error
bonosa
commited on
Commit
·
b7cca57
1
Parent(s):
cbf0a98
v3
Browse files- app.py +16 -0
- requirements.txt +6 -0
app.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from diffusers import StableDiffusionPipeline, EulerDiscreteScheduler
|
3 |
+
import torch
|
4 |
+
|
5 |
+
model_id = "stabilityai/stable-diffusion-2-1-base"
|
6 |
+
|
7 |
+
scheduler = EulerDiscreteScheduler.from_pretrained(model_id, subfolder="scheduler")
|
8 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_id, scheduler=scheduler, torch_dtype=torch.float16)
|
9 |
+
pipe = pipe.cpu() # Use CPU instead of GPU
|
10 |
+
|
11 |
+
def generate_image(prompt):
|
12 |
+
image = pipe(prompt).images[0]
|
13 |
+
return image # Gradio will handle the conversion to an image
|
14 |
+
|
15 |
+
iface = gr.Interface(fn=generate_image, inputs=gr.inputs.Textbox(), outputs='image')
|
16 |
+
iface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
transformers
|
2 |
+
diffusers
|
3 |
+
torch
|
4 |
+
gradio
|
5 |
+
pillow
|
6 |
+
accelerate
|