File size: 584 Bytes
9d05b02 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
from transformers import TFMobileViTForSemanticSegmentation
import tensorflow as tf
if __name__ == '__main__':
model = TFMobileViTForSemanticSegmentation.from_pretrained(".")
converter = tf.lite.TFLiteConverter.from_keras_model(model)
converter.optimizations = [tf.lite.Optimize.DEFAULT]
converter.target_spec.supported_ops = [
tf.lite.OpsSet.TFLITE_BUILTINS,
tf.lite.OpsSet.SELECT_TF_OPS,
]
tflite_model = converter.convert()
tflite_filename = "tflite_model.tflite"
with open(tflite_filename, "wb") as f:
f.write(tflite_model) |