File size: 530 Bytes
3f8a55d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import streamlit as st
from diffusers import StableDiffusionPipeline
import torch

# Load the model
model_id = "runwayml/stable-diffusion-v1-5"
pipe = StableDiffusionPipeline.from_pretrained(model_id)
pipe = pipe.to("cuda")  # Runs on Hugging Face's GPU servers



# Streamlit UI

st.title("Free AI Image Generator")

prompt = st.text_input("Describe your image...")



if prompt:

    with st.spinner("Generating..."):

        image = pipe(prompt).images[0]

        st.image(image, caption=prompt, use_column_width=True)