onnx_model_zoo.sh 8.6 KB
Newer Older
M
Macrobull 已提交
1 2
#! /usr/bin/env sh

M
Macrobull 已提交
3 4
# setopt SH_WORD_SPLIT # if zsh

M
Macrobull 已提交
5
base_url="https://s3.amazonaws.com/download.onnx/models/opset_9/"
M
Macrobull 已提交
6 7 8 9 10 11 12
convert_flags="-e -o /tmp/export/"
validate_flags1="/tmp/export/model.py"
validate_flags2="/tmp/export/__model__"

# alias http_get="wget -c" # if no aria2
alias http_get="aria2c -c -s8 -x8"
# alias python="python3" # if ...
M
Macrobull 已提交
13 14 15 16 17 18 19

bvlc_alexnet()
{
    bn_tar="bvlc_alexnet"
    fn_tar="$bn_tar.tar.gz"
    fn_model="$bn_tar/model.onnx"

M
Macrobull 已提交
20
    http_get "$base_url$fn_tar"
M
Macrobull 已提交
21
    rm -rf "$bn_tar/"
M
Macrobull 已提交
22 23 24
    echo "extracting ..."
    tar xf "$fn_tar"

M
Macrobull 已提交
25 26
    python -m onnx2fluid $convert_flags "$fn_model"
    for npz in "$bn_tar"/*.npz
M
Macrobull 已提交
27 28
    do
        echo "converting $npz ..."
M
Macrobull 已提交
29
        python convert_data_npz_0.py "$npz" data_0 prob_1 -s
M
Macrobull 已提交
30 31
        python -m onnx2fluid.validation $validate_flags1 -t "$npz"
        python -m onnx2fluid.validation $validate_flags2 -t "$npz"
M
Macrobull 已提交
32
    done
M
Macrobull 已提交
33
    for pb_dir in "$bn_tar"/*/
M
Macrobull 已提交
34 35
    do
        echo "converting $pb_dir ..."
M
Macrobull 已提交
36 37 38
        python convert_data_pb_0.py "$pb_dir" data_0 prob_1
        python -m onnx2fluid.validation $validate_flags1 -t $(dirname "$pb_dir/x").npz
        python -m onnx2fluid.validation $validate_flags2 -t $(dirname "$pb_dir/x").npz
M
Macrobull 已提交
39 40 41 42 43 44 45 46 47
    done
}

bvlc_googlenet()
{
    bn_tar="bvlc_googlenet"
    fn_tar="$bn_tar.tar.gz"
    fn_model="$bn_tar/model.onnx"

M
Macrobull 已提交
48
    http_get "$base_url$fn_tar"
M
Macrobull 已提交
49
    rm -rf "$bn_tar/"
M
Macrobull 已提交
50 51 52
    echo "extracting ..."
    tar xf "$fn_tar"

M
Macrobull 已提交
53 54
    python -m onnx2fluid $convert_flags "$fn_model"
    for pb_dir in "$bn_tar"/*/
M
Macrobull 已提交
55 56
    do
        echo "converting $pb_dir"
M
Macrobull 已提交
57 58 59
        python convert_data_pb_0.py "$pb_dir" data_0 prob_1
        python -m onnx2fluid.validation $validate_flags1 -t $(dirname "$pb_dir/x").npz
        python -m onnx2fluid.validation $validate_flags2 -t $(dirname "$pb_dir/x").npz
M
Macrobull 已提交
60 61 62 63 64 65 66 67 68
    done
}

bvlc_reference_caffenet()
{
    bn_tar="bvlc_reference_caffenet"
    fn_tar="$bn_tar.tar.gz"
    fn_model="$bn_tar/model.onnx"

M
Macrobull 已提交
69
    http_get "$base_url$fn_tar"
M
Macrobull 已提交
70
    rm -rf "$bn_tar/"
M
Macrobull 已提交
71 72 73
    echo "extracting ..."
    tar xf "$fn_tar"

M
Macrobull 已提交
74 75
    python -m onnx2fluid $convert_flags "$fn_model"
    for pb_dir in "$bn_tar"/*/
M
Macrobull 已提交
76 77
    do
        echo "converting $pb_dir"
M
Macrobull 已提交
78 79 80
        python convert_data_pb_0.py "$pb_dir" data_0 prob_1
        python -m onnx2fluid.validation $validate_flags1 -t $(dirname "$pb_dir/x").npz
        python -m onnx2fluid.validation $validate_flags2 -t $(dirname "$pb_dir/x").npz
M
Macrobull 已提交
81 82 83 84 85 86 87 88
    done
}

