https://github.com/alexcoca/pytorch-mobilenet-v2
A PyTorch implementation of MobileNet V2 architecture and pretrained model.
Science Score: 10.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
○codemeta.json file
-
○.zenodo.json file
-
○DOI references
-
✓Academic publication links
Links to: arxiv.org -
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (7.5%) to scientific vocabulary
Last synced: 10 months ago
·
JSON representation
Repository
A PyTorch implementation of MobileNet V2 architecture and pretrained model.
Basic Info
Statistics
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
- Releases: 0
Fork of tonylins/pytorch-mobilenet-v2
Created about 7 years ago
· Last pushed about 7 years ago
https://github.com/alexcoca/pytorch-mobilenet-v2/blob/master/
# A PyTorch implementation of MobileNetV2
This is a PyTorch implementation of MobileNetV2 architecture as described in the paper [Inverted Residuals and Linear Bottlenecks: Mobile Networks for Classification, Detection and Segmentation](https://arxiv.org/pdf/1801.04381).
**[NEW]** I fixed a difference in implementation compared to the official TensorFlow model. Please use the new model file and checkpoint!
## Training Recipe
Recently I have figured out a good training setting:
1. number of epochs: 150
2. learning rate schedule: cosine learning rate, initial lr=0.05
3. weight decay: 4e-5
4. remove dropout
You should get >72% top-1 accuracy with this training recipe!
## Accuracy & Statistics
Here is a comparison of statistics against the official TensorFlow [implementation](https://github.com/tensorflow/models/tree/master/research/slim/nets/mobilenet).
| | FLOPs | Parameters | Top1-acc | Pretrained Model |
| ----------- | --------- | ---------- | --------- | ------------------------------------------------------------ |
| Official TF | 300 M | 3.47 M | 71.8% | - |
| Ours | 300.775 M | 3.471 M | **71.8%** | [[google drive](https://drive.google.com/open?id=1jlto6HRVD3ipNkAl1lNhDbkBp7HylaqR)] |
## Usage
To use the pretrained model, run
```python
from MobileNetV2 import MobileNetV2
net = MobileNetV2(n_class=1000)
state_dict = torch.load('mobilenetv2.pth.tar') # add map_location='cpu' if no gpu
net.load_state_dict(state_dict)
```
## Data Pre-processing
I used the following code for data pre-processing on ImageNet:
```python
normalize = transforms.Normalize(mean=[0.485, 0.456, 0.406],
std=[0.229, 0.224, 0.225])
input_size = 224
train_dataset = datasets.ImageFolder(
traindir,
transforms.Compose([
transforms.RandomResizedCrop(input_size, scale=(0.2, 1.0)),
transforms.RandomHorizontalFlip(),
transforms.ToTensor(),
normalize,
]))
train_loader = torch.utils.data.DataLoader(
train_dataset, batch_size=batch_size, shuffle=True,
num_workers=n_worker, pin_memory=True)
val_loader = torch.utils.data.DataLoader(
datasets.ImageFolder(valdir, transforms.Compose([
transforms.Resize(int(input_size/0.875)),
transforms.CenterCrop(input_size),
transforms.ToTensor(),
normalize,
])),
batch_size=batch_size, shuffle=False,
num_workers=n_worker, pin_memory=True)
```
Owner
- Name: Alexandru Coca
- Login: alexcoca
- Kind: user
- Location: Cambridge
- Company: University of Cambridge
- Repositories: 3
- Profile: https://github.com/alexcoca
Student at the University of Cambridge