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

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

M
Macrobull 已提交
5 6 7 8
# alias python="python3" # if ...
# alias http_get="wget -c" # if no aria2
alias http_get="aria2c -c -s8 -x8"

M
Macrobull 已提交
9
base_url="https://s3.amazonaws.com/download.onnx/models/opset_9/"
M
Macrobull 已提交
10 11
convert_cmd="python -m onnx2fluid"
validate_cmd="$convert_cmd.validation"
M
Macrobull 已提交
12 13 14
convert_flags="-e -o /tmp/export/"
validate_flags1="/tmp/export/model.py"
validate_flags2="/tmp/export/__model__"
M
Macrobull 已提交
15
validate_flags3="/tmp/export/__model__ -i"
M
Macrobull 已提交
16

M
bugfix  
Macrobull 已提交
17

M
Macrobull 已提交
18 19
bvlc_alexnet()
{
M
bugfix  
Macrobull 已提交
20 21 22 23 24 25 26 27 28
	bn_tar="bvlc_alexnet"
	fn_tar="$bn_tar.tar.gz"
	fn_model="$bn_tar/model.onnx"

	http_get "$base_url$fn_tar"
	rm -rf "$bn_tar/"
	echo "extracting ..."
	tar xf "$fn_tar"

M
Macrobull 已提交
29
	$convert_cmd $convert_flags "$fn_model"
M
Macrobull 已提交
30
	for npz in "$bn_tar/"*.npz
M
bugfix  
Macrobull 已提交
31 32 33
	do
		echo "converting $npz ..."
		python convert_data_npz.py "$npz" data_0 prob_1 -s
M
Macrobull 已提交
34 35
		$validate_cmd $validate_flags1 -t "$npz"
		$validate_cmd $validate_flags2 -t "$npz"
M
bugfix  
Macrobull 已提交
36
	done
M
Macrobull 已提交
37
	$validate_cmd $validate_flags3 -t "$npz"
M
Macrobull 已提交
38
	for pb_dir in "$bn_tar/"*/
M
bugfix  
Macrobull 已提交
39 40 41
	do
		echo "converting $pb_dir ..."
		python convert_data_pb.py "$pb_dir" data_0 prob_1
M
Macrobull 已提交
42 43
		$validate_cmd $validate_flags1 -t $(dirname "$pb_dir/x").npz
		$validate_cmd $validate_flags2 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
44
	done
M
Macrobull 已提交
45
	$validate_cmd $validate_flags3 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
46 47

	rm -rf "$bn_tar/"
M
Macrobull 已提交
48 49 50 51
}

bvlc_googlenet()
{
M
bugfix  
Macrobull 已提交
52 53 54 55 56 57 58 59 60
	bn_tar="bvlc_googlenet"
	fn_tar="$bn_tar.tar.gz"
	fn_model="$bn_tar/model.onnx"

	http_get "$base_url$fn_tar"
	rm -rf "$bn_tar/"
	echo "extracting ..."
	tar xf "$fn_tar"

M
Macrobull 已提交
61
	$convert_cmd $convert_flags "$fn_model"
M
Macrobull 已提交
62
	for pb_dir in "$bn_tar/"*/
M
bugfix  
Macrobull 已提交
63 64 65
	do
		echo "converting $pb_dir"
		python convert_data_pb.py "$pb_dir" data_0 prob_1
M
Macrobull 已提交
66 67
		$validate_cmd $validate_flags1 -t $(dirname "$pb_dir/x").npz
		$validate_cmd $validate_flags2 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
68
	done
M
Macrobull 已提交
69
	$validate_cmd $validate_flags3 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
70 71

	rm -rf "$bn_tar/"
M
Macrobull 已提交
72 73 74 75
}

bvlc_reference_caffenet()
{
M
bugfix  
Macrobull 已提交
76 77 78 79 80 81 82 83 84
	bn_tar="bvlc_reference_caffenet"
	fn_tar="$bn_tar.tar.gz"
	fn_model="$bn_tar/model.onnx"

	http_get "$base_url$fn_tar"
	rm -rf "$bn_tar/"
	echo "extracting ..."
	tar xf "$fn_tar"

M
Macrobull 已提交
85
	$convert_cmd $convert_flags "$fn_model"
M
Macrobull 已提交
86
	for pb_dir in "$bn_tar/"*/
M
bugfix  
Macrobull 已提交
87 88 89
	do
		echo "converting $pb_dir"
		python convert_data_pb.py "$pb_dir" data_0 prob_1
M
Macrobull 已提交
90 91
		$validate_cmd $validate_flags1 -t $(dirname "$pb_dir/x").npz
		$validate_cmd $validate_flags2 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
92
	done
M
Macrobull 已提交
93
	$validate_cmd $validate_flags3 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
94 95

	rm -rf "$bn_tar/"
M
Macrobull 已提交
96 97 98 99
}

