-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.py
51 lines (33 loc) · 1.28 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import streamlit as st
from src.handler import pic_2_hubble
from src.utils import build_result_filename
IMAGE_KEY = "image"
def reset():
if st.session_state.get(IMAGE_KEY):
del st.session_state[IMAGE_KEY]
def run():
st.title("Pic 2 Hubble")
st.write(
"Upload an image and we'll convert it into a mosaic composed image"
" using astronomical photos."
)
st.markdown("[GitHub repo](https://github.com/Wolfteinter/Pic2Hubble)")
st.warning(
body="Non-profit project. Submitted and generated images are not being stored.",
icon="⚠️",
)
uploaded_file = st.file_uploader(
"Choose an image file", type=["jpg", "jpeg", "png"], key=IMAGE_KEY
)
if uploaded_file is not None:
image_filename = uploaded_file.name
st.image(uploaded_file, width=400)
with st.spinner("Generating image"):
image_bytes = pic_2_hubble(uploaded_file)
filename = build_result_filename(image_filename)
st.success("Image generated successfully!")
st.image(image_bytes, width=400)
st.download_button("Download", image_bytes, file_name=filename, on_click=reset)
st.info(body="App created by Onder F. Campos and David Betancourt")
if __name__ == "__main__":
run()