Run this model with HF Jobs
Run SpotLab/MobileViT_DeepLabv3 on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/SpotLab/MobileViT_DeepLabv3. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/SpotLab/MobileViT_DeepLabv3 on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
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")# pip install -U transformers accelerate # 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
Jaime García Villena commited on
Commit ·
9b0616b
1
Parent(s): a2798f2
Copy from apple/deeplabv3-mobilevit-small
Browse filesFiles changed (10)
- .gitattributes+1-9
- .gitignoreAdded+2
- MobileViT_DeepLabV3.mlpackage/Data/com.apple.CoreML/model.mlmodelAdded
- MobileViT_DeepLabV3.mlpackage/Data/com.apple.CoreML/weights/weight.binAdded+3
- MobileViT_DeepLabV3.mlpackage/Manifest.jsonAdded+18
- README.mdAdded+86
- config.jsonAdded+91
- preprocessor_config.jsonAdded+9
- pytorch_model.binAdded+3
- tf_model.h5Added+3
1 unmodified line2345678910111213141516171819202122232425262728293031323334351 unmodified line*.arrow filter=lfs diff=lfs merge=lfs -text*.bin filter=lfs diff=lfs merge=lfs -text*.bz2 filter=lfs diff=lfs merge=lfs -text*.ckpt filter=lfs diff=lfs merge=lfs -text*.ftz filter=lfs diff=lfs merge=lfs -text*.gz filter=lfs diff=lfs merge=lfs -text*.h5 filter=lfs diff=lfs merge=lfs -text*.joblib filter=lfs diff=lfs merge=lfs -text*.lfs.* filter=lfs diff=lfs merge=lfs -text*.mlmodel filter=lfs diff=lfs merge=lfs -text*.model filter=lfs diff=lfs merge=lfs -text*.msgpack filter=lfs diff=lfs merge=lfs -text*.npy filter=lfs diff=lfs merge=lfs -text*.npz filter=lfs diff=lfs merge=lfs -text*.onnx filter=lfs diff=lfs merge=lfs -text*.ot filter=lfs diff=lfs merge=lfs -text*.parquet filter=lfs diff=lfs merge=lfs -text*.pb filter=lfs diff=lfs merge=lfs -text*.pickle filter=lfs diff=lfs merge=lfs -text*.pkl filter=lfs diff=lfs merge=lfs -text*.pt filter=lfs diff=lfs merge=lfs -text*.pth filter=lfs diff=lfs merge=lfs -text*.rar filter=lfs diff=lfs merge=lfs -text*.safetensors filter=lfs diff=lfs merge=lfs -textsaved_model/**/* filter=lfs diff=lfs merge=lfs -text*.tar.* filter=lfs diff=lfs merge=lfs -text*.tar filter=lfs diff=lfs merge=lfs -text*.tflite filter=lfs diff=lfs merge=lfs -text*.tgz filter=lfs diff=lfs merge=lfs -text*.wasm filter=lfs diff=lfs merge=lfs -text*.xz filter=lfs diff=lfs merge=lfs -text*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -text1 unmodified line234567891011121314151617181920212223242526271 unmodified line*.arrow filter=lfs diff=lfs merge=lfs -text*.bin filter=lfs diff=lfs merge=lfs -text*.bz2 filter=lfs diff=lfs merge=lfs -text*.ftz filter=lfs diff=lfs merge=lfs -text*.gz filter=lfs diff=lfs merge=lfs -text*.h5 filter=lfs diff=lfs merge=lfs -text*.joblib filter=lfs diff=lfs merge=lfs -text*.lfs.* filter=lfs diff=lfs merge=lfs -text*.model filter=lfs diff=lfs merge=lfs -text*.msgpack filter=lfs diff=lfs merge=lfs -text*.onnx filter=lfs diff=lfs merge=lfs -text*.ot filter=lfs diff=lfs merge=lfs -text*.parquet filter=lfs diff=lfs merge=lfs -text*.pb filter=lfs diff=lfs merge=lfs -text*.pt filter=lfs diff=lfs merge=lfs -text*.pth filter=lfs diff=lfs merge=lfs -text*.rar filter=lfs diff=lfs merge=lfs -textsaved_model/**/* filter=lfs diff=lfs merge=lfs -text*.tar.* filter=lfs diff=lfs merge=lfs -text*.tflite filter=lfs diff=lfs merge=lfs -text*.tgz filter=lfs diff=lfs merge=lfs -text*.wasm filter=lfs diff=lfs merge=lfs -text*.xz filter=lfs diff=lfs merge=lfs -text*.zip filter=lfs diff=lfs merge=lfs -text*.zstandard filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -text
12.DS_Store*/.DS_Store123version https://git-lfs.github.com/spec/v1oid sha256:e50a89dd6be1e3ba7e4df23be4f2d79a081d443c1e498536377d30b8e5fb3a29size 25418432123456789101112131415161718{ "fileFormatVersion": "1.0.0", "itemInfoEntries": { "4D7D9A73-AEEC-412D-A20C-7AA2C0F806EF": { "author": "com.apple.CoreML", "description": "CoreML Model Specification", "name": "model.mlmodel", "path": "com.apple.CoreML/model.mlmodel" }, "FBABE180-594F-4894-9881-F3B3D807D27D": { "author": "com.apple.CoreML", "description": "CoreML Model Weights", "name": "weights", "path": "com.apple.CoreML/weights" } }, "rootModelIdentifier": "4D7D9A73-AEEC-412D-A20C-7AA2C0F806EF"}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586---license: othertags:- vision- image-segmentationdatasets:- pascal-vocwidget:- src: https://huggingface.co/datasets/mishig/sample_images/resolve/main/cat-2.jpg example_title: Cat---
# MobileViT + DeepLabV3 (small-sized model)
MobileViT model pre-trained on PASCAL VOC at resolution 512x512. It was introduced in [MobileViT: Light-weight, General-purpose, and Mobile-friendly Vision Transformer](https://arxiv.org/abs/2110.02178) by Sachin Mehta and Mohammad Rastegari, and first released in [this repository](https://github.com/apple/ml-cvnets). The license used is [Apple sample code license](https://github.com/apple/ml-cvnets/blob/main/LICENSE).
Disclaimer: The team releasing MobileViT did not write a model card for this model so this model card has been written by the Hugging Face team.
## Model description
MobileViT is a light-weight, low latency convolutional neural network that combines MobileNetV2-style layers with a new block that replaces local processing in convolutions with global processing using transformers. As with ViT (Vision Transformer), the image data is converted into flattened patches before it is processed by the transformer layers. Afterwards, the patches are "unflattened" back into feature maps. This allows the MobileViT-block to be placed anywhere inside a CNN. MobileViT does not require any positional embeddings.
The model in this repo adds a [DeepLabV3](https://arxiv.org/abs/1706.05587) head to the MobileViT backbone for semantic segmentation.
## Intended uses & limitations
You can use the raw model for semantic segmentation. See the [model hub](https://huggingface.co/models?search=mobilevit) to look for fine-tuned versions on a task that interests you.
### How to use
Here is how to use this model:
```pythonfrom transformers import MobileViTFeatureExtractor, MobileViTForSemanticSegmentationfrom PIL import Imageimport requests
url = "http://images.cocodataset.org/val2017/000000039769.jpg"image = Image.open(requests.get(url, stream=True).raw)
feature_extractor = MobileViTFeatureExtractor.from_pretrained("apple/deeplabv3-mobilevit-small")model = MobileViTForSemanticSegmentation.from_pretrained("apple/deeplabv3-mobilevit-small")
inputs = feature_extractor(images=image, return_tensors="pt")
outputs = model(**inputs)logits = outputs.logitspredicted_mask = logits.argmax(1).squeeze(0)```
Currently, both the feature extractor and model support PyTorch.
## Training data
The MobileViT + DeepLabV3 model was pretrained on [ImageNet-1k](https://huggingface.co/datasets/imagenet-1k), a dataset consisting of 1 million images and 1,000 classes, and then fine-tuned on the [PASCAL VOC2012](http://host.robots.ox.ac.uk/pascal/VOC/) dataset.
## Training procedure
### Preprocessing
At inference time, images are center-cropped at 512x512. Pixels are normalized to the range [0, 1]. Images are expected to be in BGR pixel order, not RGB.
### Pretraining
The MobileViT networks are trained from scratch for 300 epochs on ImageNet-1k on 8 NVIDIA GPUs with an effective batch size of 1024 and learning rate warmup for 3k steps, followed by cosine annealing. Also used were label smoothing cross-entropy loss and L2 weight decay. Training resolution varies from 160x160 to 320x320, using multi-scale sampling.
To obtain the DeepLabV3 model, MobileViT was fine-tuned on the PASCAL VOC dataset using 4 NVIDIA A100 GPUs.
## Evaluation results
| Model | PASCAL VOC mIOU | # params | URL ||------------------|-----------------|-----------|-----------------------------------------------------------|| MobileViT-XXS | 73.6 | 1.9 M | https://huggingface.co/apple/deeplabv3-mobilevit-xx-small || MobileViT-XS | 77.1 | 2.9 M | https://huggingface.co/apple/deeplabv3-mobilevit-x-small || **MobileViT-S** | **79.1** | **6.4 M** | https://huggingface.co/apple/deeplabv3-mobilevit-small |
### BibTeX entry and citation info
```bibtex@inproceedings{vision-transformer,title = {MobileViT: Light-weight, General-purpose, and Mobile-friendly Vision Transformer},author = {Sachin Mehta and Mohammad Rastegari},year = {2022},URL = {https://arxiv.org/abs/2110.02178}}```12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091{ "architectures": [ "MobileViTForSemanticSegmentation" ], "aspp_dropout_prob": 0.1, "aspp_out_channels": 256, "atrous_rates": [ 6, 12, 18 ], "attention_probs_dropout_prob": 0.0, "classifier_dropout_prob": 0.1, "conv_kernel_size": 3, "expand_ratio": 4.0, "hidden_act": "silu", "hidden_dropout_prob": 0.1, "hidden_sizes": [ 144, 192, 240 ], "id2label": { "0": "background", "1": "aeroplane", "2": "bicycle", "3": "bird", "4": "boat", "5": "bottle", "6": "bus", "7": "car", "8": "cat", "9": "chair", "10": "cow", "11": "diningtable", "12": "dog", "13": "horse", "14": "motorbike", "15": "person", "16": "pottedplant", "17": "sheep", "18": "sofa", "19": "train", "20": "tvmonitor" }, "image_size": 512, "initializer_range": 0.02, "label2id": { "aeroplane": 1, "background": 0, "bicycle": 2, "bird": 3, "boat": 4, "bottle": 5, "bus": 6, "car": 7, "cat": 8, "chair": 9, "cow": 10, "diningtable": 11, "dog": 12, "horse": 13, "motorbike": 14, "person": 15, "pottedplant": 16, "sheep": 17, "sofa": 18, "train": 19, "tvmonitor": 20 }, "layer_norm_eps": 1e-05, "mlp_ratio": 2.0, "model_type": "mobilevit", "neck_hidden_sizes": [ 16, 32, 64, 96, 128, 160, 640 ], "num_attention_heads": 4, "num_channels": 3, "output_stride": 16, "patch_size": 2, "qkv_bias": true, "semantic_loss_ignore_index": 255, "torch_dtype": "float32", "transformers_version": "4.20.0.dev0"}123456789{ "crop_size": 512, "do_center_crop": true, "do_flip_channels": true, "do_resize": true, "feature_extractor_type": "MobileViTFeatureExtractor", "resample": 2, "size": 544}123version https://git-lfs.github.com/spec/v1oid sha256:5e68a534df237d8b89aa9209c815976b4b34f49a4e8107f630fd799697e98291size 25615631123version https://git-lfs.github.com/spec/v1oid sha256:5e14ab532bd4b573c60e4f4c6639de6176db4c35c803cc7c0ba05fdb16e5b3desize 25943848.gitattributes+1-9
.gitignoreAdded+2
MobileViT_DeepLabV3.mlpackage/Data/com.apple.CoreML/model.mlmodelAdded
MobileViT_DeepLabV3.mlpackage/Data/com.apple.CoreML/weights/weight.binAdded+3
MobileViT_DeepLabV3.mlpackage/Manifest.jsonAdded+18
README.mdAdded+86
config.jsonAdded+91
preprocessor_config.jsonAdded+9
pytorch_model.binAdded+3
tf_model.h5Added+3