Thomas Lucchetta
commited on
Add files via upload
Browse files
app.py
CHANGED
@@ -18,7 +18,7 @@ from statistics import mean
|
|
18 |
|
19 |
from constants import CLASSES
|
20 |
from model.download_model import load_model
|
21 |
-
from
|
22 |
|
23 |
#SET PAGE TITLE
|
24 |
st.set_page_config(page_title = "Alzheimer Classifier", page_icon = ":brain:", layout = "wide")
|
@@ -26,9 +26,6 @@ st.set_page_config(page_title = "Alzheimer Classifier", page_icon = ":brain:", l
|
|
26 |
#LOAD MODEL
|
27 |
model = load_model()
|
28 |
|
29 |
-
#LOAD IMAGES
|
30 |
-
download_images()
|
31 |
-
|
32 |
#SET NIFTI FILE LOADING AND PROCESSING CONFIGURATIONS
|
33 |
transforms = Compose([
|
34 |
ScaleIntensity(),
|
@@ -91,7 +88,7 @@ with st.container():
|
|
91 |
if st.session_state.clicked_pp:
|
92 |
if st.session_state.clicked_pred == False:
|
93 |
with st.container():
|
94 |
-
pred_image = nib.load(
|
95 |
|
96 |
bounds_pred = plotting.find_cuts._get_auto_mask_bounds(pred_image)
|
97 |
|
@@ -105,7 +102,7 @@ with st.container():
|
|
105 |
|
106 |
else:
|
107 |
with st.container():
|
108 |
-
pred_image = nib.load(
|
109 |
|
110 |
bounds_pred = plotting.find_cuts._get_auto_mask_bounds(pred_image)
|
111 |
|
@@ -114,7 +111,7 @@ with st.container():
|
|
114 |
x_value_pred = st.sidebar.slider('Move the slider to adjust the sagittal cut ', bounds_pred[0][0], bounds_pred[0][1], mean([bounds_pred[0][0], bounds_pred[0][1]]))
|
115 |
z_value_pred = st.sidebar.slider('Move the slider to adjust the axial cut ', bounds_pred[2][0], bounds_pred[2][1], mean([bounds_pred[2][0], bounds_pred[2][1]]))
|
116 |
|
117 |
-
img_array = load_img(
|
118 |
new_data = transforms(img_array)
|
119 |
new_data_tensor = torch.from_numpy(np.array([new_data]))
|
120 |
|
@@ -156,7 +153,7 @@ with st.container():
|
|
156 |
st.pyplot()
|
157 |
|
158 |
else:
|
159 |
-
raw_image = nib.load(
|
160 |
|
161 |
bounds_raw = plotting.find_cuts._get_auto_mask_bounds(raw_image)
|
162 |
|
|
|
18 |
|
19 |
from constants import CLASSES
|
20 |
from model.download_model import load_model
|
21 |
+
from huggingface_hub import hf_hub_download
|
22 |
|
23 |
#SET PAGE TITLE
|
24 |
st.set_page_config(page_title = "Alzheimer Classifier", page_icon = ":brain:", layout = "wide")
|
|
|
26 |
#LOAD MODEL
|
27 |
model = load_model()
|
28 |
|
|
|
|
|
|
|
29 |
#SET NIFTI FILE LOADING AND PROCESSING CONFIGURATIONS
|
30 |
transforms = Compose([
|
31 |
ScaleIntensity(),
|
|
|
88 |
if st.session_state.clicked_pp:
|
89 |
if st.session_state.clicked_pred == False:
|
90 |
with st.container():
|
91 |
+
pred_image = nib.load(hf_hub_download(repo_type="dataset", subfolder="preprocessed", filename = img_path + ".nii.gz"))
|
92 |
|
93 |
bounds_pred = plotting.find_cuts._get_auto_mask_bounds(pred_image)
|
94 |
|
|
|
102 |
|
103 |
else:
|
104 |
with st.container():
|
105 |
+
pred_image = nib.load(hf_hub_download(repo_type="dataset", subfolder="preprocessed", filename = img_path + ".nii.gz"))
|
106 |
|
107 |
bounds_pred = plotting.find_cuts._get_auto_mask_bounds(pred_image)
|
108 |
|
|
|
111 |
x_value_pred = st.sidebar.slider('Move the slider to adjust the sagittal cut ', bounds_pred[0][0], bounds_pred[0][1], mean([bounds_pred[0][0], bounds_pred[0][1]]))
|
112 |
z_value_pred = st.sidebar.slider('Move the slider to adjust the axial cut ', bounds_pred[2][0], bounds_pred[2][1], mean([bounds_pred[2][0], bounds_pred[2][1]]))
|
113 |
|
114 |
+
img_array = load_img(hf_hub_download(repo_type="dataset", subfolder="preprocessed", filename = img_path + ".nii.gz"))
|
115 |
new_data = transforms(img_array)
|
116 |
new_data_tensor = torch.from_numpy(np.array([new_data]))
|
117 |
|
|
|
153 |
st.pyplot()
|
154 |
|
155 |
else:
|
156 |
+
raw_image = nib.load(hf_hub_download(repo_type="dataset", subfolder="raw", filename = img_path + ".nii"))
|
157 |
|
158 |
bounds_raw = plotting.find_cuts._get_auto_mask_bounds(raw_image)
|
159 |
|