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

[PaddlePaddle Hackathon] add ShuffleNetV2 #36313

Closed
wants to merge 17 commits into from
5 changes: 4 additions & 1 deletion python/paddle/tests/test_pretrained_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ def infer(self, arch):
np.testing.assert_allclose(res['dygraph'], res['static'])

def test_models(self):
arches = ['mobilenet_v1', 'mobilenet_v2', 'resnet18', 'vgg16']
arches = [
'mobilenet_v1', 'mobilenet_v2', 'resnet18', 'vgg16',
'shufflenetv2_swish'
]
for arch in arches:
self.infer(arch)

Expand Down
23 changes: 22 additions & 1 deletion python/paddle/tests/test_vision_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,27 @@ def test_resnet101(self):

def test_resnet152(self):
self.models_infer('resnet152')

def test_shufflenetv2_x0_25(self):
self.models_infer('shufflenetv2_x0_25')

def test_shufflenetv2_x0_33(self):
self.models_infer('shufflenetv2_x0_33')

def test_shufflenetv2_x0_5(self):
self.models_infer('shufflenetv2_x0_5')

def test_shufflenetv2_x1_0(self):
self.models_infer('shufflenetv2_x1_0')

def test_shufflenetv2_x1_5(self):
self.models_infer('shufflenetv2_x1_5')

def test_shufflenetv2_x2_0(self):
self.models_infer('shufflenetv2_x2_0')

def test_shufflenetv2_swish(self):
self.models_infer('shufflenetv2_swish')

def test_vgg16_num_classes(self):
vgg16 = models.__dict__['vgg16'](pretrained=False, num_classes=10)
Expand All @@ -81,7 +102,7 @@ def test_lenet(self):

x = np.array(np.random.random((2, 1, 28, 28)), dtype=np.float32)
lenet.predict_batch(x)


if __name__ == '__main__':
unittest.main()
8 changes: 8 additions & 0 deletions python/paddle/vision/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@
from .models import vgg16 # noqa: F401
from .models import vgg19 # noqa: F401
from .models import LeNet # noqa: F401
from .models import ShuffleNetV2 # noqa: F401
from .models import shufflenetv2_x0_25 # noqa: F401
from .models import shufflenetv2_x0_33 # noqa: F401
from .models import shufflenetv2_x0_5 # noqa: F401
from .models import shufflenetv2_x1_0 # noqa: F401
from .models import shufflenetv2_x1_5 # noqa: F401
from .models import shufflenetv2_x2_0 # noqa: F401
from .models import shufflenetv2_swish # noqa: F401
from .transforms import BaseTransform # noqa: F401
from .transforms import Compose # noqa: F401
from .transforms import Resize # noqa: F401
Expand Down
19 changes: 18 additions & 1 deletion python/paddle/vision/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@
from .vgg import vgg16 # noqa: F401
from .vgg import vgg19 # noqa: F401
from .lenet import LeNet # noqa: F401
from .shufflenetv2 import ShuffleNetV2 # noqa: F401
from .shufflenetv2 import shufflenetv2_x0_25 # noqa: F401
from .shufflenetv2 import shufflenetv2_x0_33 # noqa: F401
from .shufflenetv2 import shufflenetv2_x0_5 # noqa: F401
from .shufflenetv2 import shufflenetv2_x1_0 # noqa: F401
from .shufflenetv2 import shufflenetv2_x1_5 # noqa: F401
from .shufflenetv2 import shufflenetv2_x2_0 # noqa: F401
from .shufflenetv2 import shufflenetv2_swish # noqa: F401


__all__ = [ #noqa
'ResNet',
Expand All @@ -45,5 +54,13 @@
'mobilenet_v1',
'MobileNetV2',
'mobilenet_v2',
'LeNet'
'LeNet',
'ShuffleNetV2',
'shufflenetv2_x0_25',
'shufflenetv2_x0_33',
'shufflenetv2_x0_5',
'shufflenetv2_x1_0',
'shufflenetv2_x1_5',
'shufflenetv2_x2_0',
'shufflenetv2_swish'
]
Loading