bytchew commited on
Commit
64a41ee
·
verified ·
1 Parent(s): 09b4bcb

Upload model.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. model.py +15 -15
model.py CHANGED
@@ -1,16 +1,16 @@
1
- import torch
2
- import torch.nn as nn
3
- from torchvision import models
4
-
5
-
6
- def load_model(pretrained_weights_path):
7
- # Initialize Face-Rego
8
- net = models.resnet18(pretrained=False)
9
- num_ftrs = net.fc.in_features
10
- net.fc = nn.Linear(num_ftrs, 100) # Match your fine-tuned setup
11
-
12
- # Load weights
13
- state_dict = torch.load(pretrained_weights_path, map_location=torch.device('cpu'))
14
- net.load_state_dict(state_dict)
15
- net.eval() # Set to evaluation mode
16
  return net
 
1
+ import torch
2
+ import torch.nn as nn
3
+ from torchvision import models
4
+
5
+
6
+ def load_model(pretrained_weights_path):
7
+ # Initialize Face-Rego
8
+ net = models.resnet18(pretrained=False)
9
+ num_ftrs = net.fc.in_features
10
+ net.fc = nn.Linear(num_ftrs, 128) # Match your fine-tuned setup
11
+
12
+ # Load weights
13
+ state_dict = torch.load(pretrained_weights_path, map_location=torch.device('cpu'))
14
+ net.load_state_dict(state_dict)
15
+ net.eval() # Set to evaluation mode
16
  return net