Plsek commited on
Commit
7bcd4a9
·
1 Parent(s): 8e54123

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -45
app.py CHANGED
@@ -159,12 +159,13 @@ if uploaded_file is not None:
159
 
160
  image = np.log10(data+1)
161
  plot_image(image, scale)
162
-
163
- with col4:
164
- st.markdown("""<style>[data-baseweb="select"] {margin-top: -36px;}</style>""", unsafe_allow_html=True)
165
- threshold = st.slider("", 0.0, 1.0, 0.0, 0.05, label_visibility="hidden")
166
 
167
- if detect or threshold:
 
 
 
 
 
168
  data, wcs = cut(data, wcs, scale=scale)
169
  image = np.log10(data+1)
170
 
@@ -176,43 +177,43 @@ if uploaded_file is not None:
176
  y_pred += pred / 4
177
 
178
  # np.save("pred.npy", y_pred)
179
-
180
- # try: y_pred = np.load("pred.npy")
181
- # except: y_pred = np.zeros((128,128))
182
- try: y_pred
183
- except: y_pred = np.zeros((128,128))
184
- y_pred_th = np.where(y_pred > threshold, y_pred, 0)
185
- # np.save("thresh.npy", y_pred)
186
-
187
- plot_prediction(y_pred_th)
188
-
189
- if decompose:
190
- # y_pred = np.load("thresh.npy")
191
-
192
- cavs = decompose_cavity(y_pred_th)
193
-
194
- # ccd = CCDData(y_pred, unit="adu", wcs=wcs)
195
- # ccd.write(f"predictions/predicted.fits", overwrite=True)
196
- image_decomposed = np.zeros((128,128))
197
- for i, cav in enumerate(cavs):
198
- # ccd = CCDData(cav, unit="adu", wcs=wcs)
199
- # ccd.write(f"predictions/predicted_{i+1}.fits", overwrite=True)
200
- image_decomposed += (i+1) * np.where(cav > 0, 1, 0)
201
-
202
- # shutil.make_archive("predictions.zip", 'zip', "predictions")
203
- # np.save("decomposed.npy", image_decomposed)
204
-
205
- # try: image_decomposed = np.load("decomposed.npy")
206
- # except: image_decomposed = np.zeros((128,128))
207
- try: image_decomposed
208
- except: image_decomposed = np.zeros((128,128))
209
- plot_decomposed(image_decomposed)
210
-
211
- # shutil.make_archive("predictions", 'zip', "predictions")
212
-
213
- # with col6:
214
- # ccd = CCDData(y_pred, unit="adu", wcs=wcs)
215
- # # with open('predictions.zip', 'rb') as f:
216
- # # res = f.read()
217
- # st.markdown("""<style>[data-baseweb="select"] {margin-top: 16px;}</style>""", unsafe_allow_html=True)
218
- # download = st.download_button(label="Download", data=ccd, file_name='prediction.fits', mime="application/octet-stream")
 
159
 
160
  image = np.log10(data+1)
161
  plot_image(image, scale)
 
 
 
 
162
 
163
+ if detect:
164
+
165
+ with col4:
166
+ st.markdown("""<style>[data-baseweb="select"] {margin-top: -36px;}</style>""", unsafe_allow_html=True)
167
+ threshold = st.slider("", 0.0, 1.0, 0.0, 0.05, label_visibility="hidden")
168
+
169
  data, wcs = cut(data, wcs, scale=scale)
170
  image = np.log10(data+1)
171
 
 
177
  y_pred += pred / 4
178
 
179
  # np.save("pred.npy", y_pred)
180
+
181
+ # try: y_pred = np.load("pred.npy")
182
+ # except: y_pred = np.zeros((128,128))
183
+ try: y_pred
184
+ except: y_pred = np.zeros((128,128))
185
+ y_pred_th = np.where(y_pred > threshold, y_pred, 0)
186
+ # np.save("thresh.npy", y_pred)
187
+
188
+ plot_prediction(y_pred_th)
189
+
190
+ if decompose:
191
+ # y_pred = np.load("thresh.npy")
192
+
193
+ cavs = decompose_cavity(y_pred_th)
194
+
195
+ # ccd = CCDData(y_pred, unit="adu", wcs=wcs)
196
+ # ccd.write(f"predictions/predicted.fits", overwrite=True)
197
+ image_decomposed = np.zeros((128,128))
198
+ for i, cav in enumerate(cavs):
199
+ # ccd = CCDData(cav, unit="adu", wcs=wcs)
200
+ # ccd.write(f"predictions/predicted_{i+1}.fits", overwrite=True)
201
+ image_decomposed += (i+1) * np.where(cav > 0, 1, 0)
202
+
203
+ # shutil.make_archive("predictions.zip", 'zip', "predictions")
204
+ # np.save("decomposed.npy", image_decomposed)
205
+
206
+ # try: image_decomposed = np.load("decomposed.npy")
207
+ # except: image_decomposed = np.zeros((128,128))
208
+ try: image_decomposed
209
+ except: image_decomposed = np.zeros((128,128))
210
+ plot_decomposed(image_decomposed)
211
+
212
+ # shutil.make_archive("predictions", 'zip', "predictions")
213
+
214
+ # with col6:
215
+ # ccd = CCDData(y_pred, unit="adu", wcs=wcs)
216
+ # # with open('predictions.zip', 'rb') as f:
217
+ # # res = f.read()
218
+ # st.markdown("""<style>[data-baseweb="select"] {margin-top: 16px;}</style>""", unsafe_allow_html=True)
219
+ # download = st.download_button(label="Download", data=ccd, file_name='prediction.fits', mime="application/octet-stream")