hubconf.py 29.9 KB
Newer Older
L
lyuwenyu 已提交
1
# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
L
lyuwenyu 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14
#
# 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.

15
dependencies = ['paddle']
L
for hub  
lyuwenyu 已提交
16

L
lyuwenyu 已提交
17
import paddle
18 19 20 21 22
import os
import sys


class _SysPathG(object):
L
lyuwenyu 已提交
23 24 25 26 27 28 29 30 31
    """
    _SysPathG used to add/clean path for sys.path. Making sure minimal pkgs dependents by skiping parent dirs.

    __enter__
        add path into sys.path
    __exit__
        clean user's sys.path to avoid unexpect behaviors
    """

L
update  
lyuwenyu 已提交
32 33 34
    def __init__(self, path):
        self.path = path

35
    def __enter__(self, ):
L
update  
lyuwenyu 已提交
36
        sys.path.insert(0, self.path)
37 38

    def __exit__(self, type, value, traceback):
L
update  
lyuwenyu 已提交
39
        _p = sys.path.pop(0)
L
lyuwenyu 已提交
40 41
        assert _p == self.path, 'Make sure sys.path cleaning {} correctly.'.format(
            self.path)
42 43


L
update  
lyuwenyu 已提交
44 45
with _SysPathG(
        os.path.join(
L
lyuwenyu 已提交
46 47
            os.path.dirname(os.path.abspath(__file__)), 'ppcls', 'arch')):
    import backbone
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65

    def _load_pretrained_parameters(model, name):
        url = 'https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/{}_pretrained.pdparams'.format(
            name)
        path = paddle.utils.download.get_weights_path_from_url(url)
        model.set_state_dict(paddle.load(path))
        return model

    def alexnet(pretrained=False, **kwargs):
        """
        AlexNet
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
        Returns:
            model: nn.Layer. Specific `AlexNet` model depends on args.
        """
L
lyuwenyu 已提交
66
        model = backbone.AlexNet(**kwargs)
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
        if pretrained:
            model = _load_pretrained_parameters(model, 'AlexNet')

        return model

    def vgg11(pretrained=False, **kwargs):
        """
        VGG11
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
                stop_grad_layers: int=0. The parameters in blocks which index larger than `stop_grad_layers`, will be set `param.trainable=False`
        Returns:
            model: nn.Layer. Specific `VGG11` model depends on args.
        """
L
lyuwenyu 已提交
83
        model = backbone.VGG11(**kwargs)
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
        if pretrained:
            model = _load_pretrained_parameters(model, 'VGG11')

        return model

    def vgg13(pretrained=False, **kwargs):
        """
        VGG13
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
                stop_grad_layers: int=0. The parameters in blocks which index larger than `stop_grad_layers`, will be set `param.trainable=False`
        Returns:
            model: nn.Layer. Specific `VGG13` model depends on args.
        """
L
lyuwenyu 已提交
100
        model = backbone.VGG13(**kwargs)
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
        if pretrained:
            model = _load_pretrained_parameters(model, 'VGG13')

        return model

    def vgg16(pretrained=False, **kwargs):
        """
        VGG16
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
                stop_grad_layers: int=0. The parameters in blocks which index larger than `stop_grad_layers`, will be set `param.trainable=False`
        Returns:
            model: nn.Layer. Specific `VGG16` model depends on args.
        """
L
lyuwenyu 已提交
117
        model = backbone.VGG16(**kwargs)
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
        if pretrained:
            model = _load_pretrained_parameters(model, 'VGG16')

        return model

    def vgg19(pretrained=False, **kwargs):
        """
        VGG19
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
                stop_grad_layers: int=0. The parameters in blocks which index larger than `stop_grad_layers`, will be set `param.trainable=False`
        Returns:
            model: nn.Layer. Specific `VGG19` model depends on args.
        """
L
lyuwenyu 已提交
134
        model = backbone.VGG19(**kwargs)
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
        if pretrained:
            model = _load_pretrained_parameters(model, 'VGG19')

        return model

    def resnet18(pretrained=False, **kwargs):
        """
        ResNet18
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
                input_image_channel: int=3. The number of input image channels
                data_format: str='NCHW'. The data format of batch input images, should in ('NCHW', 'NHWC')
        Returns:
            model: nn.Layer. Specific `ResNet18` model depends on args.
        """