bvlc_reference_rcnn_ilsvrc13()
{
    bn_tar="bvlc_reference_rcnn_ilsvrc13"
    fn_tar="$bn_tar.tar.gz"
    fn_model="$bn_tar/model.onnx"
M
Macrobull 已提交
89

M
Macrobull 已提交
90
    http_get "$base_url$fn_tar"
M
Macrobull 已提交
91
    rm -rf "$bn_tar/"
M
Macrobull 已提交
92 93 94
    echo "extracting ..."
    tar xf "$fn_tar"

M
Macrobull 已提交
95 96
    python -m onnx2fluid $convert_flags "$fn_model"
    for pb_dir in "$bn_tar"/*/
M
Macrobull 已提交
97 98
    do
        echo "converting $pb_dir"
M
Macrobull 已提交
99
        python convert_data_pb_0.py "$pb_dir" data_0 fc-rcnn_1
M
Macrobull 已提交
100 101
        python -m onnx2fluid.validation $validate_flags1 -t $(dirname "$pb_dir/x").npz -p 0
        python -m onnx2fluid.validation $validate_flags2 -t $(dirname "$pb_dir/x").npz -p 0
M
Macrobull 已提交
102 103 104 105 106 107 108 109
    done
}

inception_v1()
{
    bn_tar="inception_v1"
    fn_tar="$bn_tar.tar.gz"
    fn_model="$bn_tar/model.onnx"
M
Macrobull 已提交
110

M
Macrobull 已提交
111
    http_get "$base_url$fn_tar"
M
Macrobull 已提交
112
    rm -rf "$bn_tar/"
M
Macrobull 已提交
113 114 115
    echo "extracting ..."
    tar xf "$fn_tar"

M
Macrobull 已提交
116 117
    python -m onnx2fluid $convert_flags "$fn_model"
    for npz in "$bn_tar"/*.npz
M
Macrobull 已提交
118 119
    do
        echo "converting $npz ..."
M
Macrobull 已提交
120
        python convert_data_npz_0.py "$npz" data_0 prob_1 -s
M
Macrobull 已提交
121 122
        python -m onnx2fluid.validation $validate_flags1 -t "$npz"
        python -m onnx2fluid.validation $validate_flags2 -t "$npz"
M
Macrobull 已提交
123
    done
M
Macrobull 已提交
124
    for pb_dir in "$bn_tar"/*/
M
Macrobull 已提交
125
    do
M
Macrobull 已提交
126 127 128 129
        echo "converting $pb_dir ..."
        python convert_data_pb_0.py "$pb_dir" data_0 prob_1
        python -m onnx2fluid.validation $validate_flags1 -t $(dirname "$pb_dir/x").npz
        python -m onnx2fluid.validation $validate_flags2 -t $(dirname "$pb_dir/x").npz
M
Macrobull 已提交
130 131 132 133 134 135 136 137
    done
}

inception_v2()
{
    bn_tar="inception_v2"
    fn_tar="$bn_tar.tar.gz"
    fn_model="$bn_tar/model.onnx"
M
Macrobull 已提交
138

M
Macrobull 已提交
139
    http_get "$base_url$fn_tar"
M
Macrobull 已提交
140
    rm -rf "$bn_tar/"
M
Macrobull 已提交
141 142 143
    echo "extracting ..."
    tar xf "$fn_tar"

M
Macrobull 已提交
144 145
    python -m onnx2fluid $convert_flags "$fn_model"
    for npz in "$bn_tar"/*.npz
M
Macrobull 已提交
146 147
    do
        echo "converting $npz ..."
M
Macrobull 已提交
148
        python convert_data_npz_0.py "$npz" data_0 prob_1 -s
M
Macrobull 已提交
149 150
        python -m onnx2fluid.validation $validate_flags1 -t "$npz"
        python -m onnx2fluid.validation $validate_flags2 -t "$npz"
M
Macrobull 已提交
151
    done
M
Macrobull 已提交
152
    for pb_dir in "$bn_tar"/*/
M
Macrobull 已提交
153
    do
M
Macrobull 已提交
154 155 156 157
        echo "converting $pb_dir ..."
        python convert_data_pb_0.py "$pb_dir" data_0 prob_1
        python -m onnx2fluid.validation $validate_flags1 -t $(dirname "$pb_dir/x").npz
        python -m onnx2fluid.validation $validate_flags2 -t $(dirname "$pb_dir/x").npz
M
Macrobull 已提交
158 159 160 161 162 163 164 165
    done
}

