Plsek commited on
Commit
e5f809c
·
1 Parent(s): 8e1fb51

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -31
app.py CHANGED
@@ -79,41 +79,52 @@ if uploaded_file is not None:
79
  col2.subheader("CADET prediction")
80
 
81
  with col1:
82
- st.markdown(
83
- """<style>[data-baseweb="select"] {margin-top: -50px;}</style>""",
84
- unsafe_allow_html=True
85
- )
86
-
87
- max_scale = int(data.shape[0] // 128)
88
- # scale = st.slider("Scale", 1, max_scale, 1, 1)
89
- scale = int(st.selectbox('Scale:',[i+1 for i in range(max_scale)], label_visibility="hidden"))
90
-
 
 
 
 
 
 
91
  # Add a slider to change the scale
92
  with col1:
93
  plot_image(np.log10(data+1), scale)
94
 
95
  with col2:
96
- if st.button('Detect cavities'):
97
- data, wcs = cut(data, wcs, scale=scale)
98
 
99
- image = np.log10(data+1)
100
-
101
- y_pred = 0
102
- for j in [0,1,2,3]:
103
- rotated = np.rot90(image, j)
104
- pred = model.predict(rotated.reshape(1, 128, 128, 1)).reshape(128 ,128)
105
- pred = np.rot90(pred, -j)
106
- y_pred += pred / 4
107
 
108
- # Thresholding
109
- y_pred = np.where(y_pred > 0.4, y_pred, 0)
110
-
111
- plot_prediction(y_pred)
112
-
113
- # ccd = CCDData(pred, unit="adu", wcs=wcs)
114
- # ccd.write(f"predicted.fits", overwrite=True)
115
-
116
- # if st.button('Download FITS File'):
117
- # with open('predicted.fits', 'rb') as f:
118
- # data = f.read()
119
- # st.download_button(label="Download", data=data, file_name="predicted.fits", mime="application/octet-stream")
 
 
 
 
 
 
 
 
 
 
 
 
79
  col2.subheader("CADET prediction")
80
 
81
  with col1:
82
+ col1_1, col1_2 = st.columns(2)
83
+
84
+ with col1_2:
85
+ st.Button("Smooth")
86
+
87
+ with col1_1:
88
+ st.markdown(
89
+ """<style>[data-baseweb="select"] {margin-top: -50px;}</style>""",
90
+ unsafe_allow_html=True
91
+ )
92
+
93
+ max_scale = int(data.shape[0] // 128)
94
+ # scale = st.slider("Scale", 1, max_scale, 1, 1)
95
+ scale = int(st.selectbox('Scale:',[i+1 for i in range(max_scale)], label_visibility="hidden"))
96
+
97
  # Add a slider to change the scale
98
  with col1:
99
  plot_image(np.log10(data+1), scale)
100
 
101
  with col2:
102
+ col2_1, col2_2 = st.columns(2)
 
103
 
104
+ with col2_1:
105
+ if st.button('Detect cavities'):
106
+ data, wcs = cut(data, wcs, scale=scale)
 
 
 
 
 
107
 
108
+ image = np.log10(data+1)
109
+
110
+ y_pred = 0
111
+ for j in [0,1,2,3]:
112
+ rotated = np.rot90(image, j)
113
+ pred = model.predict(rotated.reshape(1, 128, 128, 1)).reshape(128 ,128)
114
+ pred = np.rot90(pred, -j)
115
+ y_pred += pred / 4
116
+
117
+ # Thresholding
118
+ y_pred = np.where(y_pred > 0.4, y_pred, 0)
119
+
120
+ with col2:
121
+ plot_prediction(y_pred)
122
+
123
+ ccd = CCDData(pred, unit="adu", wcs=wcs)
124
+ ccd.write(f"predicted.fits", overwrite=True)
125
+
126
+ with col2_2:
127
+ if st.button('Download FITS File'):
128
+ with open('predicted.fits', 'rb') as f:
129
+ data = f.read()
130
+ st.download_button(label="Download", data=data, file_name="predicted.fits", mime="application/octet-stream")