hubconf.py 23.4 KB
Newer Older
L
lyuwenyu 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

L
for hub  
lyuwenyu 已提交
15

L
lyuwenyu 已提交
16
dependencies = ['paddle', 'numpy']
L
for hub  
lyuwenyu 已提交
17

L
lyuwenyu 已提交
18
import paddle
L
for hub  
lyuwenyu 已提交
19

L
lyuwenyu 已提交
20 21
from ppcls.modeling.architectures import alexnet as _alexnet
from ppcls.modeling.architectures import vgg as _vgg 
L
lyuwenyu 已提交
22
from ppcls.modeling.architectures import resnet as _resnet 
L
lyuwenyu 已提交
23 24 25 26
from ppcls.modeling.architectures import squeezenet as _squeezenet
from ppcls.modeling.architectures import densenet as _densenet
from ppcls.modeling.architectures import inception_v3 as _inception_v3
from ppcls.modeling.architectures import inception_v4 as _inception_v4
L
lyuwenyu 已提交
27 28 29 30 31 32 33
from ppcls.modeling.architectures import googlenet as _googlenet
from ppcls.modeling.architectures import shufflenet_v2 as _shufflenet_v2
from ppcls.modeling.architectures import mobilenet_v1 as _mobilenet_v1
from ppcls.modeling.architectures import mobilenet_v2 as _mobilenet_v2
from ppcls.modeling.architectures import mobilenet_v3 as _mobilenet_v3
from ppcls.modeling.architectures import resnext as _resnext

L
lyuwenyu 已提交
34

L
lyuwenyu 已提交
35 36 37 38
# _checkpoints = {
#     'ResNet18': 'https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNet18_pretrained.pdparams',
#     'ResNet34': 'https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNet34_pretrained.pdparams',
# }
L
lyuwenyu 已提交
39

L
lyuwenyu 已提交
40

L
lyuwenyu 已提交
41 42 43 44
def _load_pretrained_urls():
    '''Load pretrained model parameters url from README.md
    '''
    import re
L
lyuwenyu 已提交
45
    import os
L
lyuwenyu 已提交
46 47
    from collections import OrderedDict

L
lyuwenyu 已提交
48 49 50
    readme_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'README.md')

    with open(readme_path, 'r') as f:
L
lyuwenyu 已提交
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
        lines = f.readlines()
        lines = [lin for lin in lines if lin.strip().startswith('|') and 'Download link' in lin]
    
    urls = OrderedDict()
    for lin in lines:
        try:
            name = re.findall(r'\|(.*?)\|', lin)[0].strip().replace('<br>', '')
            url = re.findall(r'\((.*?)\)', lin)[-1].strip()
            if name in url:
                urls[name] = url
        except:
            pass

    return urls


_checkpoints = _load_pretrained_urls()
L
lyuwenyu 已提交
68

L
lyuwenyu 已提交
69

L
lyuwenyu 已提交
70 71 72 73 74 75
def _load_pretrained_parameters(model, name):
    assert name in _checkpoints, 'Not provide {} pretrained model.'.format(name)
    path = paddle.utils.download.get_weights_path_from_url(_checkpoints[name])
    model.set_state_dict(paddle.load(path))
    return model
    
L
lyuwenyu 已提交
76

L
lyuwenyu 已提交
77
def AlexNet(pretrained=False, **kwargs):
L
lyuwenyu 已提交
78 79
    '''AlexNet
    '''
L
lyuwenyu 已提交
80
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
81 82 83 84 85 86 87 88 89 90 91

    model = _alexnet.AlexNet(**kwargs)
    if pretrained:
        assert 'AlexNet' in _checkpoints, 'Not provide `AlexNet` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['AlexNet'])
        model.set_state_dict(paddle.load(path))

    return model



L
lyuwenyu 已提交
92
def VGG11(pretrained=False, **kwargs):
L
lyuwenyu 已提交
93 94
    '''VGG11
    '''
L
lyuwenyu 已提交
95
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
96 97 98 99 100 101 102 103 104 105

    model = _vgg.VGG11(**kwargs)
    if pretrained:
        assert 'VGG11' in _checkpoints, 'Not provide `VGG11` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['VGG11'])
        model.set_state_dict(paddle.load(path))

    return model


L
lyuwenyu 已提交
106
def VGG13(pretrained=False, **kwargs):
L
lyuwenyu 已提交
107 108
    '''VGG13
    '''