resnet50()
{
    bn_tar="resnet50"
    fn_tar="$bn_tar.tar.gz"
    fn_model="$bn_tar/model.onnx"
M
Macrobull 已提交
166

M
Macrobull 已提交
167
    http_get "$base_url$fn_tar"
M
Macrobull 已提交
168
    rm -rf "$bn_tar/"
M
Macrobull 已提交
169 170 171
    echo "extracting ..."
    tar xf "$fn_tar"

M
Macrobull 已提交
172 173
    python -m onnx2fluid $convert_flags "$fn_model"
    for npz in "$bn_tar"/*.npz
M
Macrobull 已提交
174 175
    do
        echo "converting $npz ..."
M
Macrobull 已提交
176
        python convert_data_npz_0.py "$npz" gpu_0/data_0 gpu_0/softmaxout_1 -s
M
Macrobull 已提交
177 178
        python -m onnx2fluid.validation $validate_flags1 -t "$npz"
        python -m onnx2fluid.validation $validate_flags2 -t "$npz"
M
Macrobull 已提交
179
    done
M
Macrobull 已提交
180
    for pb_dir in "$bn_tar"/*/
M
Macrobull 已提交
181
    do
M
Macrobull 已提交
182 183 184 185
        echo "converting $pb_dir ..."
        python convert_data_pb_0.py "$pb_dir" gpu_0/data_0 gpu_0/softmaxout_1
        python -m onnx2fluid.validation $validate_flags1 -t $(dirname "$pb_dir/x").npz
        python -m onnx2fluid.validation $validate_flags2 -t $(dirname "$pb_dir/x").npz
M
Macrobull 已提交
186 187 188 189 190 191 192 193
    done
}

shufflenet()
{
    bn_tar="shufflenet"
    fn_tar="$bn_tar.tar.gz"
    fn_model="$bn_tar/model.onnx"
M
Macrobull 已提交
194

M
Macrobull 已提交
195
    http_get "$base_url$fn_tar"
M
Macrobull 已提交
196
    rm -rf "$bn_tar/"
M
Macrobull 已提交
197 198 199
    echo "extracting ..."
    tar xf "$fn_tar"

M
Macrobull 已提交
200 201
    python -m onnx2fluid $convert_flags "$fn_model"
    for pb_dir in "$bn_tar"/*/
M
Macrobull 已提交
202
    do
M
Macrobull 已提交
203 204 205 206
        echo "converting $pb_dir ..."
        python convert_data_pb_0.py "$pb_dir" gpu_0/data_0 gpu_0/softmaxout_1
        python -m onnx2fluid.validation $validate_flags1 -t $(dirname "$pb_dir/x").npz
        python -m onnx2fluid.validation $validate_flags2 -t $(dirname "$pb_dir/x").npz
M
Macrobull 已提交
207 208 209 210 211 212 213 214
    done
}

squeezenet()
{
    bn_tar="squeezenet"
    fn_tar="$bn_tar.tar.gz"
    fn_model="$bn_tar/model.onnx"
M
Macrobull 已提交
215

M
Macrobull 已提交
216
    http_get "$base_url$fn_tar"
M
Macrobull 已提交
217
    rm -rf "$bn_tar/"
M
Macrobull 已提交
218 219 220
    echo "extracting ..."
    tar xf "$fn_tar"

M
Macrobull 已提交
221 222
    python -m onnx2fluid $convert_flags "$fn_model"
    for pb_dir in "$bn_tar"/*/
M
Macrobull 已提交
223 224
    do
        echo "converting $pb_dir"
M
Macrobull 已提交
225 226 227
        python convert_data_pb_0.py "$pb_dir" data_0 softmaxout_1
        python -m onnx2fluid.validation $validate_flags1 -t $(dirname "$pb_dir/x").npz
        python -m onnx2fluid.validation $validate_flags2 -t $(dirname "$pb_dir/x").npz
M
Macrobull 已提交
228 229 230 231 232 233 234 235
    done
}

