Plsek commited on
Commit
3bee343
·
1 Parent(s): 38ebf86

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -158,18 +158,20 @@ if uploaded_file is not None:
158
  col1.subheader("Input image")
159
  col3.subheader("Prediction")
160
  col5.subheader("Decomposed")
 
 
161
 
162
  with col1:
163
  # st.markdown("""<style>[data-baseweb="select"] {margin-top: -26px;}</style>""", unsafe_allow_html=True)
164
  max_scale = int(data.shape[0] // 128)
165
- scale = st.selectbox('Scale:',[f"{(i+1)*128}x{(i+1)*128}" for i in range(max_scale)], label_visibility="hidden")
166
  scale = int(scale.split("x")[0]) // 128
167
 
168
  with col3:
169
  detect = st.button('Detect')
170
 
171
  with col5:
172
- decompose = st.button('Docompose')
173
 
174
  # Make two columns for plots
175
  _, colA, colB, colC, _ = st.columns([bordersize,1,1,1,bordersize])
@@ -180,7 +182,7 @@ if uploaded_file is not None:
180
 
181
  with col4:
182
  st.markdown("""<style>[data-baseweb="select"] {margin-top: -36px;}</style>""", unsafe_allow_html=True)
183
- threshold = st.slider("", 0.0, 1.0, 0.0, 0.05, label_visibility="hidden")
184
 
185
  if detect or threshold:
186
  y_pred, wcs = cut_n_predict(data, wcs, scale)
@@ -189,7 +191,7 @@ if uploaded_file is not None:
189
 
190
  # try: y_pred = np.load("pred.npy")
191
  # except: y_pred = np.zeros((128,128))
192
- try: y_pred
193
  except: y_pred = np.zeros((128,128))
194
  y_pred_th = np.where(y_pred > threshold, y_pred, 0)
195
  # np.save("thresh.npy", y_pred)
@@ -214,7 +216,7 @@ if uploaded_file is not None:
214
 
215
  # try: image_decomposed = np.load("decomposed.npy")
216
  # except: image_decomposed = np.zeros((128,128))
217
- try: image_decomposed
218
  except: image_decomposed = np.zeros((128,128))
219
  plot_decomposed(image_decomposed)
220
 
 
158
  col1.subheader("Input image")
159
  col3.subheader("Prediction")
160
  col5.subheader("Decomposed")
161
+
162
+ st.session_state.default = 0.0
163
 
164
  with col1:
165
  # st.markdown("""<style>[data-baseweb="select"] {margin-top: -26px;}</style>""", unsafe_allow_html=True)
166
  max_scale = int(data.shape[0] // 128)
167
+ scale = st.selectbox('Scale:',[f"{(i+1)*128}x{(i+1)*128}" for i in range(max_scale)], label_visibility="hidden", on_change=lambda _: st.session_state.default = 0.0)
168
  scale = int(scale.split("x")[0]) // 128
169
 
170
  with col3:
171
  detect = st.button('Detect')
172
 
173
  with col5:
174
+ decompose = st.button('Decompose')
175
 
176
  # Make two columns for plots
177
  _, colA, colB, colC, _ = st.columns([bordersize,1,1,1,bordersize])
 
182
 
183
  with col4:
184
  st.markdown("""<style>[data-baseweb="select"] {margin-top: -36px;}</style>""", unsafe_allow_html=True)
185
+ threshold = st.slider("", 0.0, 1.0, st.session_state.default, 0.05, label_visibility="hidden")
186
 
187
  if detect or threshold:
188
  y_pred, wcs = cut_n_predict(data, wcs, scale)
 
191
 
192
  # try: y_pred = np.load("pred.npy")
193
  # except: y_pred = np.zeros((128,128))
194
+ try: _ = y_pred
195
  except: y_pred = np.zeros((128,128))
196
  y_pred_th = np.where(y_pred > threshold, y_pred, 0)
197
  # np.save("thresh.npy", y_pred)
 
216
 
217
  # try: image_decomposed = np.load("decomposed.npy")
218
  # except: image_decomposed = np.zeros((128,128))
219
+ try: _ = image_decomposed
220
  except: image_decomposed = np.zeros((128,128))
221
  plot_decomposed(image_decomposed)
222