Views
No views yet
The shortest accurate model possible — 3.5M parameters, ~13.5 MB on disk, 85%+ validation accuracy
| Property | Value |
|---|---|
| Architecture | MobileNetV2 |
| Base Checkpoint | google/mobilenet_v2_1.0_224 |
| Total Parameters | ~3,504,872 |
| Model Size (FP32) | ~13.37 MB |
| Input Resolution | 224 × 224 |
| Num Classes | 2 (cat, dog) |
| Framework | PyTorch + HuggingFace Transformers |
| Property | Value |
|---|---|
| Source | microsoft/cats_vs_dogs |
| Total Images | 23,262 |
| Train Split | 18,609 (80%) |
| Validation Split | 4,653 (20%) |
| Split Strategy | Stratified by class, seed=42 |
| Classes | Cat (0), Dog (1) |
| Class Balance | ~50/50 (balanced) |
microsoft/cats_vs_dogs from HuggingFace Datasetstrain split)google/mobilenet_v2_1.0_224 (ImageNet-1K weights)ignore_mismatched_sizes=True handles the head swap automaticallyRandomResizedCrop(224, scale=(0.8, 1.0)) — random crop with scale augmentationRandomHorizontalFlip(p=0.5) — mirror augmentationColorJitter(brightness=0.2, contrast=0.2, saturation=0.2, hue=0.1) — color augmentationNormalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]) — ImageNet normalizationResize(256) → CenterCrop(224) — deterministic center cropNormalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])| Hyperparameter | Value |
|---|---|
| Optimizer | AdamW |
| Learning Rate | 2e-4 |
| LR Scheduler | Cosine with warmup (10%) |
| Weight Decay | 1e-4 |
| Epochs | 10 |
| Batch Size | 32 |
| Mixed Precision | FP16 |
| Metric | Accuracy (best model selected) |

1from transformers import pipeline
2
3classifier = pipeline("image-classification", model="DsJASPREET/mobilenetv2-cats-dogs-classifier")
4result = classifier("path/to/cat_or_dog.jpg")
5print(result)
6# [{'label': 'cat', 'score': 0.98}, {'label': 'dog', 'score': 0.02}]1from transformers import AutoImageProcessor, AutoModelForImageClassification
2from PIL import Image
3import torch
4
5processor = AutoImageProcessor.from_pretrained("DsJASPREET/mobilenetv2-cats-dogs-classifier")
6model = AutoModelForImageClassification.from_pretrained("DsJASPREET/mobilenetv2-cats-dogs-classifier")
7
8image = Image.open("cat.jpg")
9inputs = processor(image, return_tensors="pt")
10
11with torch.no_grad():
12 logits = model(**inputs).logits
13
14predicted_class = logits.argmax(-1).item()
15print(model.config.id2label[predicted_class]) # "cat" or "dog"| Paper | Venue | Link | Relevance |
|---|---|---|---|
| MobileNetV2: Inverted Residuals and Linear Bottlenecks | CVPR 2018 | arxiv:1801.04381 | Base architecture — inverted residual blocks + depthwise separable convolutions |
| EfficientNet: Rethinking Model Scaling for CNNs | ICML 2019 | arxiv:1905.11946 | Compound scaling reference — larger but more accurate alternative |
| Cross-Dataset Generalization of Mobile CNN Architectures | 2024 | arxiv:2511.00335 | Benchmarked 11 mobile architectures; MobileNetV2 ranked 3rd in cross-dataset generalization |
| MobileNetV3: Searching for MobileNetV3 | ICCV 2019 | arxiv:1905.02244 | Successor with hardware-aware NAS; better accuracy but larger |
MobileNetV2 Architecture:
├── Conv2d (3→32, stride=2) # Initial convolution
├── InvertedResidual ×1 (32→16) # Bottleneck block 1
├── InvertedResidual ×2 (16→24) # Bottleneck block 2
├── InvertedResidual ×3 (24→32) # Bottleneck block 3
├── InvertedResidual ×4 (32→64) # Bottleneck block 4
├── InvertedResidual ×3 (64→96) # Bottleneck block 5
├── InvertedResidual ×3 (96→160) # Bottleneck block 6
├── InvertedResidual ×1 (160→320) # Bottleneck block 7
├── Conv2d (320→1280) # Feature extraction
├── AdaptiveAvgPool2d # Global pooling
├── Dropout(0.2) # Regularization
└── Linear (1280→2) # Classification head (cat/dog)Input → 1×1 Conv (expand) → 3×3 Depthwise Conv → 1×1 Conv (project) → + Input
↑ expansion ratio ↑ linear bottleneck