bvlc_reference_rcnn_ilsvrc13()
{
M
bugfix  
Macrobull 已提交
100 101 102 103 104 105 106 107 108
	bn_tar="bvlc_reference_rcnn_ilsvrc13"
	fn_tar="$bn_tar.tar.gz"
	fn_model="$bn_tar/model.onnx"

	http_get "$base_url$fn_tar"
	rm -rf "$bn_tar/"
	echo "extracting ..."
	tar xf "$fn_tar"

M
Macrobull 已提交
109
	$convert_cmd $convert_flags "$fn_model"
M
Macrobull 已提交
110
	for pb_dir in "$bn_tar/"*/
M
bugfix  
Macrobull 已提交
111 112 113
	do
		echo "converting $pb_dir"
		python convert_data_pb.py "$pb_dir" data_0 fc-rcnn_1
M
Macrobull 已提交
114 115
		$validate_cmd $validate_flags1 -t $(dirname "$pb_dir/x").npz
		$validate_cmd $validate_flags2 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
116
	done
M
Macrobull 已提交
117
	$validate_cmd $validate_flags3 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132

	rm -rf "$bn_tar/"
}

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

	http_get "$base_url$fn_tar"
	rm -rf "$bn_tar/"
	echo "extracting ..."
	tar xf "$fn_tar"

M
Macrobull 已提交
133
	$convert_cmd $convert_flags "$fn_model"
M
Macrobull 已提交
134
	for npz in "$bn_tar/"*.npz
M
bugfix  
Macrobull 已提交
135 136 137
	do
		echo "converting $npz ..."
		python convert_data_npz.py "$npz" data_0 fc6_1 -s
M
Macrobull 已提交
138 139
		$validate_cmd $validate_flags1 -t "$npz"
		$validate_cmd $validate_flags2 -t "$npz"
M
bugfix  
Macrobull 已提交
140
	done
M
Macrobull 已提交
141
	$validate_cmd $validate_flags3 -t "$npz"
M
Macrobull 已提交
142
	for pb_dir in "$bn_tar/"*/
M
bugfix  
Macrobull 已提交
143 144 145
	do
		echo "converting $pb_dir"
		python convert_data_pb.py "$pb_dir" data_0 fc6_1
M
Macrobull 已提交
146 147
		$validate_cmd $validate_flags1 -t $(dirname "$pb_dir/x").npz
		$validate_cmd $validate_flags2 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
148
	done
M
Macrobull 已提交
149
	$validate_cmd $validate_flags3 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164

   rm -rf "$bn_tar/"
}

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

	http_get "https://onnxzoo.blob.core.windows.net/models/opset_8/emotion_ferplus/$fn_tar"
	rm -rf "$bn_tar/"
	echo "extracting ..."
	tar xf "$fn_tar"

M
Macrobull 已提交
165
	$convert_cmd $convert_flags "$fn_model" -y
M
Macrobull 已提交
166
	for pb_dir in "$bn_tar/"*/
M
bugfix  
Macrobull 已提交
167 168 169
	do
		echo "converting $pb_dir ..."
		python convert_data_pb.py "$pb_dir" Input3 Plus692_Output_0
M
Macrobull 已提交
170 171
		$validate_cmd $validate_flags1 -t $(dirname "$pb_dir/x").npz
		$validate_cmd $validate_flags2 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
172
	done
M
Macrobull 已提交
173
	$validate_cmd $validate_flags3 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
174 175

	rm -rf "$bn_tar/"
M
Macrobull 已提交
176 177 178 179
}

