-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmodel.py
41 lines (27 loc) · 1.07 KB
/
model.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import config
from torchvision import models
import torch.nn as nn
from torchsummary import summary
# preprocessing done in dataset_prep
def resnet_model_50():
resnet = models.resnet50(pretrained = True)
# Already Trained Parameters will not train
for param in resnet.parameters():
param.requires_grad = False
in_features = resnet.fc.in_features
# Changing the last layer according to the classes
fc = nn.Linear(in_features = in_features, out_features = config.N_CLASSES)
resnet.fc = fc
summary(resnet.to(config.DEVICE), input_size = (3, 224, 224))
return (resnet)
def resnet_model_101():
resnet = models.resnet101(pretrained = True)
# Already Trained Parameters will not train
for param in resnet.parameters():
param.requires_grad = False
in_features = resnet.fc.in_features
# Changing the last layer according to the classes
fc = nn.Linear(in_features = in_features, out_features = config.N_CLASSES)
resnet.fc = fc
summary(resnet.to(config.DEVICE), input_size = (3, 224, 224))
return (resnet)