Spaces:
Running
on
Zero
Running
on
Zero
File size: 545 Bytes
453ed2e b248809 6914f7a b248809 453ed2e b248809 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import gradio as gr
from diffusers import StableDiffusionPipeline
import torch
# Model load
model_id = "runwayml/stable-diffusion-v1-5"
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
pipe = pipe.to("cuda" if torch.cuda.is_available() else "cpu")
# Function
def generate(prompt):
image = pipe(prompt).images[0]
return image
# Gradio UI
demo = gr.Interface(
fn=generate,
inputs=gr.Textbox(label="Enter your prompt"),
outputs=gr.Image(type="pil", label="Generated Image")
)
demo.launch() |