Spaces:
Runtime error
Runtime error
Download TumorModel.py from Codewithsalty/brain-tumor-predictor: direct link, hf CLI and curl.
- Browser
- Download file 1.29 kB
-
https://huggingface.co/spaces/Codewithsalty/brain-tumor-predictor/resolve/81484f118b687d890ad9cf9523da6c6874d9d8c4/TumorModel.py
- Command line
-
hf download hf://spaces/Codewithsalty/brain-tumor-predictor@81484f118b687d890ad9cf9523da6c6874d9d8c4/TumorModel.py
-
curl -L -o TumorModel.py https://huggingface.co/spaces/Codewithsalty/brain-tumor-predictor/resolve/81484f118b687d890ad9cf9523da6c6874d9d8c4/TumorModel.py
1.29 kB
| import torch.nn as nn | |
| class TumorClassification(nn.Module): | |
| def __init__(self): | |
| super().__init__() | |
| self.con1d = nn.Conv2d(1, 32, kernel_size=3, padding=1) | |
| self.con2d = nn.Conv2d(32, 64, kernel_size=3, padding=1) | |
| self.con3d = nn.Conv2d(64, 128, kernel_size=3, padding=1) | |
| self.pool = nn.MaxPool2d(2, 2) | |
| self.fc1 = nn.Linear(128 * 28 * 28, 512) | |
| self.fc2 = nn.Linear(512, 256) | |
| self.output = nn.Linear(256, 4) | |
| def forward(self, x): | |
| x = nn.functional.relu(self.pool(self.con1d(x))) | |
| x = nn.functional.relu(self.pool(self.con2d(x))) | |
| x = nn.functional.relu(self.pool(self.con3d(x))) | |
| x = x.view(x.size(0), -1) | |
| x = nn.functional.relu(self.fc1(x)) | |
| x = nn.functional.relu(self.fc2(x)) | |
| return self.output(x) | |
| class GliomaStageModel(nn.Module): | |
| def __init__(self): | |
| super().__init__() | |
| self.fc1 = nn.Linear(9, 100) | |
| self.fc2 = nn.Linear(100, 50) | |
| self.fc3 = nn.Linear(50, 30) | |
| self.out = nn.Linear(30, 2) # ✅ Make sure this matches your trained model | |
| def forward(self, x): | |
| x = nn.functional.relu(self.fc1(x)) | |
| x = nn.functional.relu(self.fc2(x)) | |
| x = nn.functional.relu(self.fc3(x)) | |
| return self.out(x) | |