inception_v1()
{
M
bugfix  
Macrobull 已提交
180 181 182 183 184 185 186 187 188
	bn_tar="inception_v1"
	fn_tar="$bn_tar.tar.gz"
	fn_model="$bn_tar/model.onnx"

	http_get "$base_url$fn_tar"
	rm -rf "$bn_tar/"
	echo "extracting ..."
	tar xf "$fn_tar"

M
Macrobull 已提交
189
	$convert_cmd $convert_flags "$fn_model"
M
Macrobull 已提交
190
	for npz in "$bn_tar/"*.npz
M
bugfix  
Macrobull 已提交
191 192 193
	do
		echo "converting $npz ..."
		python convert_data_npz.py "$npz" data_0 prob_1 -s
M
Macrobull 已提交
194 195
		$validate_cmd $validate_flags1 -t "$npz"
		$validate_cmd $validate_flags2 -t "$npz"
M
bugfix  
Macrobull 已提交
196
	done
M
Macrobull 已提交
197
	$validate_cmd $validate_flags3 -t "$npz"
M
Macrobull 已提交
198
	for pb_dir in "$bn_tar/"*/
M
bugfix  
Macrobull 已提交
199 200 201
	do
		echo "converting $pb_dir ..."
		python convert_data_pb.py "$pb_dir" data_0 prob_1
M
Macrobull 已提交
202 203
		$validate_cmd $validate_flags1 -t $(dirname "$pb_dir/x").npz
		$validate_cmd $validate_flags2 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
204
	done
M
Macrobull 已提交
205
	$validate_cmd $validate_flags3 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
206 207

	rm -rf "$bn_tar/"
M
Macrobull 已提交
208 209 210 211
}

inception_v2()
{
M
bugfix  
Macrobull 已提交
212 213 214 215 216 217 218 219 220
	bn_tar="inception_v2"
	fn_tar="$bn_tar.tar.gz"
	fn_model="$bn_tar/model.onnx"

	http_get "$base_url$fn_tar"
	rm -rf "$bn_tar/"
	echo "extracting ..."
	tar xf "$fn_tar"

M
Macrobull 已提交
221
	$convert_cmd $convert_flags "$fn_model"
M
Macrobull 已提交
222
	for npz in "$bn_tar/"*.npz
M
bugfix  
Macrobull 已提交
223 224 225
	do
		echo "converting $npz ..."
		python convert_data_npz.py "$npz" data_0 prob_1 -s
M
Macrobull 已提交
226 227
		$validate_cmd $validate_flags1 -t "$npz"
		$validate_cmd $validate_flags2 -t "$npz"
M
bugfix  
Macrobull 已提交
228
	done
M
Macrobull 已提交
229
	$validate_cmd $validate_flags3 -t "$npz"
M
Macrobull 已提交
230
	for pb_dir in "$bn_tar/"*/
M
bugfix  
Macrobull 已提交
231 232 233
	do
		echo "converting $pb_dir ..."
		python convert_data_pb.py "$pb_dir" data_0 prob_1
M
Macrobull 已提交
234 235
		$validate_cmd $validate_flags1 -t $(dirname "$pb_dir/x").npz
		$validate_cmd $validate_flags2 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
236
	done
M
Macrobull 已提交
237
	$validate_cmd $validate_flags3 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252

	rm -rf "$bn_tar/"
}

mobilenet()
{
	bn_tar="mobilenetv2-1.0"
	fn_tar="$bn_tar.tar.gz"
	fn_model="$bn_tar/$bn_tar.onnx"

	http_get "https://s3.amazonaws.com/onnx-model-zoo/mobilenet/mobilenetv2-1.0/$fn_tar"
	rm -rf "$bn_tar/"
	echo "extracting ..."
	tar xf "$fn_tar"

M
Macrobull 已提交
253
	$convert_cmd $convert_flags "$fn_model" -y
M
Macrobull 已提交
254
	for pb_dir in "$bn_tar/"*/
M
bugfix  
Macrobull 已提交
255 256 257
	do
		echo "converting $pb_dir ..."
		python convert_data_pb.py "$pb_dir" data mobilenetv20_output_flatten0_reshape0
M
Macrobull 已提交
258 259
		$validate_cmd $validate_flags1 -t $(dirname "$pb_dir/x").npz
		$validate_cmd $validate_flags2 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
260
	done
M
Macrobull 已提交
261
	$validate_cmd $validate_flags3 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276

	rm -rf "$bn_tar/"
}

