|
Download README.md from CodonProject/MobileNetv3: direct link, hf CLI and curl.
- Browser
- Download file 1.76 kB
-
https://huggingface.co/CodonProject/MobileNetv3/resolve/main/README.md
- Command line
-
hf download hf://CodonProject/MobileNetv3/README.md
-
curl -L -o README.md https://huggingface.co/CodonProject/MobileNetv3/resolve/main/README.md
1.76 kB
| license: mit | |
| # MobileNetV3 Backbone | |
| A feature extractor based on [MobileNetV3](https://arxiv.org/abs/1905.02244), refactored from https://github.com/xiaolai-sqlai/mobilenetv3: **backbone only — the classification head is removed**, with unified naming. | |
| ## Models | |
| | 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). | |
| ## Weight naming | |
| 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 | | |
| ## Usage | |
| ```python | |
| 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) | |
| ``` | |
| ### Auto backend detection | |
| `MobileNetV3.from_pretrained` inspects the checkpoint and picks Small / Large automatically: | |
| ```python | |
| 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. | |