File size: 1,105 Bytes
e79c85a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
30
31
32
33
34
35
import streamlit as st
from diffusers import StableDiffusionPipeline

# Define function to generate AI image
def generate_image(prompt, width, height):
    pipeline = StableDiffusionPipeline.from_single_file(
        "https://huggingface.co/Geek7/testing/blob/main/dreamshaper_8.safetensors"
    )

    # Generate image using the provided prompt
    image = pipeline.run(prompt=prompt, width=width, height=height)

    return image

# Main function for Streamlit app
def main():
    st.title("AI Image Generator")
    
    # Input fields
    prompt = st.text_input("Enter prompt")
    width = st.number_input("Width", min_value=1, step=1)
    height = st.number_input("Height", min_value=1, step=1)

    if st.button("Generate Image"):
        # Check if prompt is provided
        if prompt:
            # Generate image
            generated_image = generate_image(prompt, width, height)
            # Display image
            st.image(generated_image, caption='Generated Image', use_column_width=True)
        else:
            st.error("Please enter a prompt.")

if __name__ == "__main__":
    main()