Singularity666 commited on
Commit
dd52fb2
·
1 Parent(s): e02283a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -9
app.py CHANGED
@@ -1,23 +1,31 @@
1
  import streamlit as st
2
  from main import generate_image_from_text, upscale_image_esrgan, further_upscale_image
 
 
 
 
3
 
4
- def main():
5
  st.title("Image Generation and Upscaling")
6
  st.write("Enter a text prompt and an image will be generated and upscaled.")
7
 
8
  prompt = st.text_input("Enter a textual prompt to generate an image...")
9
-
10
  if prompt:
11
- st.success("Generating image from text prompt...")
 
12
  image_bytes = generate_image_from_text(prompt)
13
-
14
- st.success("Upscaling image with ESRGAN...")
15
  upscaled_image_bytes = upscale_image_esrgan(image_bytes)
16
-
17
- st.success("Further upscaling image with GFPGAN...")
18
- download_link = further_upscale_image(upscaled_image_bytes)
19
-
20
  st.markdown(download_link, unsafe_allow_html=True)
21
 
 
 
 
 
22
  if __name__ == "__main__":
23
  main()
 
1
  import streamlit as st
2
  from main import generate_image_from_text, upscale_image_esrgan, further_upscale_image
3
+ import asyncio
4
+
5
+ # Here we use asyncio to allow tasks to run concurrently
6
+ async def run_process():
7
 
 
8
  st.title("Image Generation and Upscaling")
9
  st.write("Enter a text prompt and an image will be generated and upscaled.")
10
 
11
  prompt = st.text_input("Enter a textual prompt to generate an image...")
12
+
13
  if prompt:
14
+ progress = st.progress(0)
15
+ st.write("Generating image from text prompt...")
16
  image_bytes = generate_image_from_text(prompt)
17
+ progress.progress(33)
18
+ st.write("Upscaling image with ESRGAN...")
19
  upscaled_image_bytes = upscale_image_esrgan(image_bytes)
20
+ progress.progress(66)
21
+ st.write("Further upscaling image with GFPGAN...")
22
+ download_link = await further_upscale_image(upscaled_image_bytes)
23
+ progress.progress(100)
24
  st.markdown(download_link, unsafe_allow_html=True)
25
 
26
+ def main():
27
+ loop = asyncio.get_event_loop()
28
+ loop.run_until_complete(run_process())
29
+
30
  if __name__ == "__main__":
31
  main()