Kvikontent commited on
Commit
e6514b2
1 Parent(s): c71ff3f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -23
app.py CHANGED
@@ -1,28 +1,17 @@
1
  import streamlit as st
2
- from diffusers import DiffusionPipeline
3
- import time
 
4
 
5
- # Load the DiffusionPipeline model
6
- pipeline = DiffusionPipeline.from_pretrained("stabilityai/sdxl-turbo")
7
 
8
- # Function to generate and display the image
9
- def generate_and_display_image(prompt):
10
- # Generate an image based on the prompt
11
- image = pipeline(prompt)
12
- # Display the generated image
13
- st.image(image, caption='Generated Image', use_column_width=True)
14
 
15
- # Main app code
16
- st.title('Real-time Image Generation App')
17
 
18
- # User input for the prompt with a placeholder
19
- prompt = st.text_input('Enter your prompt', value='', help='Enter your prompt here...')
20
-
21
- # Initialize the image display
22
- image_placeholder = st.empty()
23
-
24
- # Continuously generate and display the image based on the prompt
25
- while True:
26
- generate_and_display_image(prompt)
27
- # Sleep for a short duration to avoid excessive CPU usage
28
- time.sleep(1)
 
1
  import streamlit as st
2
+ from freeGPT import Client
3
+ from PIL import Image
4
+ from io import BytesIO
5
 
6
+ st.title("Stable Diffusion SDXL-Turbo")
 
7
 
8
+ model = st.sidebar.selectbox("Choose Model", ("prodia", "pollinations"))
 
 
 
 
 
9
 
10
+ prompt = st.text_input("Prompt", "")
 
11
 
12
+ try:
13
+ resp = Client.create_generation(model, prompt)
14
+ image = Image.open(BytesIO(resp))
15
+ st.image(image, caption="Generated Image")
16
+ except Exception as e:
17
+ st.error(str(e))