Spaces:
Sleeping
Sleeping
Commit
·
5f0e6f8
1
Parent(s):
90bece4
Update app.py
Browse files
app.py
CHANGED
@@ -1,48 +1,29 @@
|
|
1 |
# app.py
|
2 |
|
3 |
import streamlit as st
|
4 |
-
|
5 |
-
from PIL import Image
|
6 |
-
import io
|
7 |
|
8 |
-
|
9 |
-
st.title("Text to Image Upscaling")
|
10 |
-
st.write("Please enter a text prompt, and we will generate and upscale an image based on it.")
|
11 |
|
12 |
-
|
13 |
-
text_prompt = st.text_input('Enter your text prompt here:')
|
14 |
|
15 |
-
|
16 |
-
clipdrop_api_key = st.text_input(
|
17 |
-
stability_api_key = st.text_input(
|
18 |
-
replicate_api_token = st.text_input(
|
19 |
|
20 |
-
|
21 |
-
if
|
|
|
|
|
|
|
22 |
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
text_prompt=text_prompt,
|
28 |
-
clipdrop_api_key=clipdrop_api_key,
|
29 |
-
stability_api_key=stability_api_key,
|
30 |
-
replicate_api_token=replicate_api_token,
|
31 |
-
)
|
32 |
-
|
33 |
-
# Show the resulting image
|
34 |
-
st.image(upscaled_image, caption='Your upscaled image')
|
35 |
-
|
36 |
-
# Option to download image
|
37 |
-
buffered = io.BytesIO()
|
38 |
-
upscaled_image.save(buffered, format="PNG")
|
39 |
-
img_str = buffered.getvalue()
|
40 |
-
try:
|
41 |
-
st.download_button(
|
42 |
-
label="Download Image",
|
43 |
-
data=img_str,
|
44 |
-
file_name='upscaled_image.png',
|
45 |
-
mime='image/png',
|
46 |
-
)
|
47 |
-
except Exception as e:
|
48 |
-
st.write("Error in downloading the image.")
|
|
|
1 |
# app.py
|
2 |
|
3 |
import streamlit as st
|
4 |
+
import main
|
|
|
|
|
5 |
|
6 |
+
def app():
|
|
|
|
|
7 |
|
8 |
+
st.title("Image Generator and Upscaler")
|
|
|
9 |
|
10 |
+
text_prompt = st.text_input("Enter your text prompt")
|
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 |
+
if st.button("Generate and Upscale Image"):
|
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 __name__ == "__main__":
|
29 |
+
app()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|