--- pipeline_tag: image-segmentation license: apple-amlr base_model: apple/mobilevitv2-1.0-voc-deeplabv3 library_name: zeromodels tags: - keras - zeromodels - mobilevit - deeplabv3 - image-segmentation - semantic-segmentation - arxiv:2110.02178 - arxiv:2206.02680 - pytorch - jax - tf --- ## ***See [our collection](https://huggingface.co/collections/zeromodels/mobilevit-v1-and-v2-6a8eaf6304112b66453f9ccc) for MobileViT / MobileViTV2 DeepLabV3 segmentation.*** # Run MobileViTV2 DeepLabV3 with Keras 3: JAX, PyTorch, or TensorFlow [![GitHub](https://img.shields.io/badge/GitHub-ZeroModels-black?logo=github)](https://github.com/IMvision12/ZeroModels) [![Docs](https://img.shields.io/badge/Docs-MobileViT%20DeepLabV3-blue)](https://imvision12.github.io/ZeroModels/mobilevitv2/) [![Collection](https://img.shields.io/badge/HF-MobileViT%20seg%20collection-yellow)](https://huggingface.co/collections/zeromodels/mobilevit-v1-and-v2-6a8eaf6304112b66453f9ccc) # zeromodels/mobilevitv2_100_deeplabv3 Papers: [MobileViT (arXiv:{PAPER_ARXIV})]({PAPER_URL}) · [MobileViTV2 (arXiv:2206.02680)](https://arxiv.org/abs/2206.02680) · [HF Papers](https://huggingface.co/papers/2110.02178) MobileViTV2 backbone + **DeepLabV3 ASPP** head for Pascal VOC semantic segmentation (21 classes). **Resolution is 512**, not the 256 used by ImageNet classification checkpoints. Always load the processor with `from_weights` so resize/crop match. For more details on the model, please go to the upstream [model card](https://huggingface.co/apple/mobilevitv2-1.0-voc-deeplabv3). Pure-**Keras 3** conversion of [`apple/mobilevitv2-1.0-voc-deeplabv3`](https://huggingface.co/apple/mobilevitv2-1.0-voc-deeplabv3) for [zeromodels](https://github.com/IMvision12/ZeroModels). One implementation runs unmodified on **TensorFlow / Torch / JAX**. This is a **semantic segmentation** checkpoint (`MobileViTV2SemanticSegment`). ## ✨ Quick start ```python import os os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow" from PIL import Image from zeromodels.models.mobilevitv2 import ( MobileViTV2SemanticSegment, MobileViTV2ImageProcessor, ) model = MobileViTV2SemanticSegment.from_weights("zeromodels/mobilevitv2_100_deeplabv3") processor = MobileViTV2ImageProcessor.from_weights("zeromodels/mobilevitv2_100_deeplabv3") image = Image.open("your_image.jpg").convert("RGB") output = model(processor(image)["pixel_values"], training=False) result = processor.post_process_semantic_segmentation( output, target_size=(image.height, image.width) ) print(result["segmentation"].shape) # (H, W) class ids ``` Load any DeepLabV3 MobileViT variant the same way with `from_weights("zeromodels/")`: | Variant | Hub | Family | |---|---|---| | `mobilevit_xxs_deeplabv3` | [`zeromodels/mobilevit_xxs_deeplabv3`](https://huggingface.co/zeromodels/mobilevit_xxs_deeplabv3) | MobileViT v1 | | `mobilevit_xs_deeplabv3` | [`zeromodels/mobilevit_xs_deeplabv3`](https://huggingface.co/zeromodels/mobilevit_xs_deeplabv3) | MobileViT v1 | | `mobilevit_s_deeplabv3` | [`zeromodels/mobilevit_s_deeplabv3`](https://huggingface.co/zeromodels/mobilevit_s_deeplabv3) | MobileViT v1 | | `mobilevitv2_100_deeplabv3` | [`zeromodels/mobilevitv2_100_deeplabv3`](https://huggingface.co/zeromodels/mobilevitv2_100_deeplabv3) | MobileViT v2 | | `mobilevitv2_150_deeplabv3` | [`zeromodels/mobilevitv2_150_deeplabv3`](https://huggingface.co/zeromodels/mobilevitv2_150_deeplabv3) | MobileViT v2 | ## Tips - Set `KERAS_BACKEND` **before** importing Keras / zeromodels. - Do not reuse a classification processor: seg checkpoints need 544/512. - v1 imports from `mobilevit`; v2 from `mobilevitv2`. - See [docs](https://imvision12.github.io/ZeroModels/mobilevitv2/) and [Loading Weights](https://imvision12.github.io/ZeroModels/loading_weights/). - Upstream: `MobileViTV2SemanticSegment.from_weights("hf:apple/mobilevitv2-1.0-voc-deeplabv3")`. ## Special Thanks A huge thank you to the Apple MobileViT authors for creating and releasing these models. License: see YAML / upstream card.