L
lyuwenyu 已提交
152
        model = backbone.ResNet18(**kwargs)
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
        if pretrained:
            model = _load_pretrained_parameters(model, 'ResNet18')

        return model

    def resnet34(pretrained=False, **kwargs):
        """
        ResNet34
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
                input_image_channel: int=3. The number of input image channels
                data_format: str='NCHW'. The data format of batch input images, should in ('NCHW', 'NHWC')
        Returns:
            model: nn.Layer. Specific `ResNet34` model depends on args.
        """
L
lyuwenyu 已提交
170
        model = backbone.ResNet34(**kwargs)
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
        if pretrained:
            model = _load_pretrained_parameters(model, 'ResNet34')

        return model

    def resnet50(pretrained=False, **kwargs):
        """
        ResNet50
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
                input_image_channel: int=3. The number of input image channels
                data_format: str='NCHW'. The data format of batch input images, should in ('NCHW', 'NHWC')
        Returns:
            model: nn.Layer. Specific `ResNet50` model depends on args.
        """
L
lyuwenyu 已提交
188
        model = backbone.ResNet50(**kwargs)
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205
        if pretrained:
            model = _load_pretrained_parameters(model, 'ResNet50')

        return model

    def resnet101(pretrained=False, **kwargs):
        """
        ResNet101
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
                input_image_channel: int=3. The number of input image channels
                data_format: str='NCHW'. The data format of batch input images, should in ('NCHW', 'NHWC')
        Returns:
            model: nn.Layer. Specific `ResNet101` model depends on args.
        """
L
lyuwenyu 已提交
206
        model = backbone.ResNet101(**kwargs)
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
        if pretrained:
            model = _load_pretrained_parameters(model, 'ResNet101')

        return model

    def resnet152(pretrained=False, **kwargs):
        """
        ResNet152
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
                input_image_channel: int=3. The number of input image channels
                data_format: str='NCHW'. The data format of batch input images, should in ('NCHW', 'NHWC')
        Returns:
            model: nn.Layer. Specific `ResNet152` model depends on args.
        """
L
lyuwenyu 已提交
224
        model = backbone.ResNet152(**kwargs)
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
        if pretrained:
            model = _load_pretrained_parameters(model, 'ResNet152')

        return model

    def squeezenet1_0(pretrained=False, **kwargs):
        """
        SqueezeNet1_0
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
        Returns:
            model: nn.Layer. Specific `SqueezeNet1_0` model depends on args.
        """
L
lyuwenyu 已提交
240
        model = backbone.SqueezeNet1_0(**kwargs)
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
        if pretrained:
            model = _load_pretrained_parameters(model, 'SqueezeNet1_0')

        return model

    def squeezenet1_1(pretrained=False, **kwargs):
        """
        SqueezeNet1_1
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
        Returns:
            model: nn.Layer. Specific `SqueezeNet1_1` model depends on args.
        """
L
lyuwenyu 已提交
256
        model = backbone.SqueezeNet1_1(**kwargs)
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273
        if pretrained:
            model = _load_pretrained_parameters(model, 'SqueezeNet1_1')

        return model

    def densenet121(pretrained=False, **kwargs):
        """
        DenseNet121
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
                dropout: float=0. Probability of setting units to zero.
                bn_size: int=4. The number of channals per group
        Returns:
            model: nn.Layer. Specific `DenseNet121` model depends on args.
        """
L
lyuwenyu 已提交
274
        model = backbone.DenseNet121(**kwargs)
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291
        if pretrained:
            model = _load_pretrained_parameters(model, 'DenseNet121')

        return model

    def densenet161(pretrained=False, **kwargs):
        """
        DenseNet161
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
                dropout: float=0. Probability of setting units to zero.
                bn_size: int=4. The number of channals per group
        Returns:
            model: nn.Layer. Specific `DenseNet161` model depends on args.
        """
