Update app.py
Browse files
app.py
CHANGED
@@ -25,6 +25,12 @@ from sklearn.cluster import DBSCAN
|
|
25 |
import streamlit as st
|
26 |
st.set_option('deprecation.showPyplotGlobalUse', False)
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
# Define function to plot the uploaded image
|
29 |
def plot_image(image, scale):
|
30 |
plt.figure(figsize=(4, 4))
|
@@ -135,23 +141,17 @@ def decompose_cavity(pred, th2=0.7, amin=6):
|
|
135 |
|
136 |
return image_decomposed
|
137 |
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
|
145 |
# def change_scale():
|
146 |
# del st.session_state["threshold"]
|
147 |
|
148 |
-
|
149 |
-
# Use wide layout and create columns
|
150 |
-
st.set_page_config(page_title="Cavity Detection Tool", layout="wide")
|
151 |
-
bordersize = 0.45
|
152 |
-
_, col, _ = st.columns([bordersize, 3, bordersize])
|
153 |
-
|
154 |
-
os.system("mkdir -p predictions")
|
155 |
|
156 |
with col:
|
157 |
# Create heading and description
|
@@ -161,10 +161,12 @@ with col:
|
|
161 |
st.markdown("Input images should be in units of counts, centred at the galaxy center, and point sources should be filled with surrounding background ([dmfilth](https://cxc.cfa.harvard.edu/ciao/ahelp/dmfilth.html)).")
|
162 |
st.markdown("If you use this tool for your research, please cite [Plšek et al. 2023](https://arxiv.org/abs/2304.05457)")
|
163 |
|
|
|
|
|
164 |
# _, col_1, col_2, col_3, _ = st.columns([bordersize, 2.0, 0.5, 0.5, bordersize])
|
165 |
|
166 |
# with col:
|
167 |
-
uploaded_file = st.file_uploader("Choose a FITS file", type=['fits'])
|
168 |
|
169 |
# with col_2:
|
170 |
# st.markdown("### Examples")
|
@@ -187,10 +189,10 @@ with col:
|
|
187 |
# data = np.zeros((128,128))
|
188 |
|
189 |
if uploaded_file is not None:
|
190 |
-
|
191 |
-
with fits.open(uploaded_file) as hdul:
|
192 |
-
|
193 |
-
|
194 |
|
195 |
# Make six columns for buttons
|
196 |
_, col1, col2, col3, col4, col5, col6, _ = st.columns([bordersize,0.5,0.5,0.5,0.5,0.5,0.5,bordersize])
|
|
|
25 |
import streamlit as st
|
26 |
st.set_option('deprecation.showPyplotGlobalUse', False)
|
27 |
|
28 |
+
# Use wide layout and create columns
|
29 |
+
st.set_page_config(page_title="Cavity Detection Tool", layout="wide")
|
30 |
+
bordersize = 0.45
|
31 |
+
_, col, _ = st.columns([bordersize, 3, bordersize])
|
32 |
+
|
33 |
+
|
34 |
# Define function to plot the uploaded image
|
35 |
def plot_image(image, scale):
|
36 |
plt.figure(figsize=(4, 4))
|
|
|
141 |
|
142 |
return image_decomposed
|
143 |
|
144 |
+
@st.cache
|
145 |
+
def load_file(fname):
|
146 |
+
with fits.open(fname) as hdul:
|
147 |
+
data = hdul[0].data
|
148 |
+
wcs = WCS(hdul[0].header)
|
149 |
+
return data, wcs
|
150 |
|
151 |
# def change_scale():
|
152 |
# del st.session_state["threshold"]
|
153 |
|
154 |
+
# os.system("mkdir -p predictions")
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
|
156 |
with col:
|
157 |
# Create heading and description
|
|
|
161 |
st.markdown("Input images should be in units of counts, centred at the galaxy center, and point sources should be filled with surrounding background ([dmfilth](https://cxc.cfa.harvard.edu/ciao/ahelp/dmfilth.html)).")
|
162 |
st.markdown("If you use this tool for your research, please cite [Plšek et al. 2023](https://arxiv.org/abs/2304.05457)")
|
163 |
|
164 |
+
uploaded_file = st.file_uploader("Choose a FITS file", type=['fits'])
|
165 |
+
|
166 |
# _, col_1, col_2, col_3, _ = st.columns([bordersize, 2.0, 0.5, 0.5, bordersize])
|
167 |
|
168 |
# with col:
|
169 |
+
# uploaded_file = st.file_uploader("Choose a FITS file", type=['fits'])
|
170 |
|
171 |
# with col_2:
|
172 |
# st.markdown("### Examples")
|
|
|
189 |
# data = np.zeros((128,128))
|
190 |
|
191 |
if uploaded_file is not None:
|
192 |
+
data, wcs = load_file(uploaded_file)
|
193 |
+
# with fits.open(uploaded_file) as hdul:
|
194 |
+
# data = hdul[0].data
|
195 |
+
# wcs = WCS(hdul[0].header)
|
196 |
|
197 |
# Make six columns for buttons
|
198 |
_, col1, col2, col3, col4, col5, col6, _ = st.columns([bordersize,0.5,0.5,0.5,0.5,0.5,0.5,bordersize])
|