Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import numpy as np
|
| 3 |
import matplotlib.pyplot as plt
|
|
|
|
| 4 |
from astropy.io import fits
|
| 5 |
from astropy.wcs import WCS
|
| 6 |
from astropy.nddata import Cutout2D, CCDData
|
|
@@ -16,8 +17,11 @@ model = load_model("CADET.hdf5")
|
|
| 16 |
def plot_image(image_array, scale):
|
| 17 |
plt.figure(figsize=(5, 5))
|
| 18 |
# plt.subplot(1, 2, 1)
|
|
|
|
| 19 |
plt.imshow(image_array, origin="lower")
|
|
|
|
| 20 |
plt.axis('off')
|
|
|
|
| 21 |
|
| 22 |
# Define function to plot the prediction
|
| 23 |
def plot_prediction(image_array, pred):
|
|
@@ -56,15 +60,15 @@ def cut(data0, wcs0, scale=1):
|
|
| 56 |
# Create file uploader widget
|
| 57 |
uploaded_file = st.file_uploader("Choose a FITS file", type=['fits'])
|
| 58 |
|
| 59 |
-
# Add a slider to change the scale
|
| 60 |
-
scale = st.slider("Scale", 1, 4, 1, 1)
|
| 61 |
-
|
| 62 |
# If file is uploaded, read in the data and plot it
|
| 63 |
if uploaded_file is not None:
|
| 64 |
with fits.open(uploaded_file) as hdul:
|
| 65 |
data = hdul[0].data
|
| 66 |
wcs = WCS(hdul[0].header)
|
| 67 |
|
|
|
|
|
|
|
|
|
|
| 68 |
plot_image(np.log10(data+1), scale)
|
| 69 |
|
| 70 |
if st.button('Detect Cavity'):
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import numpy as np
|
| 3 |
import matplotlib.pyplot as plt
|
| 4 |
+
from matplotlib.patches import Rectangle
|
| 5 |
from astropy.io import fits
|
| 6 |
from astropy.wcs import WCS
|
| 7 |
from astropy.nddata import Cutout2D, CCDData
|
|
|
|
| 17 |
def plot_image(image_array, scale):
|
| 18 |
plt.figure(figsize=(5, 5))
|
| 19 |
# plt.subplot(1, 2, 1)
|
| 20 |
+
x0 = image_array.shape[0] // 2
|
| 21 |
plt.imshow(image_array, origin="lower")
|
| 22 |
+
plt.gca().add_patch(Rectangle((x0, x0), scale*128, scale*128, linewidth=1, edgecolor='w', facecolor='none'))
|
| 23 |
plt.axis('off')
|
| 24 |
+
st.pyplot()
|
| 25 |
|
| 26 |
# Define function to plot the prediction
|
| 27 |
def plot_prediction(image_array, pred):
|
|
|
|
| 60 |
# Create file uploader widget
|
| 61 |
uploaded_file = st.file_uploader("Choose a FITS file", type=['fits'])
|
| 62 |
|
|
|
|
|
|
|
|
|
|
| 63 |
# If file is uploaded, read in the data and plot it
|
| 64 |
if uploaded_file is not None:
|
| 65 |
with fits.open(uploaded_file) as hdul:
|
| 66 |
data = hdul[0].data
|
| 67 |
wcs = WCS(hdul[0].header)
|
| 68 |
|
| 69 |
+
# Add a slider to change the scale
|
| 70 |
+
scale = st.slider("Scale", 1, 4, 1, 1)
|
| 71 |
+
|
| 72 |
plot_image(np.log10(data+1), scale)
|
| 73 |
|
| 74 |
if st.button('Detect Cavity'):
|