Instructions to use SpotLab/MobileViT_DeepLabv3 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use SpotLab/MobileViT_DeepLabv3 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-segmentation", model="SpotLab/MobileViT_DeepLabv3")# Load model directly from transformers import AutoImageProcessor, MobileViTForSemanticSegmentation processor = AutoImageProcessor.from_pretrained("SpotLab/MobileViT_DeepLabv3") model = MobileViTForSemanticSegmentation.from_pretrained("SpotLab/MobileViT_DeepLabv3", device_map="auto") - Notebooks
- Google Colab
- Kaggle
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) |