L
lyuwenyu 已提交
292
        model = backbone.DenseNet161(**kwargs)
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309
        if pretrained:
            model = _load_pretrained_parameters(model, 'DenseNet161')

        return model

    def densenet169(pretrained=False, **kwargs):
        """
        DenseNet169
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
                dropout: float=0. Probability of setting units to zero.
                bn_size: int=4. The number of channals per group
        Returns:
            model: nn.Layer. Specific `DenseNet169` model depends on args.
        """
L
lyuwenyu 已提交
310
        model = backbone.DenseNet169(**kwargs)
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327
        if pretrained:
            model = _load_pretrained_parameters(model, 'DenseNet169')

        return model

    def densenet201(pretrained=False, **kwargs):
        """
        DenseNet201
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
                dropout: float=0. Probability of setting units to zero.
                bn_size: int=4. The number of channals per group
        Returns:
            model: nn.Layer. Specific `DenseNet201` model depends on args.
        """
L
lyuwenyu 已提交
328
        model = backbone.DenseNet201(**kwargs)
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345
        if pretrained:
            model = _load_pretrained_parameters(model, 'DenseNet201')

        return model

    def densenet264(pretrained=False, **kwargs):
        """
        DenseNet264
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
                dropout: float=0. Probability of setting units to zero.
                bn_size: int=4. The number of channals per group
        Returns:
            model: nn.Layer. Specific `DenseNet264` model depends on args.
        """
L
lyuwenyu 已提交
346
        model = backbone.DenseNet264(**kwargs)
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361
        if pretrained:
            model = _load_pretrained_parameters(model, 'DenseNet264')

        return model

    def inceptionv3(pretrained=False, **kwargs):
        """
        InceptionV3
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
        Returns:
            model: nn.Layer. Specific `InceptionV3` model depends on args.
        """
L
lyuwenyu 已提交
362
        model = backbone.InceptionV3(**kwargs)
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377
        if pretrained:
            model = _load_pretrained_parameters(model, 'InceptionV3')

        return model

    def inceptionv4(pretrained=False, **kwargs):
        """
        InceptionV4
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
        Returns:
            model: nn.Layer. Specific `InceptionV4` model depends on args.
        """
L
lyuwenyu 已提交
378
        model = backbone.InceptionV4(**kwargs)
379 380 381 382 383 384 385 386 387 388 389 390 391 392 393
        if pretrained:
            model = _load_pretrained_parameters(model, 'InceptionV4')

        return model

    def googlenet(pretrained=False, **kwargs):
        """
        GoogLeNet
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
        Returns:
            model: nn.Layer. Specific `GoogLeNet` model depends on args.
        """
L
lyuwenyu 已提交
394
        model = backbone.GoogLeNet(**kwargs)
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409
        if pretrained:
            model = _load_pretrained_parameters(model, 'GoogLeNet')

        return model

    def shufflenetv2_x0_25(pretrained=False, **kwargs):
        """
        ShuffleNetV2_x0_25
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
        Returns:
            model: nn.Layer. Specific `ShuffleNetV2_x0_25` model depends on args.
        """
L
lyuwenyu 已提交
410
        model = backbone.ShuffleNetV2_x0_25(**kwargs)
411 412 413 414 415 416 417 418 419 420 421 422 423 424 425
        if pretrained:
            model = _load_pretrained_parameters(model, 'ShuffleNetV2_x0_25')

        return model

    def mobilenetv1(pretrained=False, **kwargs):
        """
        MobileNetV1
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
        Returns:
            model: nn.Layer. Specific `MobileNetV1` model depends on args.
        """
L
lyuwenyu 已提交
426
        model = backbone.MobileNetV1(**kwargs)
427 428 429 430 431 432 433 434 435 436 437 438 439 440 441
        if pretrained:
            model = _load_pretrained_parameters(model, 'MobileNetV1')

        return model

    def mobilenetv1_x0_25(pretrained=False, **kwargs):
        """
        MobileNetV1_x0_25
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
        Returns:
            model: nn.Layer. Specific `MobileNetV1_x0_25` model depends on args.
        """
L
lyuwenyu 已提交
442
        model = backbone.MobileNetV1_x0_25(**kwargs)
