Plsek commited on
Commit
48b10cd
·
1 Parent(s): b4f54b4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -13
app.py CHANGED
@@ -68,7 +68,8 @@ def plot_decomposed(decomposed):
68
  for i in range(N):
69
  new = np.where(decomposed == i+1, 1, 0)
70
  x0, y0 = center_of_mass(new)
71
- plt.text(y0, x0, f"{i+1}", fontsize=15, color="white")
 
72
 
73
  plt.axis('off')
74
  with colC: st.pyplot()
@@ -183,11 +184,11 @@ if uploaded_file is not None:
183
  cavs = decompose_cavity(y_pred)
184
 
185
  ccd = CCDData(y_pred, unit="adu", wcs=wcs)
186
- ccd.write(f"predicted.fits", overwrite=True)
187
  image_decomposed = np.zeros((128,128))
188
  for i, cav in enumerate(cavs):
189
  ccd = CCDData(cav, unit="adu", wcs=wcs)
190
- ccd.write(f"predicted_{i+1}.fits", overwrite=True)
191
  image_decomposed += (i+1) * np.where(cav > 0, 1, 0)
192
 
193
  # shutil.make_archive("predictions.zip", 'zip', "predictions")
@@ -197,15 +198,11 @@ if uploaded_file is not None:
197
  except: image_decomposed = np.zeros((128,128))
198
  plot_decomposed(image_decomposed)
199
 
200
- # with col6:
201
- # try:
202
- # name = 'predictions.zip'
203
- # with open(name, 'rb') as f:
204
- # res = f.read()
205
- # except:
206
- # name = uploaded_file
207
- # with open(name, 'rb') as f:
208
- # res = f.read()
209
  # # st.markdown("""<style>[data-baseweb="select"] {margin-top: 16px;}</style>""", unsafe_allow_html=True)
210
  # # # download = st.button('Download')
211
- # download = st.download_button(label="Download", data=res, file_name=name, mime="application/octet-stream")
 
68
  for i in range(N):
69
  new = np.where(decomposed == i+1, 1, 0)
70
  x0, y0 = center_of_mass(new)
71
+ color = "white" if i < N//2 else "black"
72
+ plt.text(y0, x0, f"{i+1}", ha="center", va="center", fontsize=15, color=color)
73
 
74
  plt.axis('off')
75
  with colC: st.pyplot()
 
184
  cavs = decompose_cavity(y_pred)
185
 
186
  ccd = CCDData(y_pred, unit="adu", wcs=wcs)
187
+ ccd.write(f"predictions/predicted.fits", overwrite=True)
188
  image_decomposed = np.zeros((128,128))
189
  for i, cav in enumerate(cavs):
190
  ccd = CCDData(cav, unit="adu", wcs=wcs)
191
+ ccd.write(f"predictions/predicted_{i+1}.fits", overwrite=True)
192
  image_decomposed += (i+1) * np.where(cav > 0, 1, 0)
193
 
194
  # shutil.make_archive("predictions.zip", 'zip', "predictions")
 
198
  except: image_decomposed = np.zeros((128,128))
199
  plot_decomposed(image_decomposed)
200
 
201
+ shutil.make_archive("predictions.zip", 'zip', "predictions")
202
+
203
+ with col6:
204
+ with open('predictions.zip', 'rb') as f:
205
+ res = f.read()
 
 
 
 
206
  # # st.markdown("""<style>[data-baseweb="select"] {margin-top: 16px;}</style>""", unsafe_allow_html=True)
207
  # # # download = st.button('Download')
208
+ download = st.download_button(label="Download", data=res, file_name='predictions.zip', mime="application/octet-stream")