L
lyuwenyu 已提交
109
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
110 111 112 113 114 115 116 117 118 119

    model = _vgg.VGG13(**kwargs)
    if pretrained:
        assert 'VGG13' in _checkpoints, 'Not provide `VGG13` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['VGG13'])
        model.set_state_dict(paddle.load(path))

    return model


L
lyuwenyu 已提交
120
def VGG16(pretrained=False, **kwargs):
L
lyuwenyu 已提交
121 122
    '''VGG16
    '''
L
lyuwenyu 已提交
123
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
124 125 126 127 128 129 130 131 132 133

    model = _vgg.VGG16(**kwargs)
    if pretrained:
        assert 'VGG16' in _checkpoints, 'Not provide `VGG16` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['VGG16'])
        model.set_state_dict(paddle.load(path))

    return model


L
lyuwenyu 已提交
134
def VGG19(pretrained=False, **kwargs):
L
lyuwenyu 已提交
135 136
    '''VGG19
    '''
L
lyuwenyu 已提交
137
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
138 139 140 141 142 143 144 145 146 147 148 149

    model = _vgg.VGG19(**kwargs)
    if pretrained:
        assert 'VGG19' in _checkpoints, 'Not provide `VGG19` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['VGG19'])
        model.set_state_dict(paddle.load(path))

    return model




L
lyuwenyu 已提交
150
def ResNet18(pretrained=False, **kwargs):
L
lyuwenyu 已提交
151
    '''ResNet18
L
for hub  
lyuwenyu 已提交
152
    '''
L
lyuwenyu 已提交
153
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
154

L
lyuwenyu 已提交
155
    model = _resnet.ResNet18(**kwargs)
L
lyuwenyu 已提交
156
    if pretrained:
L
lyuwenyu 已提交
157
        assert 'ResNet18' in _checkpoints, 'Not provide `ResNet18` pretrained model.'
L
lyuwenyu 已提交
158 159 160
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['ResNet18'])
        model.set_state_dict(paddle.load(path))

L
for hub  
lyuwenyu 已提交
161 162
    return model

L
lyuwenyu 已提交
163

L
lyuwenyu 已提交
164
def ResNet34(pretrained=False, **kwargs):
L
lyuwenyu 已提交
165 166
    '''ResNet34
    '''
L
lyuwenyu 已提交
167
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
168 169 170 171 172 173

    model = _resnet.ResNet34(**kwargs)
    if pretrained:
        assert 'ResNet34' in _checkpoints, 'Not provide `ResNet34` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['ResNet34'])
        model.set_state_dict(paddle.load(path))
L
lyuwenyu 已提交
174

L
lyuwenyu 已提交
175
    return model
L
lyuwenyu 已提交
176 177


L
lyuwenyu 已提交
178
def ResNet50(pretrained=False, **kwargs):
L
lyuwenyu 已提交
179 180
    '''ResNet50
    '''
L
lyuwenyu 已提交
181
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
182 183 184 185 186 187 188 189 190 191

    model = _resnet.ResNet50(**kwargs)
    if pretrained:
        assert 'ResNet50' in _checkpoints, 'Not provide `ResNet50` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['ResNet50'])
        model.set_state_dict(paddle.load(path))

    return model


L
lyuwenyu 已提交
192
def ResNet101(pretrained=False, **kwargs):
L
lyuwenyu 已提交
193 194
    '''ResNet101
    '''
L
lyuwenyu 已提交
195
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
196 197 198 199 200 201 202 203 204 205

    model = _resnet.ResNet101(**kwargs)
    if pretrained:
        assert 'ResNet101' in _checkpoints, 'Not provide `ResNet101` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['ResNet101'])
        model.set_state_dict(paddle.load(path))

    return model


L
lyuwenyu 已提交
206
def ResNet152(pretrained=False, **kwargs):
L
lyuwenyu 已提交
207 208
    '''ResNet152
    '''
L
lyuwenyu 已提交
209
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
210 211 212 213 214 215 216 217

    model = _resnet.ResNet152(**kwargs)
    if pretrained:
        assert 'ResNet152' in _checkpoints, 'Not provide `ResNet152` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['ResNet152'])
        model.set_state_dict(paddle.load(path))

    return model
L
lyuwenyu 已提交
218 219 220



