tflite2tensorflow
【WIP】 Generate saved_model, tfjs, tf-trt, EdgeTPU, CoreML, quantized tflite and .pb from .tflite.
1. Supported Layers
| No. | TFLite Layer | TF Layer | Remarks |
|---|---|---|---|
| 1 | CONV_2D | tf.nn.conv2d | |
| 2 | DEPTHWISE_CONV_2D | tf.nn.depthwise_conv2d | |
| 3 | MAX_POOL_2D | tf.nn.max_pool | |
| 4 | PAD | tf.pad | |
| 5 | MIRROR_PAD | tf.raw_ops.MirrorPad | |
| 6 | RELU | tf.nn.relu | |
| 7 | PRELU | tf.keras.layers.PReLU | |
| 8 | RELU6 | tf.nn.relu6 | |
| 9 | RESHAPE | tf.reshape | |
| 10 | ADD | tf.add | |
| 11 | SUB | tf.math.subtract | |
| 12 | CONCATENATION | tf.concat | |
| 13 | LOGISTIC | tf.math.sigmoid | |
| 14 | TRANSPOSE_CONV | tf.nn.conv2d_transpose | |
| 15 | MUL | tf.multiply | |
| 16 | HARD_SWISH | x*tf.nn.relu6(x+3)*0.16666667 Or x*tf.nn.relu6(x+3)*0.16666666 | |
| 17 | AVERAGE_POOL_2D | tf.keras.layers.AveragePooling2D | |
| 18 | FULLY_CONNECTED | tf.keras.layers.Dense | |
| 19 | RESIZE_BILINEAR | tf.image.resize Or tf.image.resize_bilinear | |
| 20 | RESIZE_NEAREST_NEIGHBOR | tf.image.resize Or tf.image.resize_nearest_neighbor | |
| 21 | MEAN | tf.math.reduce_mean | |
| 22 | SQUARED_DIFFERENCE | tf.math.squared_difference | |
| 23 | RSQRT | tf.math.rsqrt | |
| 24 | DEQUANTIZE | (const) | |
| 25 | FLOOR | tf.math.floor | |
| 26 | TANH | tf.math.tanh | |
| 27 | DIV | tf.math.divide | |
| 28 | FLOOR_DIV | tf.math.floordiv | |
| 29 | SUM | tf.math.reduce_sum | |
| 30 | POW | tf.math.pow | |
| 31 | SPLIT | tf.split | |
| 32 | SOFTMAX | tf.nn.softmax | |
| 33 | STRIDED_SLICE | tf.strided_slice | |
| 34 | TRANSPOSE | ttf.transpose | |
| 35 | SPACE_TO_DEPTH | tf.nn.space_to_depth | |
| 36 | DEPTH_TO_SPACE | tf.nn.depth_to_space |
2. Environment
- Python3.6+
- TensorFlow v2.4.0+ or tf-nightly
3. Setup
To install using the Python Package Index (PyPI), use the following command.
$ pip3 install tflite2tensorflow --upgrade
To install with the latest source code of the main branch, use the following command.
$ pip3 install git+https://github.com/PINTO0309/tflite2tensorflow --upgrade
4. Usage / Execution sample
4-1. Step 1 : Generating saved_model and FreezeGraph (.pb)
$ tflite2tensorflow \
--model_path magenta_arbitrary-image-stylization-v1-256_fp16_prediction_1.tflite \
--flatc_path ./flatc \
--schema_path schema.fbs \
--output_pb True
or
$ tflite2tensorflow \
--model_path magenta_arbitrary-image-stylization-v1-256_fp16_prediction_1.tflite \
--flatc_path ./flatc \
--schema_path schema.fbs \
--output_pb True \
--optimizing_hardswish_for_edgetpu True
4-2. Step 2 : Generation of quantized tflite, TFJS, TF-TRT, EdgeTPU, and CoreML
$ tflite2tensorflow \
--model_path magenta_arbitrary-image-stylization-v1-256_fp16_prediction_1.tflite \
--flatc_path ./flatc \
--schema_path schema.fbs \
--output_no_quant_float32_tflite True \
--output_weight_quant_tflite True \
--output_float16_quant_tflite True \
--output_integer_quant_tflite True \
--string_formulas_for_normalization 'data / 255.0' \
--output_tfjs True \
--output_coreml True \
--output_tftrt True
or
$ tflite2tensorflow \
--model_path magenta_arbitrary-image-stylization-v1-256_fp16_prediction_1.tflite \
--flatc_path ./flatc \
--schema_path schema.fbs \
--output_no_quant_float32_tflite True \
--output_weight_quant_tflite True \
--output_float16_quant_tflite True \
--output_integer_quant_tflite True \
--output_edgetpu True \
--string_formulas_for_normalization 'data / 255.0' \
--output_tfjs True \
--output_coreml True \
--output_tftrt True
Metadata
Release files for tflite2tensorflow 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tflite2tensorflow-0.1.3.tar.gz | 13.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tflite2tensorflow-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 26.4 kB
Release files / tflite2tensorflow-0.1.3.tar.gz
| Download URL | tflite2tensorflow-0.1.3.tar.gz |
|---|---|
| Size | 13.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5a37a4e70c9926873eb7704be0ad6a15359b0d0779c166551930b39539376623
|
|
BLAKE2b-256 checksum How to use checksums |
29c0fb3e6ea467db4831176eabe422445dea01534f819f2512bef7afa5e7b7aa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.0 requests/2.22.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.6.9
|
Release files / tflite2tensorflow-0.1.3-py3-none-any.whl
| Download URL | tflite2tensorflow-0.1.3-py3-none-any.whl |
|---|---|
| Size | 13.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bc5fd69007b7736e53b7f9d56afea5f1ad01495a43b25533bf016bd8866f448f
|
|
BLAKE2b-256 checksum How to use checksums |
0b1c3e0a846356edcfbd45d7bc8373b74d16f7e28c2ab733e6863dfa8915979e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.0 requests/2.22.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.6.9
|