File size: 567 Bytes
361b426 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
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") |