L
lyuwenyu 已提交
221
def SqueezeNet1_0(pretrained=False, **kwargs):
L
lyuwenyu 已提交
222 223
    '''SqueezeNet1_0
    '''
L
lyuwenyu 已提交
224
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
225 226 227 228 229 230 231 232 233 234

    model = _squeezenet.SqueezeNet1_0(**kwargs)
    if pretrained:
        assert 'SqueezeNet1_0' in _checkpoints, 'Not provide `SqueezeNet1_0` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['SqueezeNet1_0'])
        model.set_state_dict(paddle.load(path))

    return model


L
lyuwenyu 已提交
235
def SqueezeNet1_1(pretrained=False, **kwargs):
L
lyuwenyu 已提交
236 237
    '''SqueezeNet1_1
    '''
L
lyuwenyu 已提交
238
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
239 240 241 242 243 244 245 246 247 248

    model = _squeezenet.SqueezeNet1_1(**kwargs)
    if pretrained:
        assert 'SqueezeNet1_1' in _checkpoints, 'Not provide `SqueezeNet1_1` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['SqueezeNet1_1'])
        model.set_state_dict(paddle.load(path))

    return model


L
lyuwenyu 已提交
249 250


L
lyuwenyu 已提交
251
def DenseNet121(pretrained=False, **kwargs):
L
lyuwenyu 已提交
252 253
    '''DenseNet121
    '''
L
lyuwenyu 已提交
254
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
255 256 257 258 259 260 261 262 263 264

    model = _densenet.DenseNet121(**kwargs)
    if pretrained:
        assert 'DenseNet121' in _checkpoints, 'Not provide `DenseNet121` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['DenseNet121'])
        model.set_state_dict(paddle.load(path))

    return model


L
lyuwenyu 已提交
265
def DenseNet161(pretrained=False, **kwargs):
L
lyuwenyu 已提交
266 267
    '''DenseNet161
    '''
L
lyuwenyu 已提交
268
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
269 270 271 272 273 274 275 276 277 278

    model = _densenet.DenseNet161(**kwargs)
    if pretrained:
        assert 'DenseNet161' in _checkpoints, 'Not provide `DenseNet161` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['DenseNet161'])
        model.set_state_dict(paddle.load(path))

    return model


L
lyuwenyu 已提交
279
def DenseNet169(pretrained=False, **kwargs):
L
lyuwenyu 已提交
280 281
    '''DenseNet169
    '''
L
lyuwenyu 已提交
282
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
283 284 285 286 287 288 289 290 291 292

    model = _densenet.DenseNet169(**kwargs)
    if pretrained:
        assert 'DenseNet169' in _checkpoints, 'Not provide `DenseNet169` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['DenseNet169'])
        model.set_state_dict(paddle.load(path))

    return model


L
lyuwenyu 已提交
293
def DenseNet201(pretrained=False, **kwargs):
L
lyuwenyu 已提交
294 295
    '''DenseNet201
    '''
L
lyuwenyu 已提交
296
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
297 298 299 300 301 302 303 304 305 306

    model = _densenet.DenseNet201(**kwargs)
    if pretrained:
        assert 'DenseNet201' in _checkpoints, 'Not provide `DenseNet201` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['DenseNet201'])
        model.set_state_dict(paddle.load(path))

    return model


L
lyuwenyu 已提交
307
def DenseNet264(pretrained=False, **kwargs):
L
lyuwenyu 已提交
308 309
    '''DenseNet264
    '''
L
lyuwenyu 已提交
310
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
311 312 313 314 315 316 317 318 319 320

    model = _densenet.DenseNet264(**kwargs)
    if pretrained:
        assert 'DenseNet264' in _checkpoints, 'Not provide `DenseNet264` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['DenseNet264'])
        model.set_state_dict(paddle.load(path))

    return model


L
lyuwenyu 已提交
321

L
lyuwenyu 已提交
322
def InceptionV3(pretrained=False, **kwargs):
L
lyuwenyu 已提交
323 324
    '''InceptionV3
    '''
L
lyuwenyu 已提交
325
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
326 327 328 329 330 331 332 333 334 335

    model = _inception_v3.InceptionV3(**kwargs)
    if pretrained:
        assert 'InceptionV3' in _checkpoints, 'Not provide `InceptionV3` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['InceptionV3'])
        model.set_state_dict(paddle.load(path))

    return model


