Update app.py
Browse files
app.py
CHANGED
|
@@ -105,6 +105,8 @@ def decompose_cavity(pred, th2=0.7, amin=10):
|
|
| 105 |
cavities.append(img)
|
| 106 |
|
| 107 |
return cavities
|
|
|
|
|
|
|
| 108 |
|
| 109 |
# If file is uploaded, read in the data and plot it
|
| 110 |
if uploaded_file is not None:
|
|
@@ -157,19 +159,24 @@ if uploaded_file is not None:
|
|
| 157 |
|
| 158 |
y_pred = np.load("pred.npy")
|
| 159 |
y_pred = np.where(y_pred > threshold, y_pred, 0)
|
|
|
|
|
|
|
| 160 |
|
| 161 |
plot_prediction(y_pred)
|
| 162 |
|
| 163 |
# with colC:
|
| 164 |
# st.markdown("""<style>[data-baseweb="select"] {margin-top: -36px;}</style>""", unsafe_allow_html=True)
|
| 165 |
|
| 166 |
-
|
| 167 |
-
|
| 168 |
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
|
|
|
|
|
|
|
|
|
| 173 |
|
| 174 |
# with col4:
|
| 175 |
# pass
|
|
|
|
| 105 |
cavities.append(img)
|
| 106 |
|
| 107 |
return cavities
|
| 108 |
+
|
| 109 |
+
np.save("pred.npy", y_pred)
|
| 110 |
|
| 111 |
# If file is uploaded, read in the data and plot it
|
| 112 |
if uploaded_file is not None:
|
|
|
|
| 159 |
|
| 160 |
y_pred = np.load("pred.npy")
|
| 161 |
y_pred = np.where(y_pred > threshold, y_pred, 0)
|
| 162 |
+
|
| 163 |
+
np.save("thresh.npy", y_pred)
|
| 164 |
|
| 165 |
plot_prediction(y_pred)
|
| 166 |
|
| 167 |
# with colC:
|
| 168 |
# st.markdown("""<style>[data-baseweb="select"] {margin-top: -36px;}</style>""", unsafe_allow_html=True)
|
| 169 |
|
| 170 |
+
if decompose:
|
| 171 |
+
y_pred = np.save("thresh.npy")
|
| 172 |
|
| 173 |
+
cavs = decompose_cavity(y_pred)
|
| 174 |
+
|
| 175 |
+
ccd = CCDData(y_pred, unit="adu", wcs=wcs)
|
| 176 |
+
ccd.write(f"predicted.fits", overwrite=True)
|
| 177 |
+
for i, cav in enumerate(cavs):
|
| 178 |
+
ccd = CCDData(cav, unit="adu", wcs=wcs)
|
| 179 |
+
ccd.write(f"predicted_{i+1}.fits", overwrite=True)
|
| 180 |
|
| 181 |
# with col4:
|
| 182 |
# pass
|