Skip to content

Commit

Permalink
add MobileNetV3 (#38653)
Browse files Browse the repository at this point in the history
* add mobilenetv3
  • Loading branch information
SigureMo authored Mar 9, 2022
1 parent 767647c commit 68af310
Show file tree
Hide file tree
Showing 8 changed files with 554 additions and 15 deletions.
2 changes: 2 additions & 0 deletions python/paddle/tests/test_pretrained_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ def test_models(self):
arches = [
'mobilenet_v1',
'mobilenet_v2',
'mobilenet_v3_small',
'mobilenet_v3_large',
'squeezenet1_0',
'shufflenet_v2_x0_25',
]
Expand Down
6 changes: 6 additions & 0 deletions python/paddle/tests/test_vision_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ def test_mobilenetv2_pretrained(self):
def test_mobilenetv1(self):
self.models_infer('mobilenet_v1')

def test_mobilenetv3_small(self):
self.models_infer('mobilenet_v3_small')

def test_mobilenetv3_large(self):
self.models_infer('mobilenet_v3_large')

def test_vgg11(self):
self.models_infer('vgg11')

Expand Down
4 changes: 4 additions & 0 deletions python/paddle/vision/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
from .models import mobilenet_v1 # noqa: F401
from .models import MobileNetV2 # noqa: F401
from .models import mobilenet_v2 # noqa: F401
from .models import MobileNetV3Small # noqa: F401
from .models import MobileNetV3Large # noqa: F401
from .models import mobilenet_v3_small # noqa: F401
from .models import mobilenet_v3_large # noqa: F401
from .models import SqueezeNet # noqa: F401
from .models import squeezenet1_0 # noqa: F401
from .models import squeezenet1_1 # noqa: F401
Expand Down
8 changes: 8 additions & 0 deletions python/paddle/vision/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
from .mobilenetv1 import mobilenet_v1 # noqa: F401
from .mobilenetv2 import MobileNetV2 # noqa: F401
from .mobilenetv2 import mobilenet_v2 # noqa: F401
from .mobilenetv3 import MobileNetV3Small # noqa: F401
from .mobilenetv3 import MobileNetV3Large # noqa: F401
from .mobilenetv3 import mobilenet_v3_small # noqa: F401
from .mobilenetv3 import mobilenet_v3_large # noqa: F401
from .vgg import VGG # noqa: F401
from .vgg import vgg11 # noqa: F401
from .vgg import vgg13 # noqa: F401
Expand Down Expand Up @@ -79,6 +83,10 @@
'mobilenet_v1',
'MobileNetV2',
'mobilenet_v2',
'MobileNetV3Small',
'MobileNetV3Large',
'mobilenet_v3_small',
'mobilenet_v3_large',
'LeNet',
'DenseNet',
'densenet121',
Expand Down
16 changes: 2 additions & 14 deletions python/paddle/vision/models/mobilenetv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import numpy as np
import paddle

import paddle.nn as nn
import paddle.nn.functional as F

from paddle.utils.download import get_weights_path_from_url

from .utils import _make_divisible

__all__ = []

model_urls = {
Expand All @@ -29,16 +27,6 @@
}


def _make_divisible(v, divisor, min_value=None):
if min_value is None:
min_value = divisor
new_v = max(min_value, int(v + divisor / 2) // divisor * divisor)

if new_v < 0.9 * v:
new_v += divisor
return new_v


class ConvBNReLU(nn.Sequential):
def __init__(self,
in_planes,
Expand Down
Loading

0 comments on commit 68af310

Please sign in to comment.