L
lyuwenyu 已提交
336
def InceptionV4(pretrained=False, **kwargs):
L
lyuwenyu 已提交
337 338
    '''InceptionV4
    '''
L
lyuwenyu 已提交
339
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
340 341 342 343 344 345 346

    model = _inception_v4.InceptionV4(**kwargs)
    if pretrained:
        assert 'InceptionV4' in _checkpoints, 'Not provide `InceptionV4` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['InceptionV4'])
        model.set_state_dict(paddle.load(path))

L
lyuwenyu 已提交
347 348 349 350
    return model



L
lyuwenyu 已提交
351
def GoogLeNet(pretrained=False, **kwargs):
L
lyuwenyu 已提交
352 353
    '''GoogLeNet
    '''
L
lyuwenyu 已提交
354
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
355 356 357 358 359 360 361 362 363 364 365

    model = _googlenet.GoogLeNet(**kwargs)
    if pretrained:
        assert 'GoogLeNet' in _checkpoints, 'Not provide `GoogLeNet` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['GoogLeNet'])
        model.set_state_dict(paddle.load(path))

    return model



L
lyuwenyu 已提交
366
def ShuffleNet(pretrained=False, **kwargs):
L
lyuwenyu 已提交
367 368
    '''ShuffleNet
    '''
L
lyuwenyu 已提交
369
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
370 371 372 373 374 375 376 377 378 379 380

    model = _shufflenet_v2.ShuffleNet(**kwargs)
    if pretrained:
        assert 'ShuffleNet' in _checkpoints, 'Not provide `ShuffleNet` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['ShuffleNet'])
        model.set_state_dict(paddle.load(path))

    return model



L
lyuwenyu 已提交
381
def MobileNetV1(pretrained=False, **kwargs):
L
lyuwenyu 已提交
382 383
    '''MobileNetV1
    '''
L
lyuwenyu 已提交
384
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
385 386 387 388 389 390 391 392 393 394

    model = _mobilenet_v1.MobileNetV1(**kwargs)
    if pretrained:
        assert 'MobileNetV1' in _checkpoints, 'Not provide `MobileNetV1` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['MobileNetV1'])
        model.set_state_dict(paddle.load(path))

    return model


L
lyuwenyu 已提交
395
def MobileNetV1_x0_25(pretrained=False, **kwargs):
L
lyuwenyu 已提交
396 397
    '''MobileNetV1_x0_25
    '''
L
lyuwenyu 已提交
398
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
399 400 401 402 403 404 405 406 407 408

    model = _mobilenet_v1.MobileNetV1_x0_25(**kwargs)
    if pretrained:
        assert 'MobileNetV1_x0_25' in _checkpoints, 'Not provide `MobileNetV1_x0_25` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['MobileNetV1_x0_25'])
        model.set_state_dict(paddle.load(path))

    return model


L
lyuwenyu 已提交
409
def MobileNetV1_x0_5(pretrained=False, **kwargs):
L
lyuwenyu 已提交
410 411
    '''MobileNetV1_x0_5
    '''
L
lyuwenyu 已提交
412
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
413 414 415 416 417 418 419 420 421 422

    model = _mobilenet_v1.MobileNetV1_x0_5(**kwargs)
    if pretrained:
        assert 'MobileNetV1_x0_5' in _checkpoints, 'Not provide `MobileNetV1_x0_5` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['MobileNetV1_x0_5'])
        model.set_state_dict(paddle.load(path))

    return model


L
lyuwenyu 已提交
423
def MobileNetV1_x0_75(pretrained=False, **kwargs):
L
lyuwenyu 已提交
424 425
    '''MobileNetV1_x0_75
    '''
L
lyuwenyu 已提交
426
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
427 428 429 430 431 432 433 434 435 436

    model = _mobilenet_v1.MobileNetV1_x0_75(**kwargs)
    if pretrained:
        assert 'MobileNetV1_x0_75' in _checkpoints, 'Not provide `MobileNetV1_x0_75` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['MobileNetV1_x0_75'])
        model.set_state_dict(paddle.load(path))

    return model


L
lyuwenyu 已提交
437
def MobileNetV2_x0_25(pretrained=False, **kwargs):
L
lyuwenyu 已提交
438 439
    '''MobileNetV2_x0_25
    '''
