Spaces:
Runtime error
Runtime error
Update TumorModel.py
Browse files- TumorModel.py +1 -30
TumorModel.py
CHANGED
@@ -1,39 +1,10 @@
|
|
1 |
-
import torch.nn as nn
|
2 |
-
import torch
|
3 |
-
|
4 |
-
class TumorClassification(nn.Module):
|
5 |
-
def __init__(self):
|
6 |
-
super().__init__()
|
7 |
-
self.con1d = nn.Conv2d(1, 32, kernel_size=3, stride=1, padding=1)
|
8 |
-
self.con2d = nn.Conv2d(32, 64, kernel_size=3, stride=1, padding=1)
|
9 |
-
self.con3d = nn.Conv2d(64, 128, kernel_size=3, stride=1, padding=1)
|
10 |
-
|
11 |
-
self.pool = nn.MaxPool2d(kernel_size=2, stride=2)
|
12 |
-
|
13 |
-
self.fc1 = nn.Linear(128 * 26 * 26, 512) # Must match training input size (208x208 image)
|
14 |
-
self.fc2 = nn.Linear(512, 256)
|
15 |
-
self.output = nn.Linear(256, 4)
|
16 |
-
|
17 |
-
self.relu = nn.ReLU()
|
18 |
-
|
19 |
-
def forward(self, x):
|
20 |
-
x = self.pool(self.relu(self.con1d(x)))
|
21 |
-
x = self.pool(self.relu(self.con2d(x)))
|
22 |
-
x = self.pool(self.relu(self.con3d(x)))
|
23 |
-
x = x.view(x.size(0), -1)
|
24 |
-
x = self.relu(self.fc1(x))
|
25 |
-
x = self.relu(self.fc2(x))
|
26 |
-
x = self.output(x)
|
27 |
-
return x
|
28 |
-
|
29 |
-
|
30 |
class GliomaStageModel(nn.Module):
|
31 |
def __init__(self):
|
32 |
super().__init__()
|
33 |
self.fc1 = nn.Linear(9, 100)
|
34 |
self.fc2 = nn.Linear(100, 50)
|
35 |
self.fc3 = nn.Linear(50, 30)
|
36 |
-
self.out = nn.Linear(30,
|
37 |
|
38 |
def forward(self, x):
|
39 |
x = nn.functional.relu(self.fc1(x))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
class GliomaStageModel(nn.Module):
|
2 |
def __init__(self):
|
3 |
super().__init__()
|
4 |
self.fc1 = nn.Linear(9, 100)
|
5 |
self.fc2 = nn.Linear(100, 50)
|
6 |
self.fc3 = nn.Linear(50, 30)
|
7 |
+
self.out = nn.Linear(30, 2) # ✅ MATCHING saved model weights
|
8 |
|
9 |
def forward(self, x):
|
10 |
x = nn.functional.relu(self.fc1(x))
|