443 444 445 446 447 448 449 450 451 452 453 454 455 456 457
        if pretrained:
            model = _load_pretrained_parameters(model, 'MobileNetV1_x0_25')

        return model

    def mobilenetv1_x0_5(pretrained=False, **kwargs):
        """
        MobileNetV1_x0_5
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
        Returns:
            model: nn.Layer. Specific `MobileNetV1_x0_5` model depends on args.
        """
L
lyuwenyu 已提交
458
        model = backbone.MobileNetV1_x0_5(**kwargs)
459 460 461 462 463 464 465 466 467 468 469 470 471 472 473
        if pretrained:
            model = _load_pretrained_parameters(model, 'MobileNetV1_x0_5')

        return model

    def mobilenetv1_x0_75(pretrained=False, **kwargs):
        """
        MobileNetV1_x0_75
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
        Returns:
            model: nn.Layer. Specific `MobileNetV1_x0_75` model depends on args.
        """
L
lyuwenyu 已提交
474
        model = backbone.MobileNetV1_x0_75(**kwargs)
475 476 477 478 479 480 481 482 483 484 485 486 487 488 489
        if pretrained:
            model = _load_pretrained_parameters(model, 'MobileNetV1_x0_75')

        return model

    def mobilenetv2_x0_25(pretrained=False, **kwargs):
        """
        MobileNetV2_x0_25
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
        Returns:
            model: nn.Layer. Specific `MobileNetV2_x0_25` model depends on args.
        """
L
lyuwenyu 已提交
490
        model = backbone.MobileNetV2_x0_25(**kwargs)
491 492 493 494 495 496 497 498 499 500 501 502 503 504 505
        if pretrained:
            model = _load_pretrained_parameters(model, 'MobileNetV2_x0_25')

        return model

    def mobilenetv2_x0_5(pretrained=False, **kwargs):
        """
        MobileNetV2_x0_5
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
        Returns:
            model: nn.Layer. Specific `MobileNetV2_x0_5` model depends on args.
        """
L
lyuwenyu 已提交
506
        model = backbone.MobileNetV2_x0_5(**kwargs)
507 508 509 510 511 512 513 514 515 516 517 518 519 520 521
        if pretrained:
            model = _load_pretrained_parameters(model, 'MobileNetV2_x0_5')

        return model

    def mobilenetv2_x0_75(pretrained=False, **kwargs):
        """
        MobileNetV2_x0_75
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
        Returns:
            model: nn.Layer. Specific `MobileNetV2_x0_75` model depends on args.
        """
L
lyuwenyu 已提交
522
        model = backbone.MobileNetV2_x0_75(**kwargs)
523 524 525 526 527 528 529 530 531 532 533 534 535 536 537
        if pretrained:
            model = _load_pretrained_parameters(model, 'MobileNetV2_x0_75')

        return model

    def mobilenetv2_x1_5(pretrained=False, **kwargs):
        """
        MobileNetV2_x1_5
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
        Returns:
            model: nn.Layer. Specific `MobileNetV2_x1_5` model depends on args.
        """
L
lyuwenyu 已提交
538
        model = backbone.MobileNetV2_x1_5(**kwargs)
539 540 541 542 543 544 545 546 547 548 549 550 551 552 553
        if pretrained:
            model = _load_pretrained_parameters(model, 'MobileNetV2_x1_5')

        return model

    def mobilenetv2_x2_0(pretrained=False, **kwargs):
        """
        MobileNetV2_x2_0
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
        Returns:
            model: nn.Layer. Specific `MobileNetV2_x2_0` model depends on args.
        """
L
lyuwenyu 已提交
554
        model = backbone.MobileNetV2_x2_0(**kwargs)
555 556 557 558 559 560 561 562 563 564 565 566 567 568 569
        if pretrained:
            model = _load_pretrained_parameters(model, 'MobileNetV2_x2_0')

        return model

    def mobilenetv3_large_x0_35(pretrained=False, **kwargs):
        """
        MobileNetV3_large_x0_35
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
        Returns:
            model: nn.Layer. Specific `MobileNetV3_large_x0_35` model depends on args.
        """