L
lyuwenyu 已提交
440
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
441 442 443 444 445 446 447 448 449 450

    model = _mobilenet_v2.MobileNetV2_x0_25(**kwargs)
    if pretrained:
        assert 'MobileNetV2_x0_25' in _checkpoints, 'Not provide `MobileNetV2_x0_25` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['MobileNetV2_x0_25'])
        model.set_state_dict(paddle.load(path))

    return model


L
lyuwenyu 已提交
451
def MobileNetV2_x0_5(pretrained=False, **kwargs):
L
lyuwenyu 已提交
452 453
    '''MobileNetV2_x0_5
    '''
L
lyuwenyu 已提交
454
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
455 456 457 458 459 460 461 462 463 464

    model = _mobilenet_v2.MobileNetV2_x0_5(**kwargs)
    if pretrained:
        assert 'MobileNetV2_x0_5' in _checkpoints, 'Not provide `MobileNetV2_x0_5` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['MobileNetV2_x0_5'])
        model.set_state_dict(paddle.load(path))

    return model


L
lyuwenyu 已提交
465
def MobileNetV2_x0_75(pretrained=False, **kwargs):
L
lyuwenyu 已提交
466 467
    '''MobileNetV2_x0_75
    '''
L
lyuwenyu 已提交
468
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
469 470 471 472 473 474 475 476 477 478

    model = _mobilenet_v2.MobileNetV2_x0_75(**kwargs)
    if pretrained:
        assert 'MobileNetV2_x0_75' in _checkpoints, 'Not provide `MobileNetV2_x0_75` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['MobileNetV2_x0_75'])
        model.set_state_dict(paddle.load(path))

    return model


L
lyuwenyu 已提交
479
def MobileNetV2_x1_5(pretrained=False, **kwargs):
L
lyuwenyu 已提交
480 481
    '''MobileNetV2_x1_5
    '''
L
lyuwenyu 已提交
482
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
483 484 485 486 487 488 489 490 491 492

    model = _mobilenet_v2.MobileNetV2_x1_5(**kwargs)
    if pretrained:
        assert 'MobileNetV2_x1_5' in _checkpoints, 'Not provide `MobileNetV2_x1_5` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['MobileNetV2_x1_5'])
        model.set_state_dict(paddle.load(path))

    return model


L
lyuwenyu 已提交
493
def MobileNetV2_x2_0(pretrained=False, **kwargs):
L
lyuwenyu 已提交
494 495
    '''MobileNetV2_x2_0
    '''
L
lyuwenyu 已提交
496
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
497 498 499 500 501 502 503 504 505 506

    model = _mobilenet_v2.MobileNetV2_x2_0(**kwargs)
    if pretrained:
        assert 'MobileNetV2_x2_0' in _checkpoints, 'Not provide `MobileNetV2_x2_0` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['MobileNetV2_x2_0'])
        model.set_state_dict(paddle.load(path))

    return model


L
lyuwenyu 已提交
507
def MobileNetV3_large_x0_35(pretrained=False, **kwargs):
L
lyuwenyu 已提交
508 509
    '''MobileNetV3_large_x0_35
    '''
L
lyuwenyu 已提交
510
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
511 512 513 514 515 516 517 518 519 520

    model = _mobilenet_v3.MobileNetV3_large_x0_35(**kwargs)
    if pretrained:
        assert 'MobileNetV3_large_x0_35' in _checkpoints, 'Not provide `MobileNetV3_large_x0_35` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['MobileNetV3_large_x0_35'])
        model.set_state_dict(paddle.load(path))

    return model


L
lyuwenyu 已提交
521
def MobileNetV3_large_x0_5(pretrained=False, **kwargs):
L
lyuwenyu 已提交
522 523
    '''MobileNetV3_large_x0_5
    '''
L
lyuwenyu 已提交
524
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
525 526 527 528 529 530 531 532 533 534

    model = _mobilenet_v3.MobileNetV3_large_x0_5(**kwargs)
    if pretrained:
        assert 'MobileNetV3_large_x0_5' in _checkpoints, 'Not provide `MobileNetV3_large_x0_5` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['MobileNetV3_large_x0_5'])
        model.set_state_dict(paddle.load(path))

    return model


L
lyuwenyu 已提交
535
def MobileNetV3_large_x0_75(pretrained=False, **kwargs):
L
lyuwenyu 已提交
536 537
    '''MobileNetV3_large_x0_75
    '''
