Update app.py
Browse files
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
|
|
|
|
|
|
|
|
|
|
|
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 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
|
|
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")
|