Spaces:
Runtime error
Runtime error
Commit
·
e6514b2
1
Parent(s):
c71ff3f
Update app.py
Browse files
app.py
CHANGED
@@ -1,28 +1,17 @@
|
|
1 |
import streamlit as st
|
2 |
-
from
|
3 |
-
import
|
|
|
4 |
|
5 |
-
|
6 |
-
pipeline = DiffusionPipeline.from_pretrained("stabilityai/sdxl-turbo")
|
7 |
|
8 |
-
|
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 |
-
|
16 |
-
st.title('Real-time Image Generation App')
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
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))
|
|
|
|
|
|
|
|
|
|