Spaces:
Sleeping
Sleeping
Update model.py
Browse files
model.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
# model.py
|
| 2 |
import torch.nn as nn
|
| 3 |
from torchvision.models import resnet18
|
| 4 |
|
|
@@ -12,7 +11,22 @@ def get_model(num_classes, pretrained=True):
|
|
| 12 |
model.conv1 = nn.Conv2d(1, 64, kernel_size=7, stride=2, padding=3, bias=False)
|
| 13 |
|
| 14 |
# Change the output layer for our number of classes
|
| 15 |
-
model.fc = nn
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
return model
|
|
|
|
|
|
|
| 1 |
import torch.nn as nn
|
| 2 |
from torchvision.models import resnet18
|
| 3 |
|
|
|
|
| 11 |
model.conv1 = nn.Conv2d(1, 64, kernel_size=7, stride=2, padding=3, bias=False)
|
| 12 |
|
| 13 |
# Change the output layer for our number of classes
|
| 14 |
+
model.fc = nn.Linear(model.fc.in_features, num_classes)
|
| 15 |
+
|
| 16 |
+
return model
|
| 17 |
+
import torch.nn as nn
|
| 18 |
+
from torchvision.models import resnet18
|
| 19 |
+
|
| 20 |
+
def get_model(num_classes, pretrained=True):
|
| 21 |
+
"""
|
| 22 |
+
Returns a CNN model adapted for grayscale ECG images
|
| 23 |
+
"""
|
| 24 |
+
model = resnet18(pretrained=pretrained)
|
| 25 |
+
|
| 26 |
+
# Change first layer to accept 1-channel input (grayscale)
|
| 27 |
+
model.conv1 = nn.Conv2d(1, 64, kernel_size=7, stride=2, padding=3, bias=False)
|
| 28 |
+
|
| 29 |
+
# Change the output layer for our number of classes
|
| 30 |
+
model.fc = nn.Linear(model.fc.in_features, num_classes)
|
| 31 |
|
| 32 |
return model
|