cb1067e2837d0810f2ac9319cf4e2fe5cf065cfa
[platform/core/ml/nnfw.git] / compiler / one-cmds / tests / prepare_test_materials.sh
1 #!/bin/bash
2
3 # Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #    http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 # See https://github.com/Samsung/ONE/issues/4155 for information
18
19 SCRIPT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
20 pushd $SCRIPT_PATH > /dev/null
21
22 if [[ ! -s "inception_v3.pb" ]]; then
23     rm -rf inception_v3_2018_04_27.tgz
24     wget https://storage.googleapis.com/download.tensorflow.org/models/tflite/model_zoo/upload_20180427/inception_v3_2018_04_27.tgz
25     tar zxvf inception_v3_2018_04_27.tgz
26 fi
27
28 if [[ ! -s "while_3.pbtxt" ]]; then
29     rm -rf while_3.zip
30     wget https://github.com/Samsung/ONE/files/5095630/while_3.zip
31     unzip while_3.zip
32     # https://github.com/Samsung/ONE/issues/4155#issuecomment-689320297
33 fi
34
35 if [[ ! -s "mobilenet_test_data.h5" ]]; then
36     rm -rf mobilenet_test_data.zip
37     wget https://github.com/Samsung/ONE/files/5139460/mobilenet_test_data.zip
38     unzip mobilenet_test_data.zip
39     # https://github.com/Samsung/ONE/issues/4155#issuecomment-689321538
40 fi
41
42 if [[ ! -s "bcq.pb" ]]; then
43     rm -rf bcq.pb.zip
44     wget https://github.com/Samsung/ONE/files/5153842/bcq.pb.zip
45     unzip bcq.pb.zip
46     # https://github.com/Samsung/ONE/issues/4155#issuecomment-689324597
47 fi
48
49 if [[ ! -s "img_files" ]]; then
50     rm -rf img_files.zip
51     wget https://github.com/Samsung/ONE/files/5499172/img_files.zip
52     unzip img_files.zip
53     # https://github.com/Samsung/ONE/issues/3213#issuecomment-722757499
54 fi
55
56 if [ ! -d "raw_files" ] || [ ! -s "datalist.txt" ]; then
57     ../bin/venv/bin/python preprocess_images.py
58 fi
59
60 if [[ ! -s "inception_v3_test_data.h5" ]]; then
61   ../bin/venv/bin/python ../bin/rawdata2hdf5 \
62   --data_list datalist.txt \
63   --output_path inception_v3_test_data.h5
64 fi
65
66 # prepare 'inception_v3.circle' file used for quantization test
67 inputfile="./inception_v3.pb"
68 outputfile="./inception_v3.circle"
69
70 if [[ ! -s ${outputfile} ]]; then
71   ../bin/one-import-tf \
72   --input_path ${inputfile} \
73   --output_path ${outputfile} \
74   --input_arrays input --input_shapes "1,299,299,3" \
75   --output_arrays InceptionV3/Predictions/Reshape_1
76 fi
77
78 popd > /dev/null