Plsek commited on
Commit
9219e24
·
1 Parent(s): 4161769

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -38
app.py CHANGED
@@ -83,7 +83,7 @@ def cut(data0, wcs0, scale=1):
83
 
84
 
85
  @st.cache
86
- def cut_n_predict(data, scale):
87
  data, wcs = cut(data, wcs, scale=scale)
88
  image = np.log10(data+1)
89
 
@@ -186,42 +186,42 @@ if uploaded_file is not None:
186
 
187
  # np.save("pred.npy", y_pred)
188
 
189
- # try: y_pred = np.load("pred.npy")
190
- # except: y_pred = np.zeros((128,128))
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
- # np.save("thresh.npy", y_pred)
 
 
 
 
 
195
 
196
- plot_prediction(y_pred_th)
197
 
198
- if decompose:
199
- # y_pred = np.load("thresh.npy")
200
-
201
- cavs = decompose_cavity(y_pred_th)
202
-
203
- # ccd = CCDData(y_pred, unit="adu", wcs=wcs)
204
- # ccd.write(f"predictions/predicted.fits", overwrite=True)
205
- image_decomposed = np.zeros((128,128))
206
- for i, cav in enumerate(cavs):
207
- # ccd = CCDData(cav, unit="adu", wcs=wcs)
208
- # ccd.write(f"predictions/predicted_{i+1}.fits", overwrite=True)
209
- image_decomposed += (i+1) * np.where(cav > 0, 1, 0)
210
-
211
- # shutil.make_archive("predictions.zip", 'zip', "predictions")
212
- # np.save("decomposed.npy", image_decomposed)
213
-
214
- # try: image_decomposed = np.load("decomposed.npy")
215
- # except: image_decomposed = np.zeros((128,128))
216
- try: image_decomposed
217
- except: image_decomposed = np.zeros((128,128))
218
- plot_decomposed(image_decomposed)
219
-
220
- # shutil.make_archive("predictions", 'zip', "predictions")
221
-
222
- # with col6:
223
- # ccd = CCDData(y_pred, unit="adu", wcs=wcs)
224
- # # with open('predictions.zip', 'rb') as f:
225
- # # res = f.read()
226
- # st.markdown("""<style>[data-baseweb="select"] {margin-top: 16px;}</style>""", unsafe_allow_html=True)
227
- # download = st.download_button(label="Download", data=ccd, file_name='prediction.fits', mime="application/octet-stream")
 
83
 
84
 
85
  @st.cache
86
+ def cut_n_predict(data, wcs, scale):
87
  data, wcs = cut(data, wcs, scale=scale)
88
  image = np.log10(data+1)
89
 
 
186
 
187
  # np.save("pred.npy", y_pred)
188
 
189
+ # try: y_pred = np.load("pred.npy")
190
+ # except: y_pred = np.zeros((128,128))
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
+ # np.save("thresh.npy", y_pred)
195
+
196
+ plot_prediction(y_pred_th)
197
+
198
+ if decompose:
199
+ # y_pred = np.load("thresh.npy")
200
 
201
+ cavs = decompose_cavity(y_pred_th)
202
 
203
+ # ccd = CCDData(y_pred, unit="adu", wcs=wcs)
204
+ # ccd.write(f"predictions/predicted.fits", overwrite=True)
205
+ image_decomposed = np.zeros((128,128))
206
+ for i, cav in enumerate(cavs):
207
+ # ccd = CCDData(cav, unit="adu", wcs=wcs)
208
+ # ccd.write(f"predictions/predicted_{i+1}.fits", overwrite=True)
209
+ image_decomposed += (i+1) * np.where(cav > 0, 1, 0)
210
+
211
+ # shutil.make_archive("predictions.zip", 'zip', "predictions")
212
+ # np.save("decomposed.npy", image_decomposed)
213
+
214
+ # try: image_decomposed = np.load("decomposed.npy")
215
+ # except: image_decomposed = np.zeros((128,128))
216
+ try: image_decomposed
217
+ except: image_decomposed = np.zeros((128,128))
218
+ plot_decomposed(image_decomposed)
219
+
220
+ # shutil.make_archive("predictions", 'zip', "predictions")
221
+
222
+ # with col6:
223
+ # ccd = CCDData(y_pred, unit="adu", wcs=wcs)
224
+ # # with open('predictions.zip', 'rb') as f:
225
+ # # res = f.read()
226
+ # st.markdown("""<style>[data-baseweb="select"] {margin-top: 16px;}</style>""", unsafe_allow_html=True)
227
+ # download = st.download_button(label="Download", data=ccd, file_name='prediction.fits', mime="application/octet-stream")