L
lyuwenyu 已提交
570
        model = backbone.MobileNetV3_large_x0_35(**kwargs)
571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586
        if pretrained:
            model = _load_pretrained_parameters(model,
                                                'MobileNetV3_large_x0_35')

        return model

    def mobilenetv3_large_x0_5(pretrained=False, **kwargs):
        """
        MobileNetV3_large_x0_5
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
        Returns:
            model: nn.Layer. Specific `MobileNetV3_large_x0_5` model depends on args.
        """
L
lyuwenyu 已提交
587
        model = backbone.MobileNetV3_large_x0_5(**kwargs)
588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603
        if pretrained:
            model = _load_pretrained_parameters(model,
                                                'MobileNetV3_large_x0_5')

        return model

    def mobilenetv3_large_x0_75(pretrained=False, **kwargs):
        """
        MobileNetV3_large_x0_75
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
        Returns:
            model: nn.Layer. Specific `MobileNetV3_large_x0_75` model depends on args.
        """
L
lyuwenyu 已提交
604
        model = backbone.MobileNetV3_large_x0_75(**kwargs)
605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620
        if pretrained:
            model = _load_pretrained_parameters(model,
                                                'MobileNetV3_large_x0_75')

        return model

    def mobilenetv3_large_x1_0(pretrained=False, **kwargs):
        """
        MobileNetV3_large_x1_0
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
        Returns:
            model: nn.Layer. Specific `MobileNetV3_large_x1_0` model depends on args.
        """
L
lyuwenyu 已提交
621
        model = backbone.MobileNetV3_large_x1_0(**kwargs)
622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637
        if pretrained:
            model = _load_pretrained_parameters(model,
                                                'MobileNetV3_large_x1_0')

        return model

    def mobilenetv3_large_x1_25(pretrained=False, **kwargs):
        """
        MobileNetV3_large_x1_25
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
        Returns:
            model: nn.Layer. Specific `MobileNetV3_large_x1_25` model depends on args.
        """
L
lyuwenyu 已提交
638
        model = backbone.MobileNetV3_large_x1_25(**kwargs)
639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654
        if pretrained:
            model = _load_pretrained_parameters(model,
                                                'MobileNetV3_large_x1_25')

        return model

    def mobilenetv3_small_x0_35(pretrained=False, **kwargs):
        """
        MobileNetV3_small_x0_35
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
        Returns:
            model: nn.Layer. Specific `MobileNetV3_small_x0_35` model depends on args.
        """
L
lyuwenyu 已提交
655
        model = backbone.MobileNetV3_small_x0_35(**kwargs)
656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671
        if pretrained:
            model = _load_pretrained_parameters(model,
                                                'MobileNetV3_small_x0_35')

        return model

    def mobilenetv3_small_x0_5(pretrained=False, **kwargs):
        """
        MobileNetV3_small_x0_5
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
        Returns:
            model: nn.Layer. Specific `MobileNetV3_small_x0_5` model depends on args.
        """
L
lyuwenyu 已提交
672
        model = backbone.MobileNetV3_small_x0_5(**kwargs)
673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688
        if pretrained:
            model = _load_pretrained_parameters(model,
                                                'MobileNetV3_small_x0_5')

        return model

    def mobilenetv3_small_x0_75(pretrained=False, **kwargs):
        """
        MobileNetV3_small_x0_75
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
        Returns:
            model: nn.Layer. Specific `MobileNetV3_small_x0_75` model depends on args.
        """
L
lyuwenyu 已提交
689
        model = backbone.MobileNetV3_small_x0_75(**kwargs)
690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705
        if pretrained:
            model = _load_pretrained_parameters(model,
                                                'MobileNetV3_small_x0_75')

        return model

    def mobilenetv3_small_x1_0(pretrained=False, **kwargs):
        """
        MobileNetV3_small_x1_0
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
        Returns:
            model: nn.Layer. Specific `MobileNetV3_small_x1_0` model depends on args.
        """
L
lyuwenyu 已提交
706
        model = backbone.MobileNetV3_small_x1_0(**kwargs)
