Home

Awesome

A PyTorch implementation of MobileNetV3

This is a PyTorch implementation of MobileNetV3 architecture as described in the paper Searching for MobileNetV3.

Some details may be different from the original paper, welcome to discuss and help me figure it out.

Training & Accuracy

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
  5. batch size: 256

MobileNetV3 large

MaddsParametersTop1-accPretrained Model
Offical 1.0219 M5.4 M75.2%-
Offical 0.75155 M4 M73.3%-
Ours 1.0224 M5.48 M72.8%-
Ours 0.75148 M3.91 M--

MobileNetV3 small

MaddsParametersTop1-accPretrained Model
Offical 1.066 M2.9 M67.4%-
Offical 0.7544 M2.4 M65.4%-
Ours 1.063 M2.94 M67.4%[google drive]
Ours 0.7546 M2.38 M--

Usage

Pretrained models are still training ...

    # pytorch 1.0.1
    # large
    net_large = mobilenetv3(mode='large')
    # small
    net_small = mobilenetv3(mode='small')
    state_dict = torch.load('mobilenetv3_small_67.4.pth.tar')
    net_small.load_state_dict(state_dict)

Data Pre-processing

I used the following code for data pre-processing on ImageNet:

normalize = transforms.Normalize(mean=[0.485, 0.456, 0.406],
                                 std=[0.229, 0.224, 0.225])

input_size = 224
train_loader = torch.utils.data.DataLoader(
    datasets.ImageFolder(
    traindir, transforms.Compose([
        transforms.RandomResizedCrop(input_size),
        transforms.RandomHorizontalFlip(),
        transforms.ToTensor(),
        normalize,
    ])),
    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)