Spaces:
Sleeping
Sleeping
File size: 780 Bytes
32e29ce 10bd232 32e29ce ac9823f 32e29ce 162eb52 32e29ce de28523 32e29ce 10bd232 32e29ce 10bd232 32e29ce |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import streamlit as st
from diffusers import DiffusionPipeline
import torch
from PIL import Image
# Streamlit app title
st.title("Stable Diffusion Image Generator")
# Load the diffusion pipeline
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2-1-base", torch_dtype=torch.float32)
pipe.to("cpu") # Use CPU for inference
# Get user input (prompt)
prompt = st.text_input("What do you want to see?", "A beautiful landscape")
# Button to generate image
if st.button('Generate Image'):
with st.spinner('Generating...'):
# Generate image
image = pipe(prompt).images[0]
# Display image in Streamlit
st.image(image, caption="Generated Image", use_column_width=True)
st.success("Image generated successfully!")
|