707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722
        if pretrained:
            model = _load_pretrained_parameters(model,
                                                'MobileNetV3_small_x1_0')

        return model

    def mobilenetv3_small_x1_25(pretrained=False, **kwargs):
        """
        MobileNetV3_small_x1_25
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
        Returns:
            model: nn.Layer. Specific `MobileNetV3_small_x1_25` model depends on args.
        """
L
lyuwenyu 已提交
723
        model = backbone.MobileNetV3_small_x1_25(**kwargs)
724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739
        if pretrained:
            model = _load_pretrained_parameters(model,
                                                'MobileNetV3_small_x1_25')

        return model

    def resnext101_32x4d(pretrained=False, **kwargs):
        """
        ResNeXt101_32x4d
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
        Returns:
            model: nn.Layer. Specific `ResNeXt101_32x4d` model depends on args.
        """
L
lyuwenyu 已提交
740
        model = backbone.ResNeXt101_32x4d(**kwargs)
741 742 743 744 745 746 747 748 749 750 751 752 753 754 755
        if pretrained:
            model = _load_pretrained_parameters(model, 'ResNeXt101_32x4d')

        return model

    def resnext101_64x4d(pretrained=False, **kwargs):
        """
        ResNeXt101_64x4d
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
        Returns:
            model: nn.Layer. Specific `ResNeXt101_64x4d` model depends on args.
        """
L
lyuwenyu 已提交
756
        model = backbone.ResNeXt101_64x4d(**kwargs)
757 758 759 760 761 762 763 764 765 766 767 768 769 770 771
        if pretrained:
            model = _load_pretrained_parameters(model, 'ResNeXt101_64x4d')

        return model

    def resnext152_32x4d(pretrained=False, **kwargs):
        """
        ResNeXt152_32x4d
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
        Returns:
            model: nn.Layer. Specific `ResNeXt152_32x4d` model depends on args.
        """
L
lyuwenyu 已提交
772
        model = backbone.ResNeXt152_32x4d(**kwargs)
773 774 775 776 777 778 779 780 781 782 783 784 785 786 787
        if pretrained:
            model = _load_pretrained_parameters(model, 'ResNeXt152_32x4d')

        return model

    def resnext152_64x4d(pretrained=False, **kwargs):
        """
        ResNeXt152_64x4d
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
        Returns:
            model: nn.Layer. Specific `ResNeXt152_64x4d` model depends on args.
        """
L
lyuwenyu 已提交
788
        model = backbone.ResNeXt152_64x4d(**kwargs)
789 790 791 792 793 794 795 796 797 798 799 800 801 802 803
        if pretrained:
            model = _load_pretrained_parameters(model, 'ResNeXt152_64x4d')

        return model

    def resnext50_32x4d(pretrained=False, **kwargs):
        """
        ResNeXt50_32x4d
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
        Returns:
            model: nn.Layer. Specific `ResNeXt50_32x4d` model depends on args.
        """
L
lyuwenyu 已提交
804
        model = backbone.ResNeXt50_32x4d(**kwargs)
805 806 807 808 809 810 811 812 813 814 815 816 817 818 819
        if pretrained:
            model = _load_pretrained_parameters(model, 'ResNeXt50_32x4d')

        return model

    def resnext50_64x4d(pretrained=False, **kwargs):
        """
        ResNeXt50_64x4d
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
        Returns:
            model: nn.Layer. Specific `ResNeXt50_64x4d` model depends on args.
        """
L
lyuwenyu 已提交
820
        model = backbone.ResNeXt50_64x4d(**kwargs)
821 822 823 824
        if pretrained:
            model = _load_pretrained_parameters(model, 'ResNeXt50_64x4d')

        return model
L
lyuwenyu 已提交
825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840

    def darknet53(pretrained=False, **kwargs):
        """
        DarkNet53
        Args:
            pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
            kwargs: 
                class_dim: int=1000. Output dim of last fc layer.
        Returns:
            model: nn.Layer. Specific `ResNeXt50_64x4d` model depends on args.
        """
        model = backbone.DarkNet53(**kwargs)
        if pretrained:
            model = _load_pretrained_parameters(model, 'DarkNet53')

        return model