Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,17 @@
|
|
| 1 |
import torch
|
| 2 |
from diffusers import StableDiffusionPipeline
|
|
|
|
| 3 |
|
| 4 |
-
|
| 5 |
-
)
|
| 6 |
-
pipe = pipe.to("cpu")
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
image
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import torch
|
| 2 |
from diffusers import StableDiffusionPipeline
|
| 3 |
+
import gradio as gr
|
| 4 |
|
| 5 |
+
# Load model on CPU (use torch_dtype=torch.float32 for CPU compatibility)
|
| 6 |
+
pipe = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", torch_dtype=torch.float32).to("cpu")
|
|
|
|
| 7 |
|
| 8 |
+
# Function to generate image
|
| 9 |
+
def generate_image(prompt):
|
| 10 |
+
image = pipe(prompt).images[0]
|
| 11 |
+
return image
|
| 12 |
+
|
| 13 |
+
# Gradio interface
|
| 14 |
+
iface = gr.Interface(fn=generate_image, inputs="text", outputs="image", title="Stable Diffusion Image Generator")
|
| 15 |
+
|
| 16 |
+
# Launch app
|
| 17 |
+
iface.launch()
|