Upload 5 files
Browse files- .gitattributes +1 -0
- CADET.hdf5 +3 -0
- README.md +7 -5
- app.py +47 -0
- requirements.txt +6 -0
.gitattributes
CHANGED
@@ -32,3 +32,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
32 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
32 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
35 |
+
CADET.hdf5 filter=lfs diff=lfs merge=lfs -text
|
CADET.hdf5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b2f01be82295c74f412fb77b74155f6c4e971bf62fe956f646e83f1636fadaa6
|
3 |
+
size 7423136
|
README.md
CHANGED
@@ -1,9 +1,11 @@
|
|
1 |
---
|
2 |
-
title: CADET
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
-
sdk:
|
|
|
|
|
7 |
pinned: false
|
8 |
---
|
9 |
|
|
|
1 |
---
|
2 |
+
title: CADET Streamlit
|
3 |
+
emoji: 🔥
|
4 |
+
colorFrom: pink
|
5 |
+
colorTo: pink
|
6 |
+
sdk: streamlit
|
7 |
+
sdk_version: 1.17.0
|
8 |
+
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
11 |
|
app.py
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
7 |
+
from tensorflow.keras.models import load_model
|
8 |
+
|
9 |
+
st.set_option('deprecation.showPyplotGlobalUse', False)
|
10 |
+
|
11 |
+
st.title("FITS Image Viewer")
|
12 |
+
|
13 |
+
model = load_model("CADET.hdf5")
|
14 |
+
|
15 |
+
# Define function to plot the uploaded image
|
16 |
+
def plot_image(image_array, pred):
|
17 |
+
plt.figure(figsize=(10, 5))
|
18 |
+
plt.subplot(1, 2, 1)
|
19 |
+
plt.imshow(image_array, origin="lower")
|
20 |
+
plt.axis('off')
|
21 |
+
|
22 |
+
plt.subplot(1, 2, 2)
|
23 |
+
plt.imshow(pred, origin="lower")
|
24 |
+
plt.axis('off')
|
25 |
+
st.pyplot()
|
26 |
+
|
27 |
+
def cut(data0, wcs0, scale=1):
|
28 |
+
shape = data0.shape[0]
|
29 |
+
x0 = shape / 2
|
30 |
+
size = 128 * scale
|
31 |
+
cutout = Cutout2D(data0, (x0, x0), (size, size), wcs=wcs0)
|
32 |
+
return cutout.data, cutout.wcs
|
33 |
+
|
34 |
+
# Create file uploader widget
|
35 |
+
uploaded_file = st.file_uploader("Choose a FITS file", type=['fits'])
|
36 |
+
|
37 |
+
# If file is uploaded, read in the data and plot it
|
38 |
+
if uploaded_file is not None:
|
39 |
+
with fits.open(uploaded_file) as hdul:
|
40 |
+
data = hdul[0].data
|
41 |
+
wcs = WCS(hdul[0].header)
|
42 |
+
data, wcs = cut(data, wcs, scale=1)
|
43 |
+
|
44 |
+
image_data = np.log10(data+1)
|
45 |
+
pred = model.predict(image_data.reshape(1, 128, 128, 1)).reshape(128 ,128)
|
46 |
+
|
47 |
+
plot_image(image_data, pred)
|
requirements.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
matplotlib==3.5.3
|
2 |
+
numpy==1.23.2
|
3 |
+
scipy==1.9.0
|
4 |
+
astropy==5.0.4
|
5 |
+
keras==2.8.0
|
6 |
+
tensorflow==2.8.1
|