resnet18()
{
	bn_tar="resnet18v1"
	fn_tar="$bn_tar.tar.gz"
	fn_model="$bn_tar/$bn_tar.onnx"

	http_get "https://s3.amazonaws.com/onnx-model-zoo/resnet/resnet18v1/$fn_tar"
	rm -rf "$bn_tar/"
	echo "extracting ..."
	tar xf "$fn_tar"

M
Macrobull 已提交
277
	$convert_cmd $convert_flags "$fn_model" -y
M
Macrobull 已提交
278
	for pb_dir in "$bn_tar/"*/
M
bugfix  
Macrobull 已提交
279 280 281
	do
		echo "converting $pb_dir ..."
		python convert_data_pb.py "$pb_dir" data resnetv15_dense0_fwd
M
Macrobull 已提交
282 283
		$validate_cmd $validate_flags1 -t $(dirname "$pb_dir/x").npz
		$validate_cmd $validate_flags2 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
284
	done
M
Macrobull 已提交
285
	$validate_cmd $validate_flags3 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
286 287

	rm -rf "$bn_tar/"
M
Macrobull 已提交
288 289 290 291
}

resnet50()
{
M
bugfix  
Macrobull 已提交
292 293 294 295 296 297 298 299 300
	bn_tar="resnet50"
	fn_tar="$bn_tar.tar.gz"
	fn_model="$bn_tar/model.onnx"

	http_get "$base_url$fn_tar"
	rm -rf "$bn_tar/"
	echo "extracting ..."
	tar xf "$fn_tar"

M
Macrobull 已提交
301
	$convert_cmd $convert_flags "$fn_model"
M
Macrobull 已提交
302
	for npz in "$bn_tar/"*.npz
M
bugfix  
Macrobull 已提交
303 304 305
	do
		echo "converting $npz ..."
		python convert_data_npz.py "$npz" gpu_0/data_0 gpu_0/softmaxout_1 -s
M
Macrobull 已提交
306 307
		$validate_cmd $validate_flags1 -t "$npz"
		$validate_cmd $validate_flags2 -t "$npz"
M
bugfix  
Macrobull 已提交
308
	done
M
Macrobull 已提交
309
	$validate_cmd $validate_flags3 -t "$npz"
M
Macrobull 已提交
310
	for pb_dir in "$bn_tar/"*/
M
bugfix  
Macrobull 已提交
311 312 313
	do
		echo "converting $pb_dir ..."
		python convert_data_pb.py "$pb_dir" gpu_0/data_0 gpu_0/softmaxout_1
M
Macrobull 已提交
314 315
		$validate_cmd $validate_flags1 -t $(dirname "$pb_dir/x").npz
		$validate_cmd $validate_flags2 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
316
	done
M
Macrobull 已提交
317
	$validate_cmd $validate_flags3 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332

	rm -rf "$bn_tar/"
}

resnet100_arcface()
{
	bn_tar="resnet100"
	fn_tar="$bn_tar.tar.gz"
	fn_model="$bn_tar/$bn_tar.onnx"

	http_get "https://s3.amazonaws.com/onnx-model-zoo/arcface/resnet100/$fn_tar"
	rm -rf "$bn_tar/"
	echo "extracting ..."
	tar xf "$fn_tar"

M
Macrobull 已提交
333
	$convert_cmd $convert_flags "$fn_model" -y
M
Macrobull 已提交
334
	for pb_dir in "$bn_tar/"*/
M
bugfix  
Macrobull 已提交
335 336 337
	do
		echo "converting $pb_dir ..."
		python convert_data_pb.py "$pb_dir" data fc1
M
Macrobull 已提交
338 339
		$validate_cmd $validate_flags1 -t $(dirname "$pb_dir/x").npz
		$validate_cmd $validate_flags2 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
340
	done
M
Macrobull 已提交
341
	$validate_cmd $validate_flags3 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356

	rm -rf "$bn_tar/"
}

resnet101_duc()
{
	bn_tar="ResNet101_DUC_HDC"
	fn_tar="$bn_tar.tar.gz"
	fn_model="$bn_tar/$bn_tar.onnx"

	http_get "https://s3.amazonaws.com/onnx-model-zoo/duc/$fn_tar"
	rm -rf "$bn_tar/"
	echo "extracting ..."
	tar xf "$fn_tar"

M
Macrobull 已提交
357
	$convert_cmd $convert_flags "$fn_model" -y
M
Macrobull 已提交
358
	for pb_dir in "$bn_tar/"*/
M
bugfix  
Macrobull 已提交
359 360 361
	do
		echo "converting $pb_dir ..."
		python convert_data_pb.py "$pb_dir" data seg_loss
M
Macrobull 已提交
362 363
		$validate_cmd $validate_flags1 -t $(dirname "$pb_dir/x").npz
		$validate_cmd $validate_flags2 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
364
	done
M
Macrobull 已提交
365
	$validate_cmd $validate_flags3 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380

	rm -rf "$bn_tar/"
}

