Plsek commited on
Commit
3138cd3
·
1 Parent(s): 57f9dda

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -20
app.py CHANGED
@@ -44,14 +44,16 @@ def plot_image(image, scale):
44
  plt.gca().add_patch(Rectangle((x0, x0), scale*128, scale*128, linewidth=1, edgecolor='w', facecolor='none'))
45
 
46
  plt.axis('off')
47
- with colA: st.pyplot()
 
48
 
49
  # Define function to plot the prediction
50
  def plot_prediction(pred):
51
  plt.figure(figsize=(4, 4))
52
  plt.imshow(pred, origin="lower")
53
  plt.axis('off')
54
- with colB: st.pyplot()
 
55
 
56
  # Cut input image and rebin it to 128x128 pixels
57
  def cut(data0, wcs0, scale=1):
@@ -133,26 +135,26 @@ if uploaded_file is not None:
133
  _, colA, colB, colC, _ = st.columns([bordersize,1,1,1,bordersize])
134
 
135
  image = np.log10(data+1)
136
- plot_image(image, scale)
137
-
138
- # with colB:
139
- # threshold = st.slider("", 0.0, 1.0, 0.4, 0.05, label_visibility="hidden")
140
 
141
- # if detect:
142
- # data, wcs = cut(data, wcs, scale=scale)
143
- # image = np.log10(data+1)
144
 
145
- # y_pred = 0
146
- # for j in [0,1,2,3]:
147
- # rotated = np.rot90(image, j)
148
- # pred = model.predict(rotated.reshape(1, 128, 128, 1)).reshape(128 ,128)
149
- # pred = np.rot90(pred, -j)
150
- # y_pred += pred / 4
151
-
152
- # # Thresholding
153
- # y_pred = np.where(y_pred > threshold, y_pred, 0)
154
-
155
- # plot_prediction(y_pred)
 
 
156
 
157
  # if decompose:
158
  # cavs = decompose_cavity(y_pred, )
 
44
  plt.gca().add_patch(Rectangle((x0, x0), scale*128, scale*128, linewidth=1, edgecolor='w', facecolor='none'))
45
 
46
  plt.axis('off')
47
+ # with colA:
48
+ st.pyplot()
49
 
50
  # Define function to plot the prediction
51
  def plot_prediction(pred):
52
  plt.figure(figsize=(4, 4))
53
  plt.imshow(pred, origin="lower")
54
  plt.axis('off')
55
+ # with colB:
56
+ st.pyplot()
57
 
58
  # Cut input image and rebin it to 128x128 pixels
59
  def cut(data0, wcs0, scale=1):
 
135
  _, colA, colB, colC, _ = st.columns([bordersize,1,1,1,bordersize])
136
 
137
  image = np.log10(data+1)
138
+ with colA:
139
+ plot_image(image, scale)
 
 
140
 
141
+ if detect:
142
+ data, wcs = cut(data, wcs, scale=scale)
143
+ image = np.log10(data+1)
144
 
145
+ y_pred = 0
146
+ for j in [0,1,2,3]:
147
+ rotated = np.rot90(image, j)
148
+ pred = model.predict(rotated.reshape(1, 128, 128, 1)).reshape(128 ,128)
149
+ pred = np.rot90(pred, -j)
150
+ y_pred += pred / 4
151
+
152
+ # Thresholding
153
+ y_pred = np.where(y_pred > threshold, y_pred, 0)
154
+
155
+ with colB:
156
+ threshold = st.slider("", 0.0, 1.0, 0.4, 0.05, label_visibility="hidden")
157
+ plot_prediction(y_pred)
158
 
159
  # if decompose:
160
  # cavs = decompose_cavity(y_pred, )