Plsek commited on
Commit
e842a8b
·
1 Parent(s): c6b81d0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -178,16 +178,20 @@ if uploaded_file is not None:
178
  threshold = st.slider("Threshold", 0.0, 1.0, 0.0, 0.05) #, label_visibility="hidden")
179
 
180
  # Decompose button
181
- with col5: decompose = st.button('Decompose')
182
 
183
  with col6:
184
- with open("blank.txt", 'w') as f: pass
185
- with open("blank.txt", 'rb') as f: 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', disabled=True, mime="application/octet-stream")
 
 
 
 
 
 
191
 
192
  # Make two columns for plots
193
  _, colA, colB, colC, _ = st.columns([bordersize,1,1,1,bordersize])
@@ -203,14 +207,10 @@ if uploaded_file is not None:
203
  plot_prediction(y_pred_th)
204
 
205
  print(type(download))
206
- if decompose or download:
207
- download.disabled = False
208
-
209
  image_decomposed = decompose_cavity(y_pred_th)
210
 
211
  plot_decomposed(image_decomposed)
212
 
213
- shutil.make_archive("predictions", 'zip', "predictions")
214
- with open('predictions.zip', 'rb') as f:
215
- res = f.read()
216
- download.data=res
 
178
  threshold = st.slider("Threshold", 0.0, 1.0, 0.0, 0.05) #, label_visibility="hidden")
179
 
180
  # Decompose button
181
+ with col5: decompose = st.button('Decompose', key="decompose")
182
 
183
  with col6:
 
 
184
  st.markdown("")
185
  st.markdown("")
186
  # st.markdown("""<style>[data-baseweb="select"] {margin-top: 16px;}</style>""", unsafe_allow_html=True)
187
+ fname = uploaded_file.name.strip(".fits")
188
+ shutil.make_archive("predictions", 'zip', "predictions")
189
+ with open('predictions.zip', 'rb') as f:
190
+ res = f.read()
191
+ download = st.download_button(label="Download", data=res,
192
+ file_name=f'{fname}_{int(scale*128)}.zip',
193
+ disabled=st.session_state.get("disabled", True),
194
+ mime="application/octet-stream")
195
 
196
  # Make two columns for plots
197
  _, colA, colB, colC, _ = st.columns([bordersize,1,1,1,bordersize])
 
207
  plot_prediction(y_pred_th)
208
 
209
  print(type(download))
210
+ if decompose or download:
 
 
211
  image_decomposed = decompose_cavity(y_pred_th)
212
 
213
  plot_decomposed(image_decomposed)
214
 
215
+ if st.session_state.get("decompose", True):
216
+ st.session_state.disabled = False