Testing3 / app.py
Geek7's picture
Create app.py
e79c85a verified
raw
history blame
1.11 kB
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()