Skip to content

Instantly share code, notes, and snippets.

@novasush
Created March 15, 2023 06:35
Show Gist options
  • Save novasush/2a8418147348957db0f48a207fca1d22 to your computer and use it in GitHub Desktop.
Save novasush/2a8418147348957db0f48a207fca1d22 to your computer and use it in GitHub Desktop.
from tensorflow.python.compiler.tensorrt import trt_convert as trt
# Instantiate the TF-TRT converter
# Here saved model directory is the path to the saved model
# You can customise precision mode to FP32 FP16 or INT8
converter = trt.TrtGraphConverterV2(
input_saved_model_dir=SAVED_MODEL_DIR,
precision_mode=trt.TrtPrecisionMode.FP32
)
# Convert the model into TRT compatible segments
trt_func = converter.convert()
converter.summary()
# save the model by specifying output dir path
converter.save(output_saved_model_dir=OUTPUT_SAVED_MODEL_DIR)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment