-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
171 lines (157 loc) · 5.95 KB
/
models.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
from os import path
import glob
import unittest
base_model_dir = path.join(path.expanduser("~"), "data", "carml", "dlperf")
def find_onnx_model(name, batch_size=1):
files = glob.glob(path.join(base_model_dir, name,
"**", "*.onnx"), recursive=True)
if len(files) == 0:
msg = "unable to find model {}".format(name)
raise Exception(msg)
files = [f for f in files if not path.basename(f).startswith(".")]
if batch_size > 1:
batch_files = [f for f in files if path.basename(
f) == "model_batch.onnx"]
if batch_files != []:
return batch_files[0]
files = [f for f in files if path.basename(f) != "model_batch.onnx"]
if len(files) != 1:
raise Exception("found more than one onnx model {}".format(name))
return files[0]
class model_url_info:
def __init__(self, name, url, shape=(1, 224, 224, 3), batch_size=1):
self.name = name
self.url = url
try:
self.path = find_onnx_model(name, batch_size=batch_size)
except:
self.path = None
self.shape = shape
def __repr__(self):
return self.path
def __str__(self):
return self.name
def get_models(batch_size=1):
return [
model_url_info(name, url, batch_size=batch_size)
for name, url in [
(
"ArcFace",
"https://s3.amazonaws.com/onnx-model-zoo/arcface/resnet100/resnet100.tar.gz",
),
(
"BVLC_AlexNet",
"https://s3.amazonaws.com/download.onnx/models/opset_9/bvlc_alexnet.tar.gz",
),
(
"BVLC_CaffeNet",
"https://s3.amazonaws.com/download.onnx/models/opset_9/bvlc_reference_caffenet.tar.gz",
),
(
"BVLC_GoogleNet",
"https://s3.amazonaws.com/download.onnx/models/opset_9/bvlc_googlenet.tar.gz",
),
(
"BVLC_RCNN_ILSVRC13",
"https://s3.amazonaws.com/download.onnx/models/opset_9/bvlc_reference_rcnn_ilsvrc13.tar.gz",
),
(
"DenseNet-121",
"https://s3.amazonaws.com/download.onnx/models/opset_9/densenet121.tar.gz",
),
(
"DUC",
"https://s3.amazonaws.com/onnx-model-zoo/duc/ResNet101_DUC_HDC.tar.gz"),
(
"Emotion-FerPlus",
"https://onnxzoo.blob.core.windows.net/models/opset_8/emotion_ferplus/emotion_ferplus.tar.gz",
),
(
"Inception-v1",
"https://s3.amazonaws.com/download.onnx/models/opset_9/inception_v1.tar.gz",
),
(
"Inception-v2",
"https://s3.amazonaws.com/download.onnx/models/opset_9/inception_v2.tar.gz",
),
(
"MNIST",
"https://onnxzoo.blob.core.windows.net/models/opset_8/mnist/mnist.tar.gz",
),
(
"MobileNet-v2",
"https://s3.amazonaws.com/onnx-model-zoo/mobilenet/mobilenetv2-1.0/mobilenetv2-1.0.tar.gz",
),
(
"ResNet018-v1",
"https://s3.amazonaws.com/onnx-model-zoo/resnet/resnet18v1/resnet18v1.tar.gz",
),
(
"ResNet018-v2",
"https://s3.amazonaws.com/onnx-model-zoo/resnet/resnet18v2/resnet18v2.tar.gz",
),
(
"ResNet034-v1",
"https://s3.amazonaws.com/onnx-model-zoo/resnet/resnet34v1/resnet34v1.tar.gz",
),
(
"ResNet034-v2",
"https://s3.amazonaws.com/onnx-model-zoo/resnet/resnet34v2/resnet34v2.tar.gz",
),
(
"ResNet050-v1",
"https://s3.amazonaws.com/onnx-model-zoo/resnet/resnet50v1/resnet50v1.tar.gz",
),
(
"ResNet050-v2",
"https://s3.amazonaws.com/onnx-model-zoo/resnet/resnet50v2/resnet50v2.tar.gz",
),
(
"ResNet101-v1",
"https://s3.amazonaws.com/onnx-model-zoo/resnet/resnet101v1/resnet101v1.tar.gz",
),
(
"ResNet101-v2",
"https://s3.amazonaws.com/onnx-model-zoo/resnet/resnet101v2/resnet101v2.tar.gz",
),
(
"ResNet152-v1",
"https://s3.amazonaws.com/onnx-model-zoo/resnet/resnet152v1/resnet152v1.tar.gz",
),
(
"ResNet152-v2",
"https://s3.amazonaws.com/onnx-model-zoo/resnet/resnet152v2/resnet152v2.tar.gz",
),
(
"Shufflenet",
"https://s3.amazonaws.com/download.onnx/models/opset_9/shufflenet.tar.gz",
),
(
"Squeezenet-v1.1",
"https://s3.amazonaws.com/onnx-model-zoo/squeezenet/squeezenet1.1/squeezenet1.1.tar.gz",
),
(
"Tiny_YOLO-v2",
"https://onnxzoo.blob.core.windows.net/models/opset_8/tiny_yolov2/tiny_yolov2.tar.gz",
),
(
"VGG16-BN",
"https://s3.amazonaws.com/onnx-model-zoo/vgg/vgg16-bn/vgg16-bn.tar.gz",
),
("VGG16", "https://s3.amazonaws.com/onnx-model-zoo/vgg/vgg16/vgg16.tar.gz"),
(
"VGG19-BN",
"https://s3.amazonaws.com/onnx-model-zoo/vgg/vgg19-bn/vgg19-bn.tar.gz",
),
("VGG19", "https://s3.amazonaws.com/onnx-model-zoo/vgg/vgg19/vgg19.tar.gz"),
(
"Zfnet512",
"https://s3.amazonaws.com/download.onnx/models/opset_9/zfnet512.tar.gz",
),
]
]
class TestModelList(unittest.TestCase):
def test_models_init(self):
self.assertEqual(len(models), 30)
if __name__ == "__main__":
unittest.main()