resnet152()
{
	bn_tar="resnet152v2"
	fn_tar="$bn_tar.tar.gz"
	fn_model="$bn_tar/$bn_tar.onnx"

	http_get "https://s3.amazonaws.com/onnx-model-zoo/resnet/resnet152v2/$fn_tar"
	rm -rf "$bn_tar/"
	echo "extracting ..."
	tar xf "$fn_tar"

M
Macrobull 已提交
381
	$convert_cmd $convert_flags "$fn_model" -y
M
Macrobull 已提交
382
	for pb_dir in "$bn_tar/"*/
M
bugfix  
Macrobull 已提交
383 384 385
	do
		echo "converting $pb_dir ..."
		python convert_data_pb.py "$pb_dir" data resnetv27_dense0_fwd
M
Macrobull 已提交
386 387
		$validate_cmd $validate_flags1 -t $(dirname "$pb_dir/x").npz
		$validate_cmd $validate_flags2 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
388
	done
M
Macrobull 已提交
389
	$validate_cmd $validate_flags3 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
390 391

	rm -rf "$bn_tar/"
M
Macrobull 已提交
392 393 394 395
}

shufflenet()
{
M
bugfix  
Macrobull 已提交
396 397 398 399 400 401 402 403 404
	bn_tar="shufflenet"
	fn_tar="$bn_tar.tar.gz"
	fn_model="$bn_tar/model.onnx"

	http_get "$base_url$fn_tar"
	rm -rf "$bn_tar/"
	echo "extracting ..."
	tar xf "$fn_tar"

M
Macrobull 已提交
405
	$convert_cmd $convert_flags "$fn_model"
M
Macrobull 已提交
406
	for pb_dir in "$bn_tar/"*/
M
bugfix  
Macrobull 已提交
407 408 409
	do
		echo "converting $pb_dir ..."
		python convert_data_pb.py "$pb_dir" gpu_0/data_0 gpu_0/softmax_1
M
Macrobull 已提交
410 411
		$validate_cmd $validate_flags1 -t $(dirname "$pb_dir/x").npz
		$validate_cmd $validate_flags2 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
412
	done
M
Macrobull 已提交
413
	$validate_cmd $validate_flags3 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
414 415

	rm -rf "$bn_tar/"
M
Macrobull 已提交
416 417 418 419
}

squeezenet()
{
M
bugfix  
Macrobull 已提交
420 421 422 423 424 425 426 427 428
	bn_tar="squeezenet"
	fn_tar="$bn_tar.tar.gz"
	fn_model="$bn_tar/model.onnx"

	http_get "$base_url$fn_tar"
	rm -rf "$bn_tar/"
	echo "extracting ..."
	tar xf "$fn_tar"

M
Macrobull 已提交
429
	$convert_cmd $convert_flags "$fn_model"
M
Macrobull 已提交
430
	for pb_dir in "$bn_tar/"*/
M
bugfix  
Macrobull 已提交
431 432 433
	do
		echo "converting $pb_dir"
		python convert_data_pb.py "$pb_dir" data_0 softmaxout_1
M
Macrobull 已提交
434 435
		$validate_cmd $validate_flags1 -t $(dirname "$pb_dir/x").npz
		$validate_cmd $validate_flags2 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
436
	done
M
Macrobull 已提交
437
	$validate_cmd $validate_flags3 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452

	rm -rf "$bn_tar/"
}

squeezenet1v1()
{
	bn_tar="squeezenet1.1"
	fn_tar="$bn_tar.tar.gz"
	fn_model="$bn_tar/$bn_tar.onnx"

	http_get "https://s3.amazonaws.com/onnx-model-zoo/squeezenet/squeezenet1.1/$fn_tar"
	rm -rf "$bn_tar/"
	echo "extracting ..."
	tar xf "$fn_tar"

M
Macrobull 已提交
453
	$convert_cmd $convert_flags "$fn_model"
M
Macrobull 已提交
454
	for pb_dir in "$bn_tar/"*/
M
bugfix  
Macrobull 已提交
455 456 457
	do
		echo "converting $pb_dir ..."
		python convert_data_pb.py "$pb_dir" data squeezenet0_flatten0_reshape0
M
Macrobull 已提交
458 459
		$validate_cmd $validate_flags1 -t $(dirname "$pb_dir/x").npz
		$validate_cmd $validate_flags2 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
460
	done
M
Macrobull 已提交
461
	$validate_cmd $validate_flags3 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
462 463 464 465 466 467 468 469 470 471 472 473 474 475

	rm -rf "$bn_tar/"
}

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

	http_get "https://onnxzoo.blob.core.windows.net/models/opset_10/ssd/$fn_tar"
	rm -rf "$bn_tar/"
	echo "extracting ..."
	mkdir "$bn_tar"
