Spaces:
Sleeping
Sleeping
Commit ·
c17fbdc
1
Parent(s): 5d123f9
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,29 +1,30 @@
|
|
| 1 |
# app.py
|
| 2 |
|
| 3 |
import streamlit as st
|
| 4 |
-
|
| 5 |
|
| 6 |
-
|
| 7 |
|
| 8 |
-
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
|
| 11 |
-
clipdrop_api_key = st.text_input("Enter your ClipDrop API Key", type="password")
|
| 12 |
-
stability_api_key = st.text_input("Enter your Stability API Key", type="password")
|
| 13 |
-
replicate_api_token = st.text_input("Enter your Replicate API Token", type="password")
|
| 14 |
|
| 15 |
-
|
| 16 |
-
if text_prompt and clipdrop_api_key and stability_api_key and replicate_api_token:
|
| 17 |
-
final_img = main.generate_and_upscale_image(
|
| 18 |
-
text_prompt, clipdrop_api_key, stability_api_key, replicate_api_token
|
| 19 |
-
)
|
| 20 |
-
|
| 21 |
-
if final_img is not None:
|
| 22 |
-
st.image(final_img)
|
| 23 |
-
else:
|
| 24 |
-
st.write("An error occurred. Please try again.")
|
| 25 |
-
else:
|
| 26 |
-
st.write("Please enter all required fields.")
|
| 27 |
|
| 28 |
-
if
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# app.py
|
| 2 |
|
| 3 |
import streamlit as st
|
| 4 |
+
from main import generate_and_upscale_image
|
| 5 |
|
| 6 |
+
st.title('Text to Image Generator and Upscaler')
|
| 7 |
|
| 8 |
+
clipdrop_api_key = st.secrets['CLIPDROP_API_KEY']
|
| 9 |
+
stability_api_key = st.secrets['STABILITY_API_KEY']
|
| 10 |
+
replicate_api_token = st.secrets['REPLICATE_API_TOKEN']
|
| 11 |
|
| 12 |
+
download_path = st.text_input('Enter the download path', value='')
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
+
text_prompt = st.text_input('Enter your text prompt', value='')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
+
if st.button('Generate and Upscale Image'):
|
| 17 |
+
if text_prompt and download_path:
|
| 18 |
+
try:
|
| 19 |
+
generate_and_upscale_image(
|
| 20 |
+
text_prompt,
|
| 21 |
+
clipdrop_api_key,
|
| 22 |
+
stability_api_key,
|
| 23 |
+
replicate_api_token,
|
| 24 |
+
download_path
|
| 25 |
+
)
|
| 26 |
+
st.success('Image saved successfully at the specified download path.')
|
| 27 |
+
except Exception as e:
|
| 28 |
+
st.error(f"An error occurred: {e}")
|
| 29 |
+
else:
|
| 30 |
+
st.error('Please ensure all fields are filled.')
|