-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexport.sh
executable file
·44 lines (40 loc) · 1.57 KB
/
export.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
#!/bin/bash
#
# Export model
#
. config.sh
cd models/research
export PYTHONPATH="$PYTHONPATH:$(pwd):$(pwd)/slim"
export CUDA_VISIBLE_DEVICES=
# Export latest checkpoint
lastCheckpoint="$(ls ../../$models/model.ckpt-* | \
sort | tail -n 1 | sed -r 's#\.[^\.]+$##g')"
python3 object_detection/export_tflite_ssd_graph.py \
--pipeline_config_path="../../$config" \
--trained_checkpoint_prefix="$lastCheckpoint" \
--output_directory="../../$exported" \
--add_postprocessing_op=true
if (( $quantize )); then
echo "Outputting quantized model"
toco \
--graph_def_file="../../$exported/tflite_graph.pb" \
--output_file="../../$exported/detect.tflite" \
--input_shapes=1,300,300,3 \
--input_arrays=normalized_input_image_tensor \
--output_arrays='TFLite_Detection_PostProcess','TFLite_Detection_PostProcess:1','TFLite_Detection_PostProcess:2','TFLite_Detection_PostProcess:3' \
--inference_type=QUANTIZED_UINT8 \
--mean_values=128 \
--std_dev_values=128 \
--change_concat_input_ranges=false \
--allow_custom_ops
else
echo "Outputting floating point model"
toco \
--graph_def_file="../../$exported/tflite_graph.pb" \
--output_file="../../$exported/detect.tflite" \
--input_shapes=1,300,300,3 \
--input_arrays=normalized_input_image_tensor \
--output_arrays='TFLite_Detection_PostProcess','TFLite_Detection_PostProcess:1','TFLite_Detection_PostProcess:2','TFLite_Detection_PostProcess:3' \
--inference_type=FLOAT \
--allow_custom_ops
fi