-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathu2net.sh
executable file
·79 lines (75 loc) · 2.07 KB
/
u2net.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
#!/bin/bash
MODEL="u2net"
FILE1="${MODEL}.onnx"
FILE2="${MODEL}.onnx.prototxt"
ARCH="large"
OPSET="10"
status=0
for n in "$@"
do
if [ "$n" = "-a" ] || [ "$n" = "--arch" ]; then
status=1
elif [ "$n" = "-o" ] || [ "$n" = "--opset" ]; then
status=2
elif [ $status -eq 1 ]; then
if [ "$n" = "small" ] || [ "$n" = "large" ]; then
ARCH="$n"
else
break;
fi
status=0
elif [ $status -eq 2 ]; then
if [ "$n" = "10" ] || [ "$n" = "11" ]; then
OPSET="$n"
else
break;
fi
status=0
else
status=0
fi
done
#download
if [ ! "$1" = "-h" ] && [ ! "$1" = "--help" ] && [ $status -eq 0 ]; then
if [ "${ARCH}" = "small" ]; then
if [ "${OPSET}" = "10" ]; then
FILE1="${MODEL}p.onnx"
else
FILE1="${MODEL}p_opset11.onnx"
fi
else
if [ "${OPSET}" = "10" ]; then
FILE1="${MODEL}.onnx"
else
FILE1="${MODEL}_opset11.onnx"
fi
fi
if [ ! -e ${FILE1} ]; then
echo "Downloading onnx file... save path: ${FILE1}"
curl https://storage.googleapis.com/ailia-models/${MODEL}/${FILE1} -o ${FILE1}
# wget https://storage.googleapis.com/ailia-models/${MODEL}/${FILE1}
fi
fi
if [ ! "$1" = "-h" ] && [ ! "$1" = "--help" ] && [ $status -eq 0 ]; then
if [ "${ARCH}" = "small" ]; then
if [ "${OPSET}" = "10" ]; then
FILE2="${MODEL}p.onnx.prototxt"
else
FILE2="${MODEL}p_opset11.onnx.prototxt"
fi
else
if [ "${OPSET}" = "10" ]; then
FILE2="${MODEL}.onnx.prototxt"
else
FILE2="${MODEL}_opset11.onnx.prototxt"
fi
fi
if [ ! -e ${FILE2} ]; then
echo "Downloading onnx file... save path: ${FILE2}"
curl https://storage.googleapis.com/ailia-models/${MODEL}/${FILE2} -o ${FILE2}
# wget https://storage.googleapis.com/ailia-models/${MODEL}/${FILE2}
fi
echo "ONNX file and Prototxt file are prepared!"
fi
#execute
./${MODEL} $*