Spaces:
Runtime error
Runtime error
Update utils.py
Browse files
utils.py
CHANGED
@@ -1,4 +1,10 @@
|
|
1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
class BrainTumorModel(nn.Module):
|
3 |
def __init__(self):
|
4 |
super(BrainTumorModel, self).__init__()
|
@@ -10,15 +16,14 @@ class BrainTumorModel(nn.Module):
|
|
10 |
nn.ReLU(),
|
11 |
nn.MaxPool2d(2),
|
12 |
nn.Flatten(),
|
13 |
-
nn.Linear(32 * 56 * 56, 128),
|
14 |
nn.ReLU(),
|
15 |
-
nn.Linear(128, 4) # 4 classes
|
16 |
)
|
17 |
|
18 |
def forward(self, x):
|
19 |
return self.model(x)
|
20 |
|
21 |
-
# Glioma Stage Detection Model
|
22 |
class GliomaStageModel(nn.Module):
|
23 |
def __init__(self):
|
24 |
super(GliomaStageModel, self).__init__()
|
@@ -39,35 +44,14 @@ class GliomaStageModel(nn.Module):
|
|
39 |
return self.model(x)
|
40 |
|
41 |
# ================================
|
42 |
-
#
|
43 |
-
# ================================
|
44 |
-
|
45 |
-
def get_user_test_data():
|
46 |
-
print("Enter the following details for prediction:")
|
47 |
-
|
48 |
-
gender_input = input("Gender (M/F): ").strip().lower()
|
49 |
-
gender = 0 if gender_input == 'm' else 1 # Male = 0, Female = 1
|
50 |
-
|
51 |
-
age = float(input("Age at Diagnosis: "))
|
52 |
-
|
53 |
-
idh1 = int(input("IDH1 Mutation? (1 for Yes, 0 for No): "))
|
54 |
-
tp53 = int(input("TP53 Mutation? (1 for Yes, 0 for No): "))
|
55 |
-
atrx = int(input("ATRX Mutation? (1 for Yes, 0 for No): "))
|
56 |
-
pten = int(input("PTEN Mutation? (1 for Yes, 0 for No): "))
|
57 |
-
egfr = int(input("EGFR Mutation? (1 for Yes, 0 for No): "))
|
58 |
-
cic = int(input("CIC Mutation? (1 for Yes, 0 for No): "))
|
59 |
-
pik3ca = int(input("PIK3CA Mutation? (1 for Yes, 0 for No): "))
|
60 |
-
|
61 |
-
return [gender, age, idh1, tp53, atrx, pten, egfr, cic, pik3ca]
|
62 |
-
|
63 |
-
# ================================
|
64 |
-
# 🩺 TUMOR PRECAUTIONS
|
65 |
# ================================
|
66 |
|
67 |
def get_precautions_from_gemini(tumor_type):
|
68 |
precaution_db = {
|
69 |
"meningioma": "Avoid radiation exposure and get regular check-ups.",
|
70 |
"pituitary": "Monitor hormonal levels and follow medication strictly.",
|
71 |
-
"notumor": "Stay healthy and get annual MRI scans if symptoms appear."
|
|
|
72 |
}
|
73 |
-
return precaution_db.get(tumor_type.lower(), "No specific precautions found.")
|
|
|
1 |
+
import torch
|
2 |
+
import torch.nn as nn
|
3 |
+
|
4 |
+
# ================================
|
5 |
+
# 🧠 MODEL CLASSES
|
6 |
+
# ================================
|
7 |
+
|
8 |
class BrainTumorModel(nn.Module):
|
9 |
def __init__(self):
|
10 |
super(BrainTumorModel, self).__init__()
|
|
|
16 |
nn.ReLU(),
|
17 |
nn.MaxPool2d(2),
|
18 |
nn.Flatten(),
|
19 |
+
nn.Linear(32 * 56 * 56, 128),
|
20 |
nn.ReLU(),
|
21 |
+
nn.Linear(128, 4) # 4 tumor classes
|
22 |
)
|
23 |
|
24 |
def forward(self, x):
|
25 |
return self.model(x)
|
26 |
|
|
|
27 |
class GliomaStageModel(nn.Module):
|
28 |
def __init__(self):
|
29 |
super(GliomaStageModel, self).__init__()
|
|
|
44 |
return self.model(x)
|
45 |
|
46 |
# ================================
|
47 |
+
# 💡 PRECAUTIONS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
# ================================
|
49 |
|
50 |
def get_precautions_from_gemini(tumor_type):
|
51 |
precaution_db = {
|
52 |
"meningioma": "Avoid radiation exposure and get regular check-ups.",
|
53 |
"pituitary": "Monitor hormonal levels and follow medication strictly.",
|
54 |
+
"notumor": "Stay healthy and get annual MRI scans if symptoms appear.",
|
55 |
+
"glioma": "Maintain a healthy lifestyle and follow up with neuro-oncologist."
|
56 |
}
|
57 |
+
return precaution_db.get(tumor_type.lower(), "No specific precautions found.")
|