bytchew commited on
Commit
3bfb590
·
verified ·
1 Parent(s): a0cbd2e

Upload model.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. model.py +16 -0
model.py ADDED
@@ -0,0 +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, 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