tiny_yolov2()
{
    bn_tar="tiny_yolov2"
    fn_tar="$bn_tar.tar.gz"
    fn_model="$bn_tar/model.onnx"
M
Macrobull 已提交
236

M
Macrobull 已提交
237
    http_get "https://onnxzoo.blob.core.windows.net/models/opset_8/tiny_yolov2/$fn_tar"
M
Macrobull 已提交
238
    rm -rf "$bn_tar/"
M
Macrobull 已提交
239 240 241
    echo "extracting ..."
    tar xf "$fn_tar"

M
Macrobull 已提交
242 243
    python -m onnx2fluid $convert_flags "$fn_model" -xy
    for pb_dir in "$bn_tar"/*/
M
Macrobull 已提交
244 245
    do
        echo "converting $pb_dir"
M
Macrobull 已提交
246 247 248
        python convert_data_pb_0.py "$pb_dir" image grid
        python -m onnx2fluid.validation $validate_flags1 -t $(dirname "$pb_dir/x").npz
        python -m onnx2fluid.validation $validate_flags2 -t $(dirname "$pb_dir/x").npz
M
Macrobull 已提交
249 250 251 252 253 254 255 256
    done
}

vgg19()
{
    bn_tar="vgg19"
    fn_tar="$bn_tar.tar.gz"
    fn_model="$bn_tar/model.onnx"
M
Macrobull 已提交
257

M
Macrobull 已提交
258
    http_get "$base_url$fn_tar"
M
Macrobull 已提交
259
    rm -rf "$bn_tar/"
M
Macrobull 已提交
260 261 262
    echo "extracting ..."
    tar xf "$fn_tar"

M
Macrobull 已提交
263 264
    python -m onnx2fluid $convert_flags "$fn_model"
    for pb_dir in "$bn_tar"/*/
M
Macrobull 已提交
265 266
    do
        echo "converting $pb_dir"
M
Macrobull 已提交
267 268 269
        python convert_data_pb_0.py "$pb_dir" data_0 prob_1
        python -m onnx2fluid.validation $validate_flags1 -t $(dirname "$pb_dir/x").npz
        python -m onnx2fluid.validation $validate_flags2 -t $(dirname "$pb_dir/x").npz
M
Macrobull 已提交
270 271 272 273 274 275 276 277
    done
}

zfnet512()
{
    bn_tar="zfnet512"
    fn_tar="$bn_tar.tar.gz"
    fn_model="$bn_tar/model.onnx"
M
Macrobull 已提交
278

M
Macrobull 已提交
279
    http_get "$base_url$fn_tar"
M
Macrobull 已提交
280
    rm -rf "$bn_tar/"
M
Macrobull 已提交
281 282 283
    echo "extracting ..."
    tar xf "$fn_tar"

M
Macrobull 已提交
284 285
    python -m onnx2fluid $convert_flags "$fn_model"
    for pb_dir in "$bn_tar"/*/
M
Macrobull 已提交
286 287
    do
        echo "converting $pb_dir"
M
Macrobull 已提交
288 289 290
        python convert_data_pb_0.py "$pb_dir" gpu_0/data_0 gpu_0/softmax_1
        python -m onnx2fluid.validation $validate_flags1 -t $(dirname "$pb_dir/x").npz
        python -m onnx2fluid.validation $validate_flags2 -t $(dirname "$pb_dir/x").npz
M
Macrobull 已提交
291 292 293 294
    done
}


M
Macrobull 已提交
295 296
bvlc_alexnet
bvlc_googlenet
M
Macrobull 已提交
297 298
bvlc_reference_caffenet
bvlc_reference_rcnn_ilsvrc13
M
Macrobull 已提交
299 300 301 302
inception_v1
inception_v2
resnet50
shufflenet
M
Macrobull 已提交
303 304
squeezenet # softmax bug
# tiny_yolov2 # not supported
M
Macrobull 已提交
305
vgg19
M
Macrobull 已提交
306
zfnet512