MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _convert_tf2_model

Function _convert_tf2_model

tensorflow/lite/python/tflite_convert.py:204–223  ·  view source on GitHub ↗

Calls function to convert the TensorFlow 2.0 model into a TFLite model. Args: flags: argparse.Namespace object. Raises: ValueError: Unsupported file format.

(flags)

Source from the content-addressed store, hash-verified

202
203
204def _convert_tf2_model(flags):
205 """Calls function to convert the TensorFlow 2.0 model into a TFLite model.
206
207 Args:
208 flags: argparse.Namespace object.
209
210 Raises:
211 ValueError: Unsupported file format.
212 """
213 # Load the model.
214 if flags.saved_model_dir:
215 converter = lite.TFLiteConverterV2.from_saved_model(flags.saved_model_dir)
216 elif flags.keras_model_file:
217 model = keras.models.load_model(flags.keras_model_file)
218 converter = lite.TFLiteConverterV2.from_keras_model(model)
219
220 # Convert the model.
221 tflite_model = converter.convert()
222 with open(flags.output_file, "wb") as f:
223 f.write(tflite_model)
224
225
226def _check_tf1_flags(flags, unparsed):

Callers 1

run_mainFunction · 0.85

Calls 4

from_keras_modelMethod · 0.80
from_saved_modelMethod · 0.45
convertMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected