Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add MobileNetV3 #38653

Merged
merged 17 commits into from
Mar 9, 2022
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',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里缺少mobilenet_v3_large,是因为mobilenet_v3_large模型太大吗?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嗯嗯,之前是看到 #37307 暂时移除了较大的模型,不过看起来 mobilenet_v3_large (21MB) 相对来说也不算大,刚刚已经加上了~

'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