-
Notifications
You must be signed in to change notification settings - Fork 1
/
hubconf.py
69 lines (42 loc) · 1.91 KB
/
hubconf.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
dependencies = ['torch', 'torchvision']
from torch.hub import load_state_dict_from_url
def _baseline_model(mode='colour', pretrained=True, n_bn=32, d_vvs=2, rep=0):
from training import BaselineModel
n_inch = 1 if mode == 'grey' else 3
model = BaselineModel(n_bn, d_vvs, n_inch)
if pretrained:
state = load_state_dict_from_url(
f'http://marc.ecs.soton.ac.uk/pytorch-models/opponency/cifar10/{mode}/model_{n_bn}_{d_vvs}_{rep}.pt',
progress=True
)
try:
model.load_conv_dict(state)
except:
model.load_state_dict(state)
return model
def _imagenet_model(pretrained=True, n_bn=32, d_vvs=2, rep=0):
from training import ImageNetModel
model = ImageNetModel(n_bn, d_vvs, 3)
if pretrained:
state = load_state_dict_from_url(
f'http://marc.ecs.soton.ac.uk/pytorch-models/opponency/imagenet/model_{n_bn}_{d_vvs}_{rep}.pt',
progress=True
)
model.load_conv_dict(state)
return model
def colour_full(n_bn=32, d_vvs=2, rep=0):
return _baseline_model(mode='colour_full', n_bn=n_bn, d_vvs=d_vvs, rep=rep)
def colour(n_bn=32, d_vvs=2, rep=0):
return _baseline_model(mode='colour_full', n_bn=n_bn, d_vvs=d_vvs, rep=rep)
def shuffled(n_bn=32, d_vvs=2, rep=0):
return _baseline_model(mode='shuffled', n_bn=n_bn, d_vvs=d_vvs, rep=rep)
def mosaic(n_bn=32, d_vvs=2, rep=0):
return _baseline_model(mode='mosaic', n_bn=n_bn, d_vvs=d_vvs, rep=rep)
def cielab(n_bn=32, d_vvs=2, rep=0):
return _baseline_model(mode='cielab', n_bn=n_bn, d_vvs=d_vvs, rep=rep)
def distorted(n_bn=32, d_vvs=2, rep=0):
return _baseline_model(mode='mosaic', n_bn=n_bn, d_vvs=d_vvs, rep=rep)
def grey(n_bn=32, d_vvs=2, rep=0):
return _baseline_model(mode='grey', n_bn=n_bn, d_vvs=d_vvs, rep=rep)
def imagenet(n_bn=32, d_vvs=2, rep=0):
return _imagenet_model(n_bn=n_bn, d_vvs=d_vvs, rep=rep)