i2t-demo / app.py
Arunaabh's picture
Create app.py
361b426 verified
raw
history blame
567 Bytes
import streamlit as st
from diffusers import StableDiffusionPipeline
import torch
# Load the DALL-E model and tokenizer
model_id = "runwayml/stable-diffusion-v1-5"
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
# Streamlit app
st.title("Image generation demo")
prompt = st.text_input("Enter a text prompt:", "a cat in the rain")
if st.button("Generate Image"):
# Generate image from the prompt
image = pipe(prompt).images[0]
# Display the image
st.image(image, caption="Generated Image", channels="RGB")