Text-Image / app.py
shashidharak99's picture
Create app.py
4483238 verified
Raw
History Blame Contribute Delete
516 Bytes
import gradio as gr
import torch
from diffusers import StableDiffusionPipeline
model_id = "runwayml/stable-diffusion-v1-5"
pipe = StableDiffusionPipeline.from_pretrained(
model_id,
torch_dtype=torch.float32
)
pipe = pipe.to("cpu") # important for free Spaces
def generate(prompt):
image = pipe(prompt).images[0]
return image
demo = gr.Interface(
fn=generate,
inputs=gr.Textbox(placeholder="Enter your prompt..."),
outputs="image",
title="Text to Image Generator"
)
demo.launch()