M
Macrobull 已提交
476
	tar xf "$fn_tar" -C "$bn_tar/"
M
bugfix  
Macrobull 已提交
477

M
Macrobull 已提交
478
	$convert_cmd $convert_flags "$fn_model"
M
Macrobull 已提交
479
	for pb_dir in "$bn_tar/"*/
M
bugfix  
Macrobull 已提交
480 481 482
	do
		echo "converting $pb_dir ..."
		python convert_data_pb.py "$pb_dir" image bboxes,labels,scores
M
Macrobull 已提交
483 484
		$validate_cmd $validate_flags1 -t $(dirname "$pb_dir/x").npz
		$validate_cmd $validate_flags2 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
485
	done
M
Macrobull 已提交
486
	$validate_cmd $validate_flags3 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
487 488

	rm -rf "$bn_tar/"
M
Macrobull 已提交
489 490 491 492
}

tiny_yolov2()
{
M
bugfix  
Macrobull 已提交
493 494 495 496 497 498 499 500 501
	bn_tar="tiny_yolov2"
	fn_tar="$bn_tar.tar.gz"
	fn_model="$bn_tar/model.onnx"

	http_get "https://onnxzoo.blob.core.windows.net/models/opset_8/tiny_yolov2/$fn_tar"
	rm -rf "$bn_tar/"
	echo "extracting ..."
	tar xf "$fn_tar"

M
Macrobull 已提交
502
	$convert_cmd $convert_flags "$fn_model" -y
M
Macrobull 已提交
503
	for pb_dir in "$bn_tar/"*/
M
bugfix  
Macrobull 已提交
504 505 506
	do
		echo "converting $pb_dir"
		python convert_data_pb.py "$pb_dir" image grid
M
Macrobull 已提交
507 508
		$validate_cmd $validate_flags1 -t $(dirname "$pb_dir/x").npz
		$validate_cmd $validate_flags2 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
509
	done
M
Macrobull 已提交
510
	$validate_cmd $validate_flags3 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
511 512 513 514 515 516 517 518 519 520 521 522 523 524 525

	rm -rf "$bn_tar/"
}

vgg16bn()
{
	bn_tar="vgg16-bn"
	fn_tar="$bn_tar.tar.gz"
	fn_model="$bn_tar/$bn_tar.onnx"

	http_get "https://s3.amazonaws.com/onnx-model-zoo/vgg/vgg16-bn/$fn_tar"
	rm -rf "$bn_tar/"
	echo "extracting ..."
	tar xf "$fn_tar"

M
Macrobull 已提交
526
	$convert_cmd $convert_flags "$fn_model" -y
M
Macrobull 已提交
527
	for pb_dir in "$bn_tar/"*/
M
bugfix  
Macrobull 已提交
528 529 530
	do
		echo "converting $pb_dir ..."
		python convert_data_pb.py "$pb_dir" data vgg0_dense2_fwd
M
Macrobull 已提交
531 532
		$validate_cmd $validate_flags1 -t $(dirname "$pb_dir/x").npz
		$validate_cmd $validate_flags2 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
533
	done
M
Macrobull 已提交
534
	$validate_cmd $validate_flags3 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
535 536

	rm -rf "$bn_tar/"
M
Macrobull 已提交
537 538 539 540
}

