Searching for MobileNetV3
Paper • 1905.02244 • Published
A feature extractor based on MobileNetV3, refactored from https://github.com/xiaolai-sqlai/mobilenetv3: backbone only — the classification head is removed, with unified naming.
| Model | Variant | Output features | Weight file |
|---|---|---|---|
MobileNetV3 |
small / large (auto) | 1280 | detected from checkpoint |
MobileNetV3_Small |
Small | 1280 | mobilenetv3_small.safetensors |
MobileNetV3_Large |
Large | 1280 | mobilenetv3_large.safetensors |
Input: (B, 3, H, W) images. Output: (B, 1280) feature vectors (migrated from ImageNet-pretrained weights).
The naming differences between the old and the new code are mapped automatically during migration:
| Old name | New name |
|---|---|
bn1/bn2/bn3 |
norm1/norm2/norm3 |
linear3 |
proj |
Block.se.se.* |
Block.se.features.* |
linear4 (classification head) |
removed |
from mobile_net import MobileNetV3_Small, MobileNetV3_Large
fe = MobileNetV3_Large().load_pretrained('./mobilenetv3_large.safetensors')
fe.eval()
fe.save_pretrained('./backbone.safetensors')
fe.save_pretrained('./backbone.pth')
import torch
x = torch.randn(2, 3, 224, 224)
feat = fe(x) # (2, 1280)
MobileNetV3.from_pretrained inspects the checkpoint and picks Small / Large automatically:
from mobile_net import MobileNetV3
fe = MobileNetV3.from_pretrained('./mobilenetv3_large.safetensors') # -> Large, weights loaded
print(fe.backend) # 'large'
Calling it on a pinned class (MobileNetV3_Large / MobileNetV3_Small) raises if the checkpoint backend disagrees with the class.