A03HCY commited on
Commit
3fd3263
·
verified ·
1 Parent(s): 060be7c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +54 -0
README.md CHANGED
@@ -1,3 +1,57 @@
1
  ---
2
  license: mit
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: mit
3
  ---
4
+
5
+ # MobileNetV3 Backbone
6
+
7
+ 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.
8
+
9
+ ## Models
10
+
11
+ | Model | Variant | Output features | Weight file |
12
+ | --- | --- | --- | --- |
13
+ | `MobileNetV3` | small / large (auto) | 1280 | detected from checkpoint |
14
+ | `MobileNetV3_Small` | Small | 1280 | `mobilenetv3_small.safetensors` |
15
+ | `MobileNetV3_Large` | Large | 1280 | `mobilenetv3_large.safetensors` |
16
+
17
+ Input: `(B, 3, H, W)` images. Output: `(B, 1280)` feature vectors (migrated from ImageNet-pretrained weights).
18
+
19
+ ## Weight naming
20
+
21
+ The naming differences between the old and the new code are mapped automatically during migration:
22
+
23
+ | Old name | New name |
24
+ | --- | --- |
25
+ | `bn1/bn2/bn3` | `norm1/norm2/norm3` |
26
+ | `linear3` | `proj` |
27
+ | `Block.se.se.*` | `Block.se.features.*` |
28
+ | `linear4` (classification head) | removed |
29
+
30
+ ## Usage
31
+
32
+ ```python
33
+ from mobile_net import MobileNetV3_Small, MobileNetV3_Large
34
+
35
+ fe = MobileNetV3_Large().load_pretrained('./mobilenetv3_large.safetensors')
36
+ fe.eval()
37
+
38
+ fe.save_pretrained('./backbone.safetensors')
39
+ fe.save_pretrained('./backbone.pth')
40
+
41
+ import torch
42
+ x = torch.randn(2, 3, 224, 224)
43
+ feat = fe(x) # (2, 1280)
44
+ ```
45
+
46
+ ### Auto backend detection
47
+
48
+ `MobileNetV3.from_pretrained` inspects the checkpoint and picks Small / Large automatically:
49
+
50
+ ```python
51
+ from mobile_net import MobileNetV3
52
+
53
+ fe = MobileNetV3.from_pretrained('./mobilenetv3_large.safetensors') # -> Large, weights loaded
54
+ print(fe.backend) # 'large'
55
+ ```
56
+
57
+ Calling it on a pinned class (`MobileNetV3_Large` / `MobileNetV3_Small`) raises if the checkpoint backend disagrees with the class.