vgg19()
{
M
bugfix  
Macrobull 已提交
541 542 543 544 545 546 547 548 549
	bn_tar="vgg19"
	fn_tar="$bn_tar.tar.gz"
	fn_model="$bn_tar/model.onnx"

	http_get "$base_url$fn_tar"
	rm -rf "$bn_tar/"
	echo "extracting ..."
	tar xf "$fn_tar"

M
Macrobull 已提交
550
	$convert_cmd $convert_flags "$fn_model"
M
Macrobull 已提交
551
	for pb_dir in "$bn_tar/"*/
M
bugfix  
Macrobull 已提交
552 553 554
	do
		echo "converting $pb_dir"
		python convert_data_pb.py "$pb_dir" data_0 prob_1
M
Macrobull 已提交
555 556
		$validate_cmd $validate_flags1 -t $(dirname "$pb_dir/x").npz
		$validate_cmd $validate_flags2 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
557
	done
M
Macrobull 已提交
558
	$validate_cmd $validate_flags3 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
559 560 561 562 563 564 565 566

	rm -rf "$bn_tar/"
}

yolov3()
{
	bn_tar="yolov3"
	fn_tar="$bn_tar.tar.gz"
M
Macrobull 已提交
567
	fn_model="$bn_tar/yolov3.onnx"
M
bugfix  
Macrobull 已提交
568 569 570 571 572 573

	http_get "https://onnxzoo.blob.core.windows.net/models/opset_10/yolov3/$fn_tar"
	rm -rf "$bn_tar/"
	echo "extracting ..."
	tar xf "$fn_tar"

M
Macrobull 已提交
574
	$convert_cmd $convert_flags "$fn_model" -x #
M
Macrobull 已提交
575
	for pb_dir in "$bn_tar/"*/
M
bugfix  
Macrobull 已提交
576 577 578
	do
		echo "converting $pb_dir ..."
		python convert_data_pb.py "$pb_dir" input_1:01,image_shape:01 yolonms_layer_1/ExpandDims_1:0,yolonms_layer_1/ExpandDims_3:0,yolonms_layer_1/concat_2:0
M
Macrobull 已提交
579 580
		$validate_cmd $validate_flags1 -t $(dirname "$pb_dir/x").npz
		$validate_cmd $validate_flags2 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
581
	done
M
Macrobull 已提交
582
	$validate_cmd $validate_flags3 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
583 584

	rm -rf "$bn_tar/"
M
Macrobull 已提交
585 586 587 588
}

zfnet512()
{
M
bugfix  
Macrobull 已提交
589 590 591 592 593 594 595 596 597
	bn_tar="zfnet512"
	fn_tar="$bn_tar.tar.gz"
	fn_model="$bn_tar/model.onnx"

	http_get "$base_url$fn_tar"
	rm -rf "$bn_tar/"
	echo "extracting ..."
	tar xf "$fn_tar"

M
Macrobull 已提交
598
	$convert_cmd $convert_flags "$fn_model"
M
Macrobull 已提交
599
	for pb_dir in "$bn_tar/"*/
M
bugfix  
Macrobull 已提交
600 601 602
	do
		echo "converting $pb_dir"
		python convert_data_pb.py "$pb_dir" gpu_0/data_0 gpu_0/softmax_1
M
Macrobull 已提交
603 604
		$validate_cmd $validate_flags1 -t $(dirname "$pb_dir/x").npz
		$validate_cmd $validate_flags2 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
605
	done
M
Macrobull 已提交
606
	$validate_cmd $validate_flags3 -t $(dirname "$pb_dir/x").npz
M
bugfix  
Macrobull 已提交
607 608

	rm -rf "$bn_tar/"
M
Macrobull 已提交
609 610 611
}


M
Macrobull 已提交
612 613
bvlc_alexnet
bvlc_googlenet
M
Macrobull 已提交
614 615
bvlc_reference_caffenet
bvlc_reference_rcnn_ilsvrc13
M
bugfix  
Macrobull 已提交
616 617
densenet121
emotion_ferplus # not supported
M
Macrobull 已提交
618 619
inception_v1
inception_v2
M
bugfix  
Macrobull 已提交
620 621
mobilenet
resnet18
M
Macrobull 已提交
622
resnet50
M
bugfix  
Macrobull 已提交
623 624 625
resnet100_arcface
resnet101_duc
resnet152
M
Macrobull 已提交
626
shufflenet
M
Macrobull 已提交
627
squeezenet # softmax bug
M
bugfix  
Macrobull 已提交
628 629 630 631
squeezenet1v1
ssd # version not supported
tiny_yolov2 # not supported
vgg16bn
M
Macrobull 已提交
632
vgg19
M
bugfix  
Macrobull 已提交
633
yolov3 # malformed model ?
M
Macrobull 已提交
634
zfnet512