Codewithsalty commited on
Commit
dfea2de
·
verified ·
1 Parent(s): a75fe7e

Update utils.py

Browse files
Files changed (1) hide show
  1. utils.py +55 -1
utils.py CHANGED
@@ -1,3 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  def get_user_test_data():
2
  print("Enter the following details for prediction:")
3
 
@@ -16,10 +66,14 @@ def get_user_test_data():
16
 
17
  return [gender, age, idh1, tp53, atrx, pten, egfr, cic, pik3ca]
18
 
 
 
 
 
19
  def get_precautions_from_gemini(tumor_type):
20
  precaution_db = {
21
  "meningioma": "Avoid radiation exposure and get regular check-ups.",
22
  "pituitary": "Monitor hormonal levels and follow medication strictly.",
23
  "notumor": "Stay healthy and get annual MRI scans if symptoms appear."
24
  }
25
- return precaution_db.get(tumor_type, "No specific precautions found.")
 
1
+ import torch.nn as nn
2
+
3
+ # ================================
4
+ # 🧠 MODEL CLASSES
5
+ # ================================
6
+
7
+ # Brain Tumor Detection Model
8
+ class BrainTumorModel(nn.Module):
9
+ def __init__(self):
10
+ super(BrainTumorModel, self).__init__()
11
+ self.model = nn.Sequential(
12
+ nn.Conv2d(3, 16, kernel_size=3, stride=1, padding=1),
13
+ nn.ReLU(),
14
+ nn.MaxPool2d(2),
15
+ nn.Conv2d(16, 32, kernel_size=3, stride=1, padding=1),
16
+ nn.ReLU(),
17
+ nn.MaxPool2d(2),
18
+ nn.Flatten(),
19
+ nn.Linear(32 * 56 * 56, 128), # Adjust if image size is different
20
+ nn.ReLU(),
21
+ nn.Linear(128, 4) # 4 classes
22
+ )
23
+
24
+ def forward(self, x):
25
+ return self.model(x)
26
+
27
+ # Glioma Stage Detection Model
28
+ class GliomaStageModel(nn.Module):
29
+ def __init__(self):
30
+ super(GliomaStageModel, self).__init__()
31
+ self.model = nn.Sequential(
32
+ nn.Conv2d(3, 16, kernel_size=3, stride=1, padding=1),
33
+ nn.ReLU(),
34
+ nn.MaxPool2d(2),
35
+ nn.Conv2d(16, 32, kernel_size=3, stride=1, padding=1),
36
+ nn.ReLU(),
37
+ nn.MaxPool2d(2),
38
+ nn.Flatten(),
39
+ nn.Linear(32 * 56 * 56, 128),
40
+ nn.ReLU(),
41
+ nn.Linear(128, 4) # 4 glioma stages
42
+ )
43
+
44
+ def forward(self, x):
45
+ return self.model(x)
46
+
47
+ # ================================
48
+ # 👤 USER INPUT FUNCTION
49
+ # ================================
50
+
51
  def get_user_test_data():
52
  print("Enter the following details for prediction:")
53
 
 
66
 
67
  return [gender, age, idh1, tp53, atrx, pten, egfr, cic, pik3ca]
68
 
69
+ # ================================
70
+ # 🩺 TUMOR PRECAUTIONS
71
+ # ================================
72
+
73
  def get_precautions_from_gemini(tumor_type):
74
  precaution_db = {
75
  "meningioma": "Avoid radiation exposure and get regular check-ups.",
76
  "pituitary": "Monitor hormonal levels and follow medication strictly.",
77
  "notumor": "Stay healthy and get annual MRI scans if symptoms appear."
78
  }
79
+ return precaution_db.get(tumor_type.lower(), "No specific precautions found.")