Views
No views yet
MobileNets are small, low-latency, low-power models parameterized to meet the resource constraints of a variety of use cases. They can be built upon for classification, detection, embeddings and segmentation similar to how other popular large scale models, such as Inception, are used. MobileNets can be run efficiently on mobile devices [...] MobileNets trade off between latency, size and accuracy while comparing favorably with popular models from the literature.
1from transformers import MobileNetV2FeatureExtractor, MobileNetV2ForSemanticSegmentation
2from PIL import Image
3import requests
4
5url = "http://images.cocodataset.org/val2017/000000039769.jpg"
6image = Image.open(requests.get(url, stream=True).raw)
7
8feature_extractor = MobileNetV2FeatureExtractor.from_pretrained("Matthijs/deeplabv3_mobilenet_v2_1.0_513")
9model = MobileNetV2ForSemanticSegmentation.from_pretrained("Matthijs/deeplabv3_mobilenet_v2_1.0_513")
10
11inputs = feature_extractor(images=image, return_tensors="pt")
12
13outputs = model(**inputs)
14logits = outputs.logits
15predicted_mask = logits.argmax(1).squeeze(0)1@inproceedings{deeplabv3plus2018,
2 title={Encoder-Decoder with Atrous Separable Convolution for Semantic Image Segmentation},
3 author={Liang-Chieh Chen and Yukun Zhu and George Papandreou and Florian Schroff and Hartwig Adam},
4 booktitle={ECCV},
5 year={2018}
6}