Spaces:
Runtime error
Runtime error
import torch | |
import torch.nn as nn | |
# ================================ | |
# 🧠 MODEL CLASSES | |
# ================================ | |
class BrainTumorModel(nn.Module): | |
def __init__(self): | |
super(BrainTumorModel, self).__init__() | |
self.model = nn.Sequential( | |
nn.Conv2d(3, 16, kernel_size=3, stride=1, padding=1), | |
nn.ReLU(), | |
nn.MaxPool2d(2), | |
nn.Conv2d(16, 32, kernel_size=3, stride=1, padding=1), | |
nn.ReLU(), | |
nn.MaxPool2d(2), | |
nn.Flatten(), | |
nn.Linear(32 * 56 * 56, 128), | |
nn.ReLU(), | |
nn.Linear(128, 4) # 4 tumor classes | |
) | |
def forward(self, x): | |
return self.model(x) | |
class GliomaStageModel(nn.Module): | |
def __init__(self): | |
super(GliomaStageModel, self).__init__() | |
self.model = nn.Sequential( | |
nn.Conv2d(3, 16, kernel_size=3, stride=1, padding=1), | |
nn.ReLU(), | |
nn.MaxPool2d(2), | |
nn.Conv2d(16, 32, kernel_size=3, stride=1, padding=1), | |
nn.ReLU(), | |
nn.MaxPool2d(2), | |
nn.Flatten(), | |
nn.Linear(32 * 56 * 56, 128), | |
nn.ReLU(), | |
nn.Linear(128, 4) # 4 glioma stages | |
) | |
def forward(self, x): | |
return self.model(x) | |
# ================================ | |
# 💡 PRECAUTIONS | |
# ================================ | |
def get_precautions_from_gemini(tumor_type): | |
precaution_db = { | |
"meningioma": "Avoid radiation exposure and get regular check-ups.", | |
"pituitary": "Monitor hormonal levels and follow medication strictly.", | |
"notumor": "Stay healthy and get annual MRI scans if symptoms appear.", | |
"glioma": "Maintain a healthy lifestyle and follow up with neuro-oncologist." | |
} | |
return precaution_db.get(tumor_type.lower(), "No specific precautions found.") | |