L
lyuwenyu 已提交
538
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
539 540 541 542 543 544 545 546 547 548

    model = _mobilenet_v3.MobileNetV3_large_x0_75(**kwargs)
    if pretrained:
        assert 'MobileNetV3_large_x0_75' in _checkpoints, 'Not provide `MobileNetV3_large_x0_75` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['MobileNetV3_large_x0_75'])
        model.set_state_dict(paddle.load(path))

    return model


L
lyuwenyu 已提交
549
def MobileNetV3_large_x1_0(pretrained=False, **kwargs):
L
lyuwenyu 已提交
550 551
    '''MobileNetV3_large_x1_0
    '''
L
lyuwenyu 已提交
552
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
553 554 555 556 557 558 559 560 561 562

    model = _mobilenet_v3.MobileNetV3_large_x1_0(**kwargs)
    if pretrained:
        assert 'MobileNetV3_large_x1_0' in _checkpoints, 'Not provide `MobileNetV3_large_x1_0` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['MobileNetV3_large_x1_0'])
        model.set_state_dict(paddle.load(path))

    return model


L
lyuwenyu 已提交
563
def MobileNetV3_large_x1_25(pretrained=False, **kwargs):
L
lyuwenyu 已提交
564 565
    '''MobileNetV3_large_x1_25
    '''
L
lyuwenyu 已提交
566
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
567 568 569 570 571 572 573 574 575 576

    model = _mobilenet_v3.MobileNetV3_large_x1_25(**kwargs)
    if pretrained:
        assert 'MobileNetV3_large_x1_25' in _checkpoints, 'Not provide `MobileNetV3_large_x1_25` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['MobileNetV3_large_x1_25'])
        model.set_state_dict(paddle.load(path))

    return model


L
lyuwenyu 已提交
577
def MobileNetV3_small_x0_35(pretrained=False, **kwargs):
L
lyuwenyu 已提交
578 579
    '''MobileNetV3_small_x0_35
    '''
L
lyuwenyu 已提交
580
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
581 582 583 584 585 586 587 588 589 590

    model = _mobilenet_v3.MobileNetV3_small_x0_35(**kwargs)
    if pretrained:
        assert 'MobileNetV3_small_x0_35' in _checkpoints, 'Not provide `MobileNetV3_small_x0_35` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['MobileNetV3_small_x0_35'])
        model.set_state_dict(paddle.load(path))

    return model


L
lyuwenyu 已提交
591
def MobileNetV3_small_x0_5(pretrained=False, **kwargs):
L
lyuwenyu 已提交
592 593
    '''MobileNetV3_small_x0_5
    '''
L
lyuwenyu 已提交
594
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
595 596 597 598 599 600 601 602 603 604

    model = _mobilenet_v3.MobileNetV3_small_x0_5(**kwargs)
    if pretrained:
        assert 'MobileNetV3_small_x0_5' in _checkpoints, 'Not provide `MobileNetV3_small_x0_5` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['MobileNetV3_small_x0_5'])
        model.set_state_dict(paddle.load(path))

    return model


L
lyuwenyu 已提交
605
def MobileNetV3_small_x0_75(pretrained=False, **kwargs):
L
lyuwenyu 已提交
606 607
    '''MobileNetV3_small_x0_75
    '''
L
lyuwenyu 已提交
608
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
609 610 611 612 613 614 615 616 617 618

    model = _mobilenet_v3.MobileNetV3_small_x0_75(**kwargs)
    if pretrained:
        assert 'MobileNetV3_small_x0_75' in _checkpoints, 'Not provide `MobileNetV3_small_x0_75` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['MobileNetV3_small_x0_75'])
        model.set_state_dict(paddle.load(path))

    return model


L
lyuwenyu 已提交
619
def MobileNetV3_small_x1_0(pretrained=False, **kwargs):
L
lyuwenyu 已提交
620 621
    '''MobileNetV3_small_x1_0
    '''
L
lyuwenyu 已提交
622
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
623 624 625 626 627 628 629 630 631 632

    model = _mobilenet_v3.MobileNetV3_small_x1_0(**kwargs)
    if pretrained:
        assert 'MobileNetV3_small_x1_0' in _checkpoints, 'Not provide `MobileNetV3_small_x1_0` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['MobileNetV3_small_x1_0'])
        model.set_state_dict(paddle.load(path))

    return model


L
lyuwenyu 已提交
633
def MobileNetV3_small_x1_25(pretrained=False, **kwargs):
L
lyuwenyu 已提交
634 635
    '''MobileNetV3_small_x1_25
    '''
