Michael Rey commited on
Commit
eb6a8a0
·
1 Parent(s): 4d6d4c8

resolving path cannot be found problem

Browse files
Files changed (1) hide show
  1. src/resnet_model.py +17 -0
src/resnet_model.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch.nn as nn
2
+ from torchvision import models
3
+
4
+ # Custom ResNet model for monkey classification
5
+ class MonkeyResNet(nn.Module):
6
+ def __init__(self, num_classes):
7
+ super(MonkeyResNet, self).__init__()
8
+
9
+ # Load pretrained ResNet18 model from torchvision
10
+ self.model = models.resnet18(pretrained=True) # pretrained weights from ImageNet
11
+
12
+ # Replace the final fully connected layer to match number of classes
13
+ in_features = self.model.fc.in_features
14
+ self.model.fc = nn.Linear(in_features, num_classes)
15
+
16
+ def forward(self, x):
17
+ return self.model(x) # run input through the model