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 AutoImageProcessor, AutoModelForImageClassification
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
8preprocessor = AutoImageProcessor.from_pretrained("google/mobilenet_v2_0.35_96")
9model = AutoModelForImageClassification.from_pretrained("google/mobilenet_v2_0.35_96")
10
11inputs = preprocessor(images=image, return_tensors="pt")
12
13outputs = model(**inputs)
14logits = outputs.logits
15
16# model predicts one of the 1000 ImageNet classes
17predicted_class_idx = logits.argmax(-1).item()
18print("Predicted class:", model.config.id2label[predicted_class_idx])1@inproceedings{mobilenetv22018,
2 title={MobileNetV2: Inverted Residuals and Linear Bottlenecks},
3 author={Mark Sandler and Andrew Howard and Menglong Zhu and Andrey Zhmoginov and Liang-Chieh Chen},
4 booktitle={CVPR},
5 year={2018}
6}