Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,13 +1,10 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
|
| 3 |
from diffusers import DiffusionPipeline
|
| 4 |
|
| 5 |
-
# Load the pre-trained model
|
| 6 |
-
model_id = "stabilityai/sdxl-turbo"
|
| 7 |
-
model_path = hf_hub_download(repo_id=model_id, repo_type="model")
|
| 8 |
pipe = DiffusionPipeline.from_pretrained(model_path, torch_dtype=torch.float32)
|
| 9 |
|
| 10 |
-
|
| 11 |
def generate_image(prompt):
|
| 12 |
# Run the diffusion model to generate an image
|
| 13 |
image = pipe(prompt, num_inference_steps=50, guidance_scale=7.5)
|
|
@@ -18,7 +15,8 @@ gr_interface = gr.Interface(
|
|
| 18 |
inputs="text",
|
| 19 |
outputs="image",
|
| 20 |
title="Real-time Image Generation with Diffusion",
|
| 21 |
-
description="Enter a prompt to generate an image"
|
|
|
|
| 22 |
)
|
| 23 |
|
| 24 |
# Launch the Gradio app
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import spaces
|
| 3 |
from diffusers import DiffusionPipeline
|
| 4 |
|
|
|
|
|
|
|
|
|
|
| 5 |
pipe = DiffusionPipeline.from_pretrained(model_path, torch_dtype=torch.float32)
|
| 6 |
|
| 7 |
+
@spaces.GPU(duration=120)
|
| 8 |
def generate_image(prompt):
|
| 9 |
# Run the diffusion model to generate an image
|
| 10 |
image = pipe(prompt, num_inference_steps=50, guidance_scale=7.5)
|
|
|
|
| 15 |
inputs="text",
|
| 16 |
outputs="image",
|
| 17 |
title="Real-time Image Generation with Diffusion",
|
| 18 |
+
description="Enter a prompt to generate an image",
|
| 19 |
+
theme="soft"
|
| 20 |
)
|
| 21 |
|
| 22 |
# Launch the Gradio app
|