L
lyuwenyu 已提交
636
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
637 638 639 640 641 642 643 644 645 646

    model = _mobilenet_v3.MobileNetV3_small_x1_25(**kwargs)
    if pretrained:
        assert 'MobileNetV3_small_x1_25' in _checkpoints, 'Not provide `MobileNetV3_small_x1_25` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['MobileNetV3_small_x1_25'])
        model.set_state_dict(paddle.load(path))

    return model


L
lyuwenyu 已提交
647

L
lyuwenyu 已提交
648
def ResNeXt101_32x4d(pretrained=False, **kwargs):
L
lyuwenyu 已提交
649 650
    '''ResNeXt101_32x4d
    '''
L
lyuwenyu 已提交
651
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
652 653 654 655 656 657 658 659 660 661

    model = _resnext.ResNeXt101_32x4d(**kwargs)
    if pretrained:
        assert 'ResNeXt101_32x4d' in _checkpoints, 'Not provide `ResNeXt101_32x4d` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['ResNeXt101_32x4d'])
        model.set_state_dict(paddle.load(path))

    return model


L
lyuwenyu 已提交
662
def ResNeXt101_64x4d(pretrained=False, **kwargs):
L
lyuwenyu 已提交
663 664
    '''ResNeXt101_64x4d
    '''
L
lyuwenyu 已提交
665
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
666 667 668 669 670 671 672 673 674 675

    model = _resnext.ResNeXt101_64x4d(**kwargs)
    if pretrained:
        assert 'ResNeXt101_64x4d' in _checkpoints, 'Not provide `ResNeXt101_64x4d` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['ResNeXt101_64x4d'])
        model.set_state_dict(paddle.load(path))

    return model


L
lyuwenyu 已提交
676
def ResNeXt152_32x4d(pretrained=False, **kwargs):
L
lyuwenyu 已提交
677 678
    '''ResNeXt152_32x4d
    '''
L
lyuwenyu 已提交
679
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
680 681 682 683 684 685 686 687 688 689

    model = _resnext.ResNeXt152_32x4d(**kwargs)
    if pretrained:
        assert 'ResNeXt152_32x4d' in _checkpoints, 'Not provide `ResNeXt152_32x4d` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['ResNeXt152_32x4d'])
        model.set_state_dict(paddle.load(path))

    return model


L
lyuwenyu 已提交
690
def ResNeXt152_64x4d(pretrained=False, **kwargs):
L
lyuwenyu 已提交
691 692
    '''ResNeXt152_64x4d
    '''
L
lyuwenyu 已提交
693
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
694 695 696 697 698 699 700 701 702 703

    model = _resnext.ResNeXt152_64x4d(**kwargs)
    if pretrained:
        assert 'ResNeXt152_64x4d' in _checkpoints, 'Not provide `ResNeXt152_64x4d` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['ResNeXt152_64x4d'])
        model.set_state_dict(paddle.load(path))

    return model


L
lyuwenyu 已提交
704
def ResNeXt50_32x4d(pretrained=False, **kwargs):
L
lyuwenyu 已提交
705 706
    '''ResNeXt50_32x4d
    '''
L
lyuwenyu 已提交
707
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
708 709 710 711 712 713 714 715 716 717

    model = _resnext.ResNeXt50_32x4d(**kwargs)
    if pretrained:
        assert 'ResNeXt50_32x4d' in _checkpoints, 'Not provide `ResNeXt50_32x4d` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['ResNeXt50_32x4d'])
        model.set_state_dict(paddle.load(path))

    return model


L
lyuwenyu 已提交
718
def ResNeXt50_64x4d(pretrained=False, **kwargs):
L
lyuwenyu 已提交
719 720
    '''ResNeXt50_64x4d
    '''
L
lyuwenyu 已提交
721
    # pretrained = kwargs.pop('pretrained', False)
L
lyuwenyu 已提交
722 723 724 725 726 727 728 729

    model = _resnext.ResNeXt50_64x4d(**kwargs)
    if pretrained:
        assert 'ResNeXt50_64x4d' in _checkpoints, 'Not provide `ResNeXt50_64x4d` pretrained model.'
        path = paddle.utils.download.get_weights_path_from_url(_checkpoints['ResNeXt50_64x4d'])
        model.set_state_dict(paddle.load(path))

    return model