Update app.py
Browse files
app.py
CHANGED
@@ -18,11 +18,11 @@ def plot_image(image_array, scale):
|
|
18 |
# st.set_plot_config(plt, figsize=(4, 4))
|
19 |
plt.figure(figsize=(4, 4))
|
20 |
# plt.subplot(1, 2, 1)
|
21 |
-
x0 = image_array.shape[0] // 2 - scale * 128 /
|
22 |
plt.imshow(image_array, origin="lower")
|
23 |
plt.gca().add_patch(Rectangle((x0, x0), scale*128, scale*128, linewidth=1, edgecolor='w', facecolor='none'))
|
24 |
plt.axis('off')
|
25 |
-
st.pyplot(width=
|
26 |
|
27 |
# Define function to plot the prediction
|
28 |
def plot_prediction(image_array, pred):
|
@@ -35,7 +35,7 @@ def plot_prediction(image_array, pred):
|
|
35 |
plt.subplot(1, 2, 2)
|
36 |
plt.imshow(pred, origin="lower")
|
37 |
plt.axis('off')
|
38 |
-
st.pyplot(width=
|
39 |
|
40 |
def cut(data0, wcs0, scale=1):
|
41 |
shape = data0.shape[0]
|
@@ -73,14 +73,19 @@ if uploaded_file is not None:
|
|
73 |
|
74 |
plot_image(np.log10(data+1), scale)
|
75 |
|
76 |
-
if st.button('Detect
|
77 |
data, wcs = cut(data, wcs, scale=scale)
|
78 |
|
79 |
image_data = np.log10(data+1)
|
80 |
|
81 |
-
|
|
|
|
|
|
|
|
|
|
|
82 |
|
83 |
# ccd = CCDData(pred, unit="adu", wcs=wcs)
|
84 |
# ccd.write(f"predicted.fits", overwrite=True)
|
85 |
|
86 |
-
plot_prediction(image_data,
|
|
|
18 |
# st.set_plot_config(plt, figsize=(4, 4))
|
19 |
plt.figure(figsize=(4, 4))
|
20 |
# plt.subplot(1, 2, 1)
|
21 |
+
x0 = image_array.shape[0] // 2 - scale * 128 / 2
|
22 |
plt.imshow(image_array, origin="lower")
|
23 |
plt.gca().add_patch(Rectangle((x0, x0), scale*128, scale*128, linewidth=1, edgecolor='w', facecolor='none'))
|
24 |
plt.axis('off')
|
25 |
+
st.pyplot(width=200)
|
26 |
|
27 |
# Define function to plot the prediction
|
28 |
def plot_prediction(image_array, pred):
|
|
|
35 |
plt.subplot(1, 2, 2)
|
36 |
plt.imshow(pred, origin="lower")
|
37 |
plt.axis('off')
|
38 |
+
st.pyplot(width=400)
|
39 |
|
40 |
def cut(data0, wcs0, scale=1):
|
41 |
shape = data0.shape[0]
|
|
|
73 |
|
74 |
plot_image(np.log10(data+1), scale)
|
75 |
|
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, 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(image_data, y_pred)
|