Update app.py
Browse files
app.py
CHANGED
@@ -123,7 +123,15 @@ def decompose_cavity(pred, th2=0.7, amin=10):
|
|
123 |
|
124 |
cavities.append(img)
|
125 |
|
126 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
|
128 |
# @st.cache
|
129 |
# def zip_predictions():
|
@@ -204,23 +212,23 @@ if uploaded_file is not None:
|
|
204 |
if decompose:
|
205 |
# y_pred = np.load("thresh.npy")
|
206 |
|
207 |
-
|
208 |
-
|
209 |
-
ccd = CCDData(y_pred, unit="adu", wcs=wcs)
|
210 |
-
ccd.write(f"predictions/predicted.fits", overwrite=True)
|
211 |
-
image_decomposed = np.zeros((128,128))
|
212 |
-
for i, cav in enumerate(cavs):
|
213 |
-
ccd = CCDData(cav, unit="adu", wcs=wcs)
|
214 |
-
ccd.write(f"predictions/predicted_{i+1}.fits", overwrite=True)
|
215 |
-
image_decomposed += (i+1) * np.where(cav > 0, 1, 0)
|
216 |
-
|
217 |
-
try: _ = image_decomposed
|
218 |
-
except: image_decomposed = np.zeros((128,128))
|
219 |
-
plot_decomposed(image_decomposed)
|
220 |
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
|
124 |
cavities.append(img)
|
125 |
|
126 |
+
ccd = CCDData(pred, unit="adu", wcs=wcs)
|
127 |
+
ccd.write(f"predictions/predicted.fits", overwrite=True)
|
128 |
+
image_decomposed = np.zeros((128,128))
|
129 |
+
for i, cav in enumerate(cavities):
|
130 |
+
ccd = CCDData(cav, unit="adu", wcs=wcs)
|
131 |
+
ccd.write(f"predictions/predicted_{i+1}.fits", overwrite=True)
|
132 |
+
image_decomposed += (i+1) * np.where(cav > 0, 1, 0)
|
133 |
+
|
134 |
+
return image_decomposed
|
135 |
|
136 |
# @st.cache
|
137 |
# def zip_predictions():
|
|
|
212 |
if decompose:
|
213 |
# y_pred = np.load("thresh.npy")
|
214 |
|
215 |
+
image_decomposed = decompose_cavity(y_pred_th)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
|
217 |
+
# ccd = CCDData(y_pred, unit="adu", wcs=wcs)
|
218 |
+
# ccd.write(f"predictions/predicted.fits", overwrite=True)
|
219 |
+
# image_decomposed = np.zeros((128,128))
|
220 |
+
# for i, cav in enumerate(cavs):
|
221 |
+
# ccd = CCDData(cav, unit="adu", wcs=wcs)
|
222 |
+
# ccd.write(f"predictions/predicted_{i+1}.fits", overwrite=True)
|
223 |
+
# image_decomposed += (i+1) * np.where(cav > 0, 1, 0)
|
224 |
+
|
225 |
+
try: _ = image_decomposed
|
226 |
+
except: image_decomposed = np.zeros((128,128))
|
227 |
+
plot_decomposed(image_decomposed)
|
228 |
+
|
229 |
+
with col6:
|
230 |
+
shutil.make_archive("predictions", 'zip', "predictions")
|
231 |
+
with open('predictions.zip', 'rb') as f:
|
232 |
+
res = f.read()
|
233 |
+
st.markdown("""<style>[data-baseweb="select"] {margin-top: 16px;}</style>""", unsafe_allow_html=True)
|
234 |
+
download = st.download_button(label="Download", data=res, file_name='prediction.zip', mime="application/octet-stream")
|