CoolFace
Modelpublic

SpotLab/MobileViT_DeepLabv3

sourceHugging Faceotherupdated 3y agoView on Hugging Face
0likes251downloads
tflite_convert.py15 linesDownload Raw Back to scripts
1from transformers import TFMobileViTForSemanticSegmentation2import tensorflow as tf3 4if __name__ == '__main__':5    model = TFMobileViTForSemanticSegmentation.from_pretrained(".")6    converter = tf.lite.TFLiteConverter.from_keras_model(model)7    converter.optimizations = [tf.lite.Optimize.DEFAULT]8    converter.target_spec.supported_ops = [9        tf.lite.OpsSet.TFLITE_BUILTINS,10        tf.lite.OpsSet.SELECT_TF_OPS,11    ]12    tflite_model = converter.convert()13    tflite_filename = "tflite_model.tflite"14    with open(tflite_filename, "wb") as f:15        f.write(tflite_model)