0% found this document useful (0 votes)
74 views1 page

Convert Pb2 Tflite

This Python code takes a TensorFlow model file and converts it to TensorFlow Lite format for deployment on mobile devices. It imports TensorFlow, defines the input and output model paths and names, initializes a converter object, runs the conversion, and saves the converted model file.

Uploaded by

dedSec PC
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views1 page

Convert Pb2 Tflite

This Python code takes a TensorFlow model file and converts it to TensorFlow Lite format for deployment on mobile devices. It imports TensorFlow, defines the input and output model paths and names, initializes a converter object, runs the conversion, and saves the converted model file.

Uploaded by

dedSec PC
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

import tensorflow as tf

in_path = "model.pb"
out_path = "model.tflite"

input_tensor_name = ["input_x"]
output_tensor_name = ["output/y_hat"]

converter = tf.compat.v1.tflite.TFLiteConverter.from_frozen_graph(in_path,

input_tensor_name,

output_tensor_name)

converter.experimental_new_converter = True
tflite_model = converter.convert()

with open(out_path, 'wb') as f:


f.write(tflite_model)

You might also like