File size: 770 Bytes
a90540d
3980707
9d74bc1
a90540d
3980707
 
 
 
 
 
 
a90540d
3980707
 
 
9d74bc1
3980707
 
 
 
 
 
 
5a6a7e8
3980707
 
 
 
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
27
28
29
import streamlit as st
from diffusers import DiffusionPipeline
import torch

# Load the pipeline
pipe = DiffusionPipeline.from_pretrained(
    "stabilityai/stable-diffusion-xl-base-1.0", 
    torch_dtype=torch.float16, 
    use_safetensors=True, 
    variant="fp16"
)

# Streamlit UI
st.title("Stable Diffusion Image Generator")
prompt = st.text_area('Enter a prompt to generate an image...')

if prompt:  # Ensure the prompt is not empty
    with st.spinner("Generating image..."):
        out = pipe(
            prompt,
            height=1024,
            width=1024,
            guidance_scale=3.5,
            num_inference_steps=50 
        ).images[0]
    
    # Display the image in Streamlit
    st.image(out, caption="Generated Image", use_column_width=True)