Singularity666 commited on
Commit
5f0e6f8
·
1 Parent(s): 90bece4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -39
app.py CHANGED
@@ -1,48 +1,29 @@
1
  # app.py
2
 
3
  import streamlit as st
4
- from main import generate_and_upscale_image
5
- from PIL import Image
6
- import io
7
 
8
- # Display title and instructions
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
- # User input for text prompt
13
- text_prompt = st.text_input('Enter your text prompt here:')
14
 
15
- # User input for API keys
16
- clipdrop_api_key = st.text_input('Enter your ClipDrop API key:', type="password")
17
- stability_api_key = st.text_input('Enter your Stability API key:', type="password")
18
- replicate_api_token = st.text_input('Enter your Replicate API token:', type="password")
19
 
20
- # When the button is clicked, the processing functions are called with the user's input
21
- if st.button('Generate and Upscale Image'):
 
 
 
22
 
23
- st.write("Processing... Please wait, this may take a while.")
 
 
 
 
 
24
 
25
- # Calls function from main.py and passes user input
26
- upscaled_image = generate_and_upscale_image(
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()