Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,9 +2,10 @@ import gradio as gr
|
|
| 2 |
from diffusers import StableDiffusionPipeline
|
| 3 |
import torch
|
| 4 |
|
|
|
|
| 5 |
model_id = "CompVis/stable-diffusion-v1-4"
|
| 6 |
-
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.
|
| 7 |
-
pipe = pipe.to("cuda")
|
| 8 |
|
| 9 |
def generate_image(prompt):
|
| 10 |
image = pipe(prompt).images[0]
|
|
@@ -12,12 +13,10 @@ def generate_image(prompt):
|
|
| 12 |
|
| 13 |
iface = gr.Interface(
|
| 14 |
fn=generate_image,
|
| 15 |
-
inputs=gr.Textbox(label="
|
| 16 |
outputs=gr.Image(type="pil", label="Generated Image"),
|
| 17 |
-
title="Speech2Image Generator (
|
| 18 |
theme="default",
|
| 19 |
)
|
| 20 |
|
| 21 |
iface.launch()
|
| 22 |
-
|
| 23 |
-
|
|
|
|
| 2 |
from diffusers import StableDiffusionPipeline
|
| 3 |
import torch
|
| 4 |
|
| 5 |
+
# Use a compatible model ID
|
| 6 |
model_id = "CompVis/stable-diffusion-v1-4"
|
| 7 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float32) # Use float32 if float16 causes issues
|
| 8 |
+
pipe = pipe.to("cuda") # Ensure your environment supports CUDA; if not, remove this line
|
| 9 |
|
| 10 |
def generate_image(prompt):
|
| 11 |
image = pipe(prompt).images[0]
|
|
|
|
| 13 |
|
| 14 |
iface = gr.Interface(
|
| 15 |
fn=generate_image,
|
| 16 |
+
inputs=gr.Textbox(label="Prompt", placeholder="Enter your prompt here..."),
|
| 17 |
outputs=gr.Image(type="pil", label="Generated Image"),
|
| 18 |
+
title="Speech2Image Generator (FastAPI Powered)",
|
| 19 |
theme="default",
|
| 20 |
)
|
| 21 |
|
| 22 |
iface.launch()
|
|
|
|
|
|