Geek7 commited on
Commit
e79c85a
·
verified ·
1 Parent(s): c3581af

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from diffusers import StableDiffusionPipeline
3
+
4
+ # Define function to generate AI image
5
+ def generate_image(prompt, width, height):
6
+ pipeline = StableDiffusionPipeline.from_single_file(
7
+ "https://huggingface.co/Geek7/testing/blob/main/dreamshaper_8.safetensors"
8
+ )
9
+
10
+ # Generate image using the provided prompt
11
+ image = pipeline.run(prompt=prompt, width=width, height=height)
12
+
13
+ return image
14
+
15
+ # Main function for Streamlit app
16
+ def main():
17
+ st.title("AI Image Generator")
18
+
19
+ # Input fields
20
+ prompt = st.text_input("Enter prompt")
21
+ width = st.number_input("Width", min_value=1, step=1)
22
+ height = st.number_input("Height", min_value=1, step=1)
23
+
24
+ if st.button("Generate Image"):
25
+ # Check if prompt is provided
26
+ if prompt:
27
+ # Generate image
28
+ generated_image = generate_image(prompt, width, height)
29
+ # Display image
30
+ st.image(generated_image, caption='Generated Image', use_column_width=True)
31
+ else:
32
+ st.error("Please enter a prompt.")
33
+
34
+ if __name__ == "__main__":
35
+ main()