Skip to content

Commit ce59424

Browse files
fyangftensorflower-gardener
authored andcommitted
Internal change
PiperOrigin-RevId: 398043538
1 parent b6baa76 commit ce59424

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

official/vision/beta/serving/export_tflite.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,26 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
"""Binary to convert a saved model to tflite model."""
15+
r"""Binary to convert a saved model to tflite model.
16+
17+
It requires a SavedModel exported using export_saved_model.py with batch size 1
18+
and input type `tflite`, and using the same config file used for exporting saved
19+
model. It includes optional post-training quantization. When using integer
20+
quantization, calibration steps need to be provided to calibrate model input.
21+
22+
To convert a SavedModel to a TFLite model:
23+
24+
EXPERIMENT_TYPE = XX
25+
TFLITE_PATH = XX
26+
SAVED_MOODEL_DIR = XX
27+
CONFIG_FILE = XX
28+
export_tflite --experiment=${EXPERIMENT_TYPE} \
29+
--saved_model_dir=${SAVED_MOODEL_DIR} \
30+
--tflite_path=${TFLITE_PATH} \
31+
--config_file=${CONFIG_FILE} \
32+
--quant_type=fp16 \
33+
--calibration_steps=500
34+
"""
1635
from absl import app
1736
from absl import flags
1837
from absl import logging

0 commit comments

Comments
 (0)