Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,7 @@ from PIL import Image
|
|
8 |
from torch.utils.data import Dataset, DataLoader
|
9 |
import streamlit as st
|
10 |
|
11 |
-
# Function to extract zip
|
12 |
def extract_zip(zip_file, extract_to):
|
13 |
with zipfile.ZipFile(zip_file, 'r') as zip_ref:
|
14 |
zip_ref.extractall(extract_to)
|
@@ -41,7 +41,7 @@ def prepare_dataset(extracted_folder):
|
|
41 |
labels = []
|
42 |
for disease_folder in ['alzheimers_dataset', 'parkinsons_dataset', 'ms']:
|
43 |
folder_path = os.path.join(extracted_folder, disease_folder)
|
44 |
-
label = {'
|
45 |
for img_file in os.listdir(folder_path):
|
46 |
if img_file.endswith(('.nii', '.jpg', '.jpeg')):
|
47 |
image_paths.append(os.path.join(folder_path, img_file))
|
@@ -86,16 +86,14 @@ def fine_tune_model(train_loader):
|
|
86 |
# Streamlit UI for Fine-tuning
|
87 |
st.title("Fine-tune ViT on MRI/CT Scans for MS & Neurodegenerative Diseases")
|
88 |
|
89 |
-
|
90 |
-
zip_file_2 = "https://huggingface.co/spaces/Tanusree88/ViT-MRI-FineTuning/resolve/main/MS.zip"
|
91 |
|
92 |
if st.button("Start Training"):
|
93 |
extraction_dir = "extracted_files"
|
94 |
os.makedirs(extraction_dir, exist_ok=True)
|
95 |
|
96 |
-
# Extract
|
97 |
-
extract_zip(
|
98 |
-
extract_zip(zip_file_2, extraction_dir)
|
99 |
|
100 |
# Prepare dataset
|
101 |
image_paths, labels = prepare_dataset(extraction_dir)
|
|
|
8 |
from torch.utils.data import Dataset, DataLoader
|
9 |
import streamlit as st
|
10 |
|
11 |
+
# Function to extract zip file
|
12 |
def extract_zip(zip_file, extract_to):
|
13 |
with zipfile.ZipFile(zip_file, 'r') as zip_ref:
|
14 |
zip_ref.extractall(extract_to)
|
|
|
41 |
labels = []
|
42 |
for disease_folder in ['alzheimers_dataset', 'parkinsons_dataset', 'ms']:
|
43 |
folder_path = os.path.join(extracted_folder, disease_folder)
|
44 |
+
label = {'alzheimers_dataset': 0, 'parkinsons_dataset': 1, 'ms': 2}[disease_folder]
|
45 |
for img_file in os.listdir(folder_path):
|
46 |
if img_file.endswith(('.nii', '.jpg', '.jpeg')):
|
47 |
image_paths.append(os.path.join(folder_path, img_file))
|
|
|
86 |
# Streamlit UI for Fine-tuning
|
87 |
st.title("Fine-tune ViT on MRI/CT Scans for MS & Neurodegenerative Diseases")
|
88 |
|
89 |
+
zip_file = "https://huggingface.co/spaces/Tanusree88/ViT-MRI-FineTuning/resolve/main/archive%20(5).zip"
|
|
|
90 |
|
91 |
if st.button("Start Training"):
|
92 |
extraction_dir = "extracted_files"
|
93 |
os.makedirs(extraction_dir, exist_ok=True)
|
94 |
|
95 |
+
# Extract the zip file
|
96 |
+
extract_zip(zip_file, extraction_dir)
|
|
|
97 |
|
98 |
# Prepare dataset
|
99 |
image_paths, labels = prepare_dataset(extraction_dir)
|