forked from alibaba/MNN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_model.sh
executable file
·122 lines (105 loc) · 4.22 KB
/
get_model.sh
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
#!/bin/bash
pushd "$(dirname $0)"/../.. > /dev/null
pushd resource > /dev/null
# mkdir
if [ ! -d build ]; then
mkdir build
fi
# build converter
CONVERTER=build/MNNConvert
if [ ! -e $CONVERTER ]; then
echo "building converter ..."
pushd ../tools/converter > /dev/null
./build_tool.sh
popd > /dev/null
cp ../tools/converter/build/MNNConvert $CONVERTER
fi
# functions
download() {
if [ -e $2 ]; then return 0; fi
name=`basename $2`
echo "downloading $name ..."
status=`curl $1 -s -w %{http_code} -o $2`
if (( status == 200 )); then
return 0
else
echo "download $name failed" 1>&2
return -1
fi
}
get_caffe1() { # model_URL, model_path, prototxt_URL, prototxt_path, model, MNN_path
if [ ! -e $6 ]; then
download $1 $2 && download $3 $4 && ./$CONVERTER -f CAFFE --modelFile $2 --prototxt $4 --MNNModel $6 --bizCode 0000
fi
}
get_tensorflow_lite() {
if [ ! -e $4 ]; then
pushd build > /dev/null
download $1 $2.tgz && tar -xzf $2.tgz $2
succ=$?
popd > /dev/null
[ $succ -eq 0 ] && ./$CONVERTER -f TFLITE --modelFile build/$2 --MNNModel $4 --bizCode 0000
fi
}
get_portrait_lite() {
if [ ! -e $4 ]; then
pushd build > /dev/null
download $1 $2
succ=$?
popd > /dev/null
[ $succ -eq 0 ] && ./$CONVERTER -f TFLITE --modelFile build/$2 --MNNModel $4 --bizCode 0000
fi
}
# get models
## Using MobileNet V1 downloaded from: https://github.com/shicai/MobileNet-Caffe/
get_caffe1 \
"https://raw.githubusercontent.com/shicai/MobileNet-Caffe/master/mobilenet.caffemodel" \
"build/mobilenet_v1.caffe.caffemodel" \
"https://raw.githubusercontent.com/shicai/MobileNet-Caffe/master/mobilenet_deploy.prototxt" \
"build/mobilenet_v1.caffe.prototxt" \
"MobileNet V1" \
"model/MobileNet/v1/mobilenet_v1.caffe.mnn"
## Using MobileNet V2 downloaded from: https://github.com/shicai/MobileNet-Caffe/
get_caffe1 \
"https://raw.githubusercontent.com/shicai/MobileNet-Caffe/master/mobilenet_v2.caffemodel" \
"build/mobilenet_v2.caffe.caffemodel" \
"https://raw.githubusercontent.com/shicai/MobileNet-Caffe/master/mobilenet_v2_deploy.prototxt" \
"build/mobilenet_v2.caffe.prototxt" \
"MobileNet V2" \
"model/MobileNet/v2/mobilenet_v2.caffe.mnn"
## Using SqueezeNet V1.0 downloaded from: https://github.com/DeepScale/SqueezeNet/
get_caffe1 \
"https://raw.githubusercontent.com/DeepScale/SqueezeNet/master/SqueezeNet_v1.0/squeezenet_v1.0.caffemodel" \
"build/squeezenet_v1.0.caffe.caffemodel" \
"https://raw.githubusercontent.com/DeepScale/SqueezeNet/master/SqueezeNet_v1.0/deploy.prototxt" \
"build/squeezenet_v1.0.caffe.prototxt" \
"SqueezeNet V1.0" \
"model/SqueezeNet/v1.0/squeezenet_v1.0.caffe.mnn"
## Using SqueezeNet V1.1 downloaded from: https://github.com/DeepScale/SqueezeNet/
get_caffe1 \
"https://raw.githubusercontent.com/DeepScale/SqueezeNet/master/SqueezeNet_v1.1/squeezenet_v1.1.caffemodel" \
"build/squeezenet_v1.1.caffe.caffemodel" \
"https://raw.githubusercontent.com/DeepScale/SqueezeNet/b6b5ae2ce884a3866c21efd31e103defde8631ae/SqueezeNet_v1.1/deploy.prototxt" \
"build/squeezenet_v1.1.caffe.prototxt" \
"SqueezeNet V1.1" \
"model/SqueezeNet/v1.1/squeezenet_v1.1.caffe.mnn"
## Using MobileNet V2 downloaded from: http://download.tensorflow.org/models/tflite_11_05_08/mobilenet_v2_1.0_224.tgz
get_tensorflow_lite \
"http://download.tensorflow.org/models/tflite_11_05_08/mobilenet_v2_1.0_224.tgz" \
"mobilenet_v2_1.0_224.tflite" \
"MobileNet V2 TFLite" \
"model/MobileNet/v2/mobilenet_v2_1.0_224.tflite.mnn"
## Using MobileNet V2 downloaded from: http://download.tensorflow.org/models/tflite_11_05_08/mobilenet_v2_1.0_224_quant.tgz
get_tensorflow_lite \
"http://download.tensorflow.org/models/tflite_11_05_08/mobilenet_v2_1.0_224_quant.tgz" \
"mobilenet_v2_1.0_224_quant.tflite" \
"MobileNet V2 TFLite Quantized" \
"model/MobileNet/v2/mobilenet_v2_1.0_224_quant.tflite.mnn"
## Using deeplab v3 downloaded from: https://storage.googleapis.com/download.tensorflow.org/models/tflite/gpu/deeplabv3_257_mv_gpu.tflite
get_portrait_lite \
"https://storage.googleapis.com/download.tensorflow.org/models/tflite/gpu/deeplabv3_257_mv_gpu.tflite" \
"deeplabv3_257_mv_gpu.tflite" \
"deeplabv3" \
"model/Portrait/Portrait.tflite.mnn"
popd > /dev/null
popd > /dev/null