Spaces:
Runtime error
Runtime error
Commit
·
f2241ff
1
Parent(s):
bd74121
Update app.py
Browse files
app.py
CHANGED
@@ -2,18 +2,32 @@ import streamlit as st
|
|
2 |
import requests
|
3 |
from PIL import Image
|
4 |
from io import BytesIO
|
|
|
5 |
|
6 |
st.title('CreativeAI')
|
|
|
7 |
|
8 |
-
|
|
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
params = {'prompt': prompt}
|
13 |
-
response = requests.get(url, params=params)
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
import requests
|
3 |
from PIL import Image
|
4 |
from io import BytesIO
|
5 |
+
import time
|
6 |
|
7 |
st.title('CreativeAI')
|
8 |
+
st.description('This is AI image generation based on KVIImager 2.0 API by KVI Kontent')
|
9 |
|
10 |
+
# Pre-defined prompts
|
11 |
+
example_prompts = ["A cat sitting on a keyboard", "A futuristic cityscape", "Magical forest at night"]
|
12 |
|
13 |
+
# Select box for choosing examples
|
14 |
+
selected_prompt = st.selectbox("Select an example prompt", example_prompts)
|
|
|
|
|
15 |
|
16 |
+
# Input field for custom prompt
|
17 |
+
custom_prompt = st.text_input("Enter your own prompt")
|
18 |
+
|
19 |
+
prompt = selected_prompt if not custom_prompt else custom_prompt
|
20 |
+
|
21 |
+
if st.button('Generate Image'):
|
22 |
+
if prompt:
|
23 |
+
with st.spinner('Generating your image...'):
|
24 |
+
time.sleep(3) # Simulate some processing time
|
25 |
+
url = 'https://ee1f-217-71-237-228.ngrok-free.app/generate_image'
|
26 |
+
params = {'prompt': prompt}
|
27 |
+
response = requests.get(url, params=params)
|
28 |
+
|
29 |
+
if response.status_code == 200:
|
30 |
+
image = Image.open(BytesIO(response.content))
|
31 |
+
st.image(image, caption='Generated Image', use_column_width=True)
|
32 |
+
else:
|
33 |
+
st.error("Failed to generate the image. Please try again.")
|