-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmodel.py
More file actions
24 lines (19 loc) · 699 Bytes
/
Copy pathmodel.py
File metadata and controls
24 lines (19 loc) · 699 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import torch
import torch.nn as nn
import torch.optim as optim
from torch.utils.data import DataLoader
from torchvision import datasets, transforms
import cv2
import torchvision.models as models #To load the ResNet model from the torchvision
DEVICE = 'cuda'
#Import the models you want from torchvision or write from scratch
model = models.resnet18(pretrained = True)
for param in model.parameters():
param.requires_grad = True
model.fc = nn.Sequential(
nn.Linear(512, 128),
nn.ReLU(inplace=True),
nn.Linear(128, 7))
# cl_model = model
cl_model = model #For the ResNet pre-trained network
cl_model.to(DEVICE) #Load the models to GPU