Spaces:
Sleeping
Sleeping
Commit
·
2a74599
1
Parent(s):
315e367
Update app.py
Browse files
app.py
CHANGED
@@ -1,30 +1,21 @@
|
|
1 |
# app.py
|
2 |
|
3 |
import streamlit as st
|
|
|
4 |
from main import generate_and_upscale_image
|
5 |
-
import os
|
6 |
|
7 |
-
def
|
|
|
|
|
|
|
8 |
|
9 |
-
|
10 |
|
11 |
-
|
|
|
|
|
|
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
download_path = st.text_input("Enter the path where the image will be saved")
|
18 |
-
if not os.path.exists(download_path):
|
19 |
-
st.error("The provided download path does not exist. Please provide a valid path.")
|
20 |
-
return
|
21 |
-
|
22 |
-
if st.button("Generate and Upscale"):
|
23 |
-
try:
|
24 |
-
generate_and_upscale_image(text_prompt, clipdrop_api_key, stability_api_key, replicate_api_token, download_path)
|
25 |
-
st.success("The image has been successfully generated, upscaled, and saved to the specified path.")
|
26 |
-
except Exception as e:
|
27 |
-
st.error(f"An error occurred: {e}")
|
28 |
-
|
29 |
-
if __name__ == "__main__":
|
30 |
-
main()
|
|
|
1 |
# app.py
|
2 |
|
3 |
import streamlit as st
|
4 |
+
import base64
|
5 |
from main import generate_and_upscale_image
|
|
|
6 |
|
7 |
+
def get_image_download_link(img_bytes, filename):
|
8 |
+
b64 = base64.b64encode(img_bytes).decode()
|
9 |
+
href = f'<a href="data:image/png;base64,{b64}" download="{filename}">Click to download</a>'
|
10 |
+
return href
|
11 |
|
12 |
+
st.title("Generate and Upscale Image")
|
13 |
|
14 |
+
text_prompt = st.text_input("Enter a text prompt")
|
15 |
+
clipdrop_api_key = st.text_input("Enter your Clipdrop API key")
|
16 |
+
stability_api_key = st.text_input("Enter your Stability API key")
|
17 |
+
replicate_api_token = st.text_input("Enter your Replicate API token")
|
18 |
|
19 |
+
if st.button("Generate and Upscale Image"):
|
20 |
+
final_image_bytes = generate_and_upscale_image(text_prompt, clipdrop_api_key, stability_api_key, replicate_api_token)
|
21 |
+
st.markdown(get_image_download_link(final_image_bytes, "gfpgan_upscaled_image.png"), unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|