forked from adobe/antialiased-cnns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_usage.py
47 lines (33 loc) · 1.9 KB
/
example_usage.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
42
43
44
45
46
# Copyright (c) 2019, Adobe Inc. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike
# 4.0 International Public License. To view a copy of this license, visit
# https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode.
import torch
# Run `bash weights/get_antialiased_models.sh` to get weights.
# filter_size = 2;
filter_size = 3;
# filter_size = 5;
import models_lpf.resnet
model = models_lpf.resnet.resnet18(filter_size=filter_size)
model.load_state_dict(torch.load('weights/resnet18_lpf%i.pth.tar'%filter_size)['state_dict'])
model = models_lpf.resnet.resnet34(filter_size=filter_size)
model.load_state_dict(torch.load('weights/resnet34_lpf%i.pth.tar'%filter_size)['state_dict'])
model = models_lpf.resnet.resnet50(filter_size=filter_size)
model.load_state_dict(torch.load('weights/resnet50_lpf%i.pth.tar'%filter_size)['state_dict'])
model = models_lpf.resnet.resnet101(filter_size=filter_size)
model.load_state_dict(torch.load('weights/resnet101_lpf%i.pth.tar'%filter_size)['state_dict'])
import models_lpf.alexnet
model = models_lpf.alexnet.AlexNet(filter_size=filter_size)
model.load_state_dict(torch.load('weights/alexnet_lpf%i.pth.tar'%filter_size)['state_dict'])
import models_lpf.vgg
model = models_lpf.vgg.vgg16(filter_size=filter_size)
model.load_state_dict(torch.load('weights/vgg16_lpf%i.pth.tar'%filter_size)['state_dict'])
model = models_lpf.vgg.vgg16_bn(filter_size=filter_size)
model.load_state_dict(torch.load('weights/vgg16_bn_lpf%i.pth.tar'%filter_size)['state_dict'])
import models_lpf.densenet
model = models_lpf.densenet.densenet121(filter_size=filter_size)
model.load_state_dict(torch.load('weights/densenet121_lpf%i.pth.tar'%filter_size)['state_dict'])
import models_lpf.mobilenet
model = models_lpf.mobilenet.mobilenet_v2(filter_size=filter_size)
model.load_state_dict(torch.load('weights/mobilenet_v2_lpf%i.pth.tar'%filter_size)['state_dict'])