Singularity666 commited on
Commit
d594335
·
1 Parent(s): 65741b8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -18
app.py CHANGED
@@ -2,29 +2,29 @@
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.')
 
 
2
 
3
  import streamlit as st
4
  from main import generate_and_upscale_image
5
+ import os
6
 
7
+ def main():
8
 
9
+ st.title("Image Generator and Upscaler")
 
 
10
 
11
+ text_prompt = st.text_input("Enter your text prompt")
12
 
13
+ clipdrop_api_key = st.text_input("Enter your ClipDrop API Key", type="password")
14
+ stability_api_key = st.text_input("Enter your Stability API Key", type="password")
15
+ replicate_api_token = st.text_input("Enter your Replicate API Token", type="password")
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()