Update app.py
Browse files
app.py
CHANGED
@@ -87,7 +87,7 @@ def cut(data0, wcs0, scale=1):
|
|
87 |
return data, wcs
|
88 |
|
89 |
# Define function to apply cutting and produce a prediction
|
90 |
-
@st.cache
|
91 |
def cut_n_predict(data, wcs, scale):
|
92 |
data, wcs = cut(data, wcs, scale=scale)
|
93 |
image = np.log10(data+1)
|
@@ -102,7 +102,7 @@ def cut_n_predict(data, wcs, scale):
|
|
102 |
return y_pred, wcs
|
103 |
|
104 |
# Define function to decompose prediction into individual cavities
|
105 |
-
@st.cache
|
106 |
def decompose_cavity(pred, th2=0.7, amin=6):
|
107 |
X, Y = pred.nonzero()
|
108 |
data = np.array([X,Y]).reshape(2, -1)
|
@@ -141,12 +141,12 @@ def decompose_cavity(pred, th2=0.7, amin=6):
|
|
141 |
|
142 |
return image_decomposed
|
143 |
|
144 |
-
@st.cache
|
145 |
-
def load_file(fname):
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
|
151 |
# def change_scale():
|
152 |
# del st.session_state["threshold"]
|
@@ -207,31 +207,31 @@ if uploaded_file is not None:
|
|
207 |
scale = st.selectbox('Scale:',[f"{(i+1)*128}x{(i+1)*128}" for i in range(max_scale)], label_visibility="hidden") #, on_change=change_scale)
|
208 |
scale = int(scale.split("x")[0]) // 128
|
209 |
|
210 |
-
# Detect button
|
211 |
-
with col3: detect = st.button('Detect', key="detect")
|
212 |
|
213 |
-
# Threshold slider
|
214 |
-
with col4:
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
|
219 |
-
# Decompose button
|
220 |
-
with col5: decompose = st.button('Decompose', key="decompose")
|
221 |
|
222 |
-
# Make two columns for plots
|
223 |
-
_, colA, colB, colC, _ = st.columns([bordersize,1,1,1,bordersize])
|
224 |
|
225 |
image = np.log10(data+1)
|
226 |
plot_image(image, scale)
|
227 |
|
228 |
-
if detect or threshold:
|
229 |
-
# if st.session_state.get("detect", True):
|
230 |
-
|
231 |
|
232 |
-
|
233 |
|
234 |
-
|
235 |
|
236 |
# if decompose or st.session_state.get("download", False):
|
237 |
# image_decomposed = decompose_cavity(y_pred_th)
|
|
|
87 |
return data, wcs
|
88 |
|
89 |
# Define function to apply cutting and produce a prediction
|
90 |
+
# @st.cache
|
91 |
def cut_n_predict(data, wcs, scale):
|
92 |
data, wcs = cut(data, wcs, scale=scale)
|
93 |
image = np.log10(data+1)
|
|
|
102 |
return y_pred, wcs
|
103 |
|
104 |
# Define function to decompose prediction into individual cavities
|
105 |
+
# @st.cache
|
106 |
def decompose_cavity(pred, th2=0.7, amin=6):
|
107 |
X, Y = pred.nonzero()
|
108 |
data = np.array([X,Y]).reshape(2, -1)
|
|
|
141 |
|
142 |
return image_decomposed
|
143 |
|
144 |
+
# @st.cache
|
145 |
+
# def load_file(fname):
|
146 |
+
# with fits.open(fname) as hdul:
|
147 |
+
# data = hdul[0].data
|
148 |
+
# wcs = WCS(hdul[0].header)
|
149 |
+
# return data, wcs
|
150 |
|
151 |
# def change_scale():
|
152 |
# del st.session_state["threshold"]
|
|
|
207 |
scale = st.selectbox('Scale:',[f"{(i+1)*128}x{(i+1)*128}" for i in range(max_scale)], label_visibility="hidden") #, on_change=change_scale)
|
208 |
scale = int(scale.split("x")[0]) // 128
|
209 |
|
210 |
+
# # Detect button
|
211 |
+
# with col3: detect = st.button('Detect', key="detect")
|
212 |
|
213 |
+
# # Threshold slider
|
214 |
+
# with col4:
|
215 |
+
# st.markdown("")
|
216 |
+
# # st.markdown("""<style>[data-baseweb="select"] {margin-top: -36px;}</style>""", unsafe_allow_html=True)
|
217 |
+
# threshold = st.slider("Threshold", 0.0, 1.0, 0.0, 0.05, key="threshold") #, label_visibility="hidden")
|
218 |
|
219 |
+
# # Decompose button
|
220 |
+
# with col5: decompose = st.button('Decompose', key="decompose")
|
221 |
|
222 |
+
# # Make two columns for plots
|
223 |
+
# _, colA, colB, colC, _ = st.columns([bordersize,1,1,1,bordersize])
|
224 |
|
225 |
image = np.log10(data+1)
|
226 |
plot_image(image, scale)
|
227 |
|
228 |
+
# if detect or threshold:
|
229 |
+
# # if st.session_state.get("detect", True):
|
230 |
+
# y_pred, wcs = cut_n_predict(data, wcs, scale)
|
231 |
|
232 |
+
# y_pred_th = np.where(y_pred > threshold, y_pred, 0)
|
233 |
|
234 |
+
# plot_prediction(y_pred_th)
|
235 |
|
236 |
# if decompose or st.session_state.get("download", False):
|
237 |
# image_decomposed = decompose_cavity(y_pred_th)
|