File size: 748 Bytes
a38a82a
ba0ed52
a38a82a
cf2baf5
a38a82a
 
 
 
 
cf2baf5
a38a82a
 
ba0ed52
a38a82a
 
ba0ed52
a38a82a
 
 
 
ba0ed52
a38a82a
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import streamlit as st
import torch
from diffusers import StableDiffusionXLPipeline

# Load the stable diffusion model
pipe = StableDiffusionXLPipeline.from_pretrained(
    "stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16
)
pipe = pipe.to("cuda")  # Move the model to GPU for faster processing

# Create a Streamlit app
st.title("Image Generation App")

# Add a text input for the prompt
prompt = st.text_input("Prompt", "a photo of an astronaut riding a horse on mars")

# Generate the image based on the prompt
if st.button("Generate Image"):
    # Use the model to generate the image
    image = pipe(prompt).images[0]

    # Display the generated image
    st.image(image, caption="Generated Image", use_column_width=True)