Imported Upstream version 1.8.0
[platform/core/ml/nnfw.git] / compiler / tf2tfliteV2 / README.md
1 # tf2tfliteV2
2
3 _tf2tfliteV2_ is a TensorFlow to TensorFlow Lite model Converter.
4
5 ## Where does V2 come from?
6 Even though we alreay have _tf2tflite_, we cannot cover all opeartors in TensorFlow. To expand coverage, we introduce _tf2tfliteV2_ which uses `TensorFlow Lite Converter`(by Google) internally.
7
8 ## Prerequisite
9 - Frozen graph from TensorFlow 1.13.1 in binary(`*.pb`) or text(`*.pbtxt`) format
10 - Desired version of TensorFlow(You can use python virtualenv, docker, etc.)
11
12 ## Example
13 ```
14 python tf2tfliteV2.py \
15 > --v1 \
16 > -i frozen_graph.pb -o converted.tflite
17 > -I model_inputs -O model_outputs
18 ```
19 ```
20 python tf2tfliteV2.py \
21 > --v1 \
22 > --input_path=frozen_graph.pb \
23 > --output_path=converted.tflite \
24 > --input_arrays=model_inputs \
25 > --output_arrays=model_outputs
26
27 ```
28 ```
29 python tf2tfliteV2.py \
30 > --v2 \
31 > --input_path=frozen_graph.pbtxt \
32 > --output_path=converted.tflite \
33 > --input_arrays=model_inputs \
34 > --output_arrays=model_outputs
35 ```
36 ```
37 python tf2tfliteV2.py \
38 > --v2 \
39 > --input_path=multiple_output_graph.pb \
40 > --output_path=converted.tflite \
41 > --input_arrays=model_inputs \
42 > --output_arrays=output,output:1,output:2
43 ```
44
45 ## optional argument
46 ```
47   -h, --help            show this help message and exit
48   --v1                  Use TensorFlow Lite Converter 1.x
49   --v2                  Use TensorFlow Lite Converter 2.x
50   --graph_def           Use graph def file(default)
51   --saved_model         Use saved model
52   --keras_model         Use keras model
53   -i INPUT_PATH, --input_path INPUT_PATH
54                         Full filepath of the input file.
55   -o OUTPUT_PATH, --output_path OUTPUT_PATH
56                         Full filepath of the output file.
57   -I INPUT_ARRAYS, --input_arrays INPUT_ARRAYS
58                         Names of the input arrays, comma-separated.
59   -s INPUT_SHAPES, --input_shapes INPUT_SHAPES
60                         Shapes corresponding to --input_arrays, colon-
61                         separated.(ex:"1,4,4,3:1,20,20,3")
62   -O OUTPUT_ARRAYS, --output_arrays OUTPUT_ARRAYS
63                         Names of the output arrays, comma-separated.
64
65 ```