Plsek commited on
Commit
8120054
·
1 Parent(s): dd3e183

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -31
app.py CHANGED
@@ -29,22 +29,14 @@ def plot_image(image_array, scale):
29
  plt.gca().add_patch(Rectangle((x0, x0), scale*128, scale*128, linewidth=1, edgecolor='w', facecolor='none'))
30
 
31
  plt.axis('off')
32
- fig.set_size_inches((4,4))
33
- with col1:
34
- st.pyplot()
35
 
36
  # Define function to plot the prediction
37
- def plot_prediction(image_array, pred):
38
  plt.figure(figsize=(4, 4))
39
- # plt.subplot(1, 2, 1)
40
- # plt.imshow(image_array, origin="lower")
41
- # plt.axis('off')
42
-
43
- # plt.subplot(1, 2, 2)
44
  plt.imshow(pred, origin="lower")
45
  plt.axis('off')
46
- with col2:
47
- st.pyplot()
48
 
49
  def cut(data0, wcs0, scale=1):
50
  shape = data0.shape[0]
@@ -80,24 +72,25 @@ if uploaded_file is not None:
80
 
81
  plot_image(np.log10(data+1), scale)
82
 
83
- if st.button('Detect cavities'):
84
- data, wcs = cut(data, wcs, scale=scale)
 
 
 
85
 
86
- image_data = np.log10(data+1)
87
-
88
- y_pred = 0
89
- for j in [0,1,2,3]:
90
- rotated = np.rot90(image_data, j)
91
- pred = model.predict(rotated.reshape(1, 128, 128, 1)).reshape(128 ,128)
92
- pred = np.rot90(pred, -j)
93
- y_pred += pred / 4
94
-
95
- # ccd = CCDData(pred, unit="adu", wcs=wcs)
96
- # ccd.write(f"predicted.fits", overwrite=True)
97
-
98
- plot_prediction(image_data, y_pred)
99
-
100
- # if st.button('Download FITS File'):
101
- # with open('predicted.fits', 'rb') as f:
102
- # data = f.read()
103
- # st.download_button(label="Download", data=data, file_name="predicted.fits", mime="application/octet-stream")
 
29
  plt.gca().add_patch(Rectangle((x0, x0), scale*128, scale*128, linewidth=1, edgecolor='w', facecolor='none'))
30
 
31
  plt.axis('off')
32
+ with col1: st.pyplot()
 
 
33
 
34
  # Define function to plot the prediction
35
+ def plot_prediction(pred):
36
  plt.figure(figsize=(4, 4))
 
 
 
 
 
37
  plt.imshow(pred, origin="lower")
38
  plt.axis('off')
39
+ with col2: st.pyplot()
 
40
 
41
  def cut(data0, wcs0, scale=1):
42
  shape = data0.shape[0]
 
72
 
73
  plot_image(np.log10(data+1), scale)
74
 
75
+ with col2:
76
+ if st.button('Detect cavities'):
77
+ data, wcs = cut(data, wcs, scale=scale)
78
+
79
+ image_data = np.log10(data+1)
80
 
81
+ y_pred = 0
82
+ for j in [0,1,2,3]:
83
+ rotated = np.rot90(image_data, j)
84
+ pred = model.predict(rotated.reshape(1, 128, 128, 1)).reshape(128 ,128)
85
+ pred = np.rot90(pred, -j)
86
+ y_pred += pred / 4
87
+
88
+ # ccd = CCDData(pred, unit="adu", wcs=wcs)
89
+ # ccd.write(f"predicted.fits", overwrite=True)
90
+
91
+ plot_prediction(y_pred)
92
+
93
+ # if st.button('Download FITS File'):
94
+ # with open('predicted.fits', 'rb') as f:
95
+ # data = f.read()
96
+ # st.download_button(label="Download", data=data, file_name="predicted.fits", mime="application/octet-stream")