Sayed223 commited on
Commit
2a16572
·
verified ·
1 Parent(s): a97991a

Update model.py

Browse files
Files changed (1) hide show
  1. model.py +18 -17
model.py CHANGED
@@ -1,17 +1,18 @@
1
- # model.py
2
- import torch.nn as nn
3
- from torchvision.models import resnet18
4
-
5
- def get_model(num_classes, pretrained=True):
6
- """
7
- Returns a CNN model adapted for grayscale ECG images
8
- """
9
- model = resnet18(pretrained=pretrained)
10
-
11
- # Change first layer to accept 1-channel input (grayscale)
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.Linear(model.fc.in_features, num_classes)
16
-
17
- return model
 
 
1
+ # model.py
2
+ import torch.nn as nn
3
+ from torchvision.models import resnet18
4
+
5
+ def get_model(num_classes, pretrained=True):
6
+ """
7
+ Returns a CNN model adapted for grayscale ECG images
8
+ """
9
+ model = resnet18(pretrained=pretrained)
10
+
11
+ # Change first layer to accept 1-channel input (grayscale)
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
+ Linear(model.fc.in_features, num_classes)
17
+
18
+ return model