Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,25 +2,22 @@ import gradio as gr
|
|
| 2 |
from diffusers import DiffusionPipeline
|
| 3 |
import torch
|
| 4 |
|
| 5 |
-
# Load the
|
| 6 |
pipeline = DiffusionPipeline.from_pretrained("openai/shap-e", torch_dtype=torch.float16)
|
| 7 |
pipeline = pipeline.to("cuda" if torch.cuda.is_available() else "cpu")
|
| 8 |
|
| 9 |
def generate_image(prompt):
|
| 10 |
-
# Generate
|
| 11 |
output = pipeline(prompt)
|
| 12 |
return output.images[0]
|
| 13 |
|
| 14 |
-
# Gradio interface
|
| 15 |
-
title = "Shap-E Model Demo"
|
| 16 |
-
description = "Generate images from text prompts using the Shap-E diffusion model."
|
| 17 |
-
|
| 18 |
interface = gr.Interface(
|
| 19 |
fn=generate_image,
|
| 20 |
inputs=gr.Textbox(label="Prompt"),
|
| 21 |
outputs=gr.Image(label="Generated Image"),
|
| 22 |
-
title=
|
| 23 |
-
description=
|
| 24 |
)
|
| 25 |
|
| 26 |
if __name__ == "__main__":
|
|
|
|
| 2 |
from diffusers import DiffusionPipeline
|
| 3 |
import torch
|
| 4 |
|
| 5 |
+
# Load the pipeline
|
| 6 |
pipeline = DiffusionPipeline.from_pretrained("openai/shap-e", torch_dtype=torch.float16)
|
| 7 |
pipeline = pipeline.to("cuda" if torch.cuda.is_available() else "cpu")
|
| 8 |
|
| 9 |
def generate_image(prompt):
|
| 10 |
+
# Generate image using the prompt
|
| 11 |
output = pipeline(prompt)
|
| 12 |
return output.images[0]
|
| 13 |
|
| 14 |
+
# Set up Gradio interface
|
|
|
|
|
|
|
|
|
|
| 15 |
interface = gr.Interface(
|
| 16 |
fn=generate_image,
|
| 17 |
inputs=gr.Textbox(label="Prompt"),
|
| 18 |
outputs=gr.Image(label="Generated Image"),
|
| 19 |
+
title="Shap-E Image Generation",
|
| 20 |
+
description="Generate images from text prompts using the Shap-E diffusion model."
|
| 21 |
)
|
| 22 |
|
| 23 |
if __name__ == "__main__":
|