Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ import shutil
|
|
4 |
import numpy as np
|
5 |
from scipy.ndimage import center_of_mass
|
6 |
import matplotlib.pyplot as plt
|
7 |
-
from matplotlib.colors import Normalize
|
8 |
from matplotlib.patches import Rectangle
|
9 |
|
10 |
# Astropy
|
@@ -29,7 +29,7 @@ from huggingface_hub import from_pretrained_keras
|
|
29 |
def plot_image(image, scale):
|
30 |
plt.figure(figsize=(4, 4))
|
31 |
x0 = image.shape[0] // 2 - scale * 128 / 2
|
32 |
-
plt.imshow(image, origin="lower")
|
33 |
plt.gca().add_patch(Rectangle((x0-0.5, x0-0.5), scale*128, scale*128, linewidth=1, edgecolor='w', facecolor='none'))
|
34 |
plt.axis('off')
|
35 |
plt.tight_layout()
|
@@ -219,17 +219,14 @@ if uploaded_file is not None:
|
|
219 |
|
220 |
MIN = np.min(np.where(data == 0, 1, data))
|
221 |
if MIN < 1: data = data / MIN
|
222 |
-
image = np.log10(data+1)
|
223 |
|
224 |
if st.session_state.get("example", True):
|
225 |
fname = "NGC4649_example"
|
226 |
os.system(f'mkdir -p {fname}')
|
227 |
data, wcs = load_file(f"{fname}.fits")
|
228 |
-
image = np.log10(data+1)
|
229 |
|
230 |
if "data" not in locals():
|
231 |
data = np.zeros((128,128))
|
232 |
-
image = data
|
233 |
|
234 |
# Make six columns for buttons
|
235 |
_, col1, col2, col3, col4, col5, col6, _ = st.columns([bordersize,0.5,0.5,0.5,0.5,0.5,0.5,bordersize])
|
@@ -262,7 +259,7 @@ _, colA, colB, colC, _ = st.columns([bordersize,1,1,1,bordersize])
|
|
262 |
|
263 |
if "data" in locals():
|
264 |
# NORMALIZE IMAGE
|
265 |
-
plot_image(
|
266 |
|
267 |
if detect or threshold or st.session_state.get("decompose", False):
|
268 |
|
|
|
4 |
import numpy as np
|
5 |
from scipy.ndimage import center_of_mass
|
6 |
import matplotlib.pyplot as plt
|
7 |
+
from matplotlib.colors import Normalize, LogNorm
|
8 |
from matplotlib.patches import Rectangle
|
9 |
|
10 |
# Astropy
|
|
|
29 |
def plot_image(image, scale):
|
30 |
plt.figure(figsize=(4, 4))
|
31 |
x0 = image.shape[0] // 2 - scale * 128 / 2
|
32 |
+
plt.imshow(image, origin="lower", norm=LogNorm())
|
33 |
plt.gca().add_patch(Rectangle((x0-0.5, x0-0.5), scale*128, scale*128, linewidth=1, edgecolor='w', facecolor='none'))
|
34 |
plt.axis('off')
|
35 |
plt.tight_layout()
|
|
|
219 |
|
220 |
MIN = np.min(np.where(data == 0, 1, data))
|
221 |
if MIN < 1: data = data / MIN
|
|
|
222 |
|
223 |
if st.session_state.get("example", True):
|
224 |
fname = "NGC4649_example"
|
225 |
os.system(f'mkdir -p {fname}')
|
226 |
data, wcs = load_file(f"{fname}.fits")
|
|
|
227 |
|
228 |
if "data" not in locals():
|
229 |
data = np.zeros((128,128))
|
|
|
230 |
|
231 |
# Make six columns for buttons
|
232 |
_, col1, col2, col3, col4, col5, col6, _ = st.columns([bordersize,0.5,0.5,0.5,0.5,0.5,0.5,bordersize])
|
|
|
259 |
|
260 |
if "data" in locals():
|
261 |
# NORMALIZE IMAGE
|
262 |
+
plot_image(data, scale)
|
263 |
|
264 |
if detect or threshold or st.session_state.get("decompose", False):
|
265 |
|