Update app.py
Browse files
app.py
CHANGED
@@ -163,7 +163,7 @@ if uploaded_file is not None:
|
|
163 |
# col6.subheader("")
|
164 |
|
165 |
with col1:
|
166 |
-
|
167 |
max_scale = int(data.shape[0] // 128)
|
168 |
scale = st.selectbox('Scale:',[f"{(i+1)*128}x{(i+1)*128}" for i in range(max_scale)], label_visibility="hidden")
|
169 |
scale = int(scale.split("x")[0]) // 128
|
@@ -178,6 +178,16 @@ if uploaded_file is not None:
|
|
178 |
|
179 |
# Decompose button
|
180 |
with col5: decompose = st.button('Decompose')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
181 |
|
182 |
# Make two columns for plots
|
183 |
_, colA, colB, colC, _ = st.columns([bordersize,1,1,1,bordersize])
|
@@ -188,26 +198,13 @@ if uploaded_file is not None:
|
|
188 |
if detect or threshold:
|
189 |
y_pred, wcs = cut_n_predict(data, wcs, scale)
|
190 |
|
191 |
-
# try: _ = y_pred
|
192 |
-
# except: y_pred = np.zeros((128,128))
|
193 |
y_pred_th = np.where(y_pred > threshold, y_pred, 0)
|
194 |
|
195 |
plot_prediction(y_pred_th)
|
196 |
|
197 |
-
if decompose:
|
|
|
198 |
|
199 |
image_decomposed = decompose_cavity(y_pred_th)
|
200 |
|
201 |
-
|
202 |
-
# except: image_decomposed = np.zeros((128,128))
|
203 |
-
plot_decomposed(image_decomposed)
|
204 |
-
|
205 |
-
with col6:
|
206 |
-
shutil.make_archive("predictions", 'zip', "predictions")
|
207 |
-
with open('predictions.zip', 'rb') as f:
|
208 |
-
res = f.read()
|
209 |
-
st.markdown("")
|
210 |
-
st.markdown("")
|
211 |
-
# st.markdown("""<style>[data-baseweb="select"] {margin-top: 16px;}</style>""", unsafe_allow_html=True)
|
212 |
-
fname = uploaded_file.name.strip(".fits")
|
213 |
-
download = st.download_button(label="Download", data=res, file_name=f'{fname}_{int(scale*128)}.zip', mime="application/octet-stream")
|
|
|
163 |
# col6.subheader("")
|
164 |
|
165 |
with col1:
|
166 |
+
st.markdown("""<style>[data-baseweb="select"] {margin-top: -26px;}</style>""", unsafe_allow_html=True)
|
167 |
max_scale = int(data.shape[0] // 128)
|
168 |
scale = st.selectbox('Scale:',[f"{(i+1)*128}x{(i+1)*128}" for i in range(max_scale)], label_visibility="hidden")
|
169 |
scale = int(scale.split("x")[0]) // 128
|
|
|
178 |
|
179 |
# Decompose button
|
180 |
with col5: decompose = st.button('Decompose')
|
181 |
+
|
182 |
+
with col6:
|
183 |
+
shutil.make_archive("predictions", 'zip', "predictions")
|
184 |
+
with open('predictions.zip', 'rb') as f:
|
185 |
+
res = f.read()
|
186 |
+
st.markdown("")
|
187 |
+
st.markdown("")
|
188 |
+
# st.markdown("""<style>[data-baseweb="select"] {margin-top: 16px;}</style>""", unsafe_allow_html=True)
|
189 |
+
fname = uploaded_file.name.strip(".fits")
|
190 |
+
download = st.download_button(label="Download", data=res, file_name=f'{fname}_{int(scale*128)}.zip', disable=True, mime="application/octet-stream")
|
191 |
|
192 |
# Make two columns for plots
|
193 |
_, colA, colB, colC, _ = st.columns([bordersize,1,1,1,bordersize])
|
|
|
198 |
if detect or threshold:
|
199 |
y_pred, wcs = cut_n_predict(data, wcs, scale)
|
200 |
|
|
|
|
|
201 |
y_pred_th = np.where(y_pred > threshold, y_pred, 0)
|
202 |
|
203 |
plot_prediction(y_pred_th)
|
204 |
|
205 |
+
if decompose or download:
|
206 |
+
download.disabled = False
|
207 |
|
208 |
image_decomposed = decompose_cavity(y_pred_th)
|
209 |
|
210 |
+
plot_decomposed(image_decomposed)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|