-
Notifications
You must be signed in to change notification settings - Fork 0
/
Test Score.txt
47 lines (38 loc) · 1.33 KB
/
Test Score.txt
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
42
43
44
45
46
47
import torch
import time
import numpy as np
from torch import nn, optim
import torch.nn.functional as F
from torchvision import datasets, transforms, models
import torchvision
from collections import OrderedDict
from torch.autograd import Variable
from PIL import Image
import PIL
from torch.optim import lr_scheduler
import copy
import json
import os
from os.path import exists
import matplotlib.pyplot as plt
def load_checkpoint(filepath):
checkpoint = torch.load(filepath, map_location='cpu')
model = models.resnet152(pretrained=True)
for param in model.parameters():
param.requires_grad = False
# Our input_size matches the in_features of pretrained model
input_size = 2048
output_size = 102
classifier = nn.Sequential(nn.Dropout(p=0.5),
nn.Linear(2048,102))
# Replacing the pretrained model classifier with our classifier
model.fc = classifier
return model
# get index to class mapping
model = load_checkpoint('Swati_Checkpoint.pt')
# If you used something other than 224x224 cropped images, set the correct size here
image_size = 224
# Values you used for normalizing the images. Default here are for
# pretrained models from torchvision.
norm_mean = [0.485, 0.456, 0.406]
norm_std = [0.229, 0.224, 0.225]