當前位置: 首頁>>代碼示例>>Python>>正文


Python resnet.resnet50方法代碼示例

本文整理匯總了Python中resnet.resnet50方法的典型用法代碼示例。如果您正苦於以下問題:Python resnet.resnet50方法的具體用法?Python resnet.resnet50怎麽用?Python resnet.resnet50使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在resnet的用法示例。


在下文中一共展示了resnet.resnet50方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import resnet [as 別名]
# 或者: from resnet import resnet50 [as 別名]
def __init__(self, use_nhwc=False, pad_input=False):
        super().__init__()

        if use_nhwc:
            rn50 = resnet50_nhwc(pretrained=True, pad_input=pad_input)
            idx = 5
        else:
            rn50 = resnet50(pretrained=True)
            idx = 6

        # discard last Resnet block, avrpooling and classification FC
        self.layer1 = nn.Sequential(*list(rn50.children())[:idx])
        self.layer2 = nn.Sequential(*list(rn50.children())[idx:idx+1])
        self.layer3 = nn.Sequential(*list(rn50.children())[idx+1:idx+2])

        # modify conv4 if necessary
        padding = None
        # Always deal with stride in first block
        modulelist = list(self.layer2.children())
        _ModifyBlock(modulelist[0], bottleneck=True, stride=(1,1)) 
開發者ID:mlperf,項目名稱:training_results_v0.5,代碼行數:22,代碼來源:base_model.py

示例2: __init__

# 需要導入模塊: import resnet [as 別名]
# 或者: from resnet import resnet50 [as 別名]
def __init__(self):
        super(FPN, self).__init__()

        self.relu = nn.ReLU(inplace=True)

        # bottom up
        self.resnet = resnet_fpn.resnet50(pretrained=True)

        # top down
        self.upsample = nn.Upsample(scale_factor=2, mode='nearest')
        self.c5_conv = nn.Conv2d(2048, 256, (1, 1))
        self.c4_conv = nn.Conv2d(1024, 256, (1, 1))
        self.c3_conv = nn.Conv2d(512, 256, (1, 1))
        self.c2_conv = nn.Conv2d(256, 256, (1, 1))
        #self.max_pool = nn.MaxPool2d((1, 1), stride=2)

        self.p5_conv = nn.Conv2d(256, 256, (3, 3), padding=1)
        self.p4_conv = nn.Conv2d(256, 256, (3, 3), padding=1)
        self.p3_conv = nn.Conv2d(256, 256, (3, 3), padding=1)
        self.p2_conv = nn.Conv2d(256, 256, (3, 3), padding=1)

        # predict heatmap
        self.sigmoid = nn.Sigmoid()
        self.predict = nn.Conv2d(256, 1, (3, 3), padding=1) 
開發者ID:svip-lab,項目名稱:GazeFollowing,代碼行數:26,代碼來源:gazenet.py

示例3: __init__

# 需要導入模塊: import resnet [as 別名]
# 或者: from resnet import resnet50 [as 別名]
def __init__(self, arch='resnet50'):
        super(visible_module, self).__init__()

        model_v = resnet50(pretrained=True,
                           last_conv_stride=1, last_conv_dilation=1)
        # avg pooling to global pooling
        self.visible = model_v 
開發者ID:mangye16,項目名稱:Cross-Modal-Re-ID-baseline,代碼行數:9,代碼來源:model.py

示例4: GenModelZoo

# 需要導入模塊: import resnet [as 別名]
# 或者: from resnet import resnet50 [as 別名]
def GenModelZoo():
    """  Specify the input shape and model initializing param  """
    return {
        0: (torchvision.models.squeezenet1_1, [1, 3, 224, 224], [True], {}),
        1: (resnet.resnet50, [1, 3, 224, 224], [True], {}),
        2: (torchvision.models.densenet121, [1, 3, 224, 224], [False], {}),
        3: (MobileNet, [1, 3, 224, 224], [], {}),

        17: (models._netG_1, [1, 100, 1, 1], [1, 100, 3, 64, 1], {}),
        18: (FaceBoxes, [1, 3, 224, 224], [], {}),
        20: (UNet.UNet, [1, 3, 64, 64], [2], {}),
    } 
開發者ID:starimeL,項目名稱:PytorchConverter,代碼行數:14,代碼來源:run.py

示例5: __init__

# 需要導入模塊: import resnet [as 別名]
# 或者: from resnet import resnet50 [as 別名]
def __init__(self, pretrained=True):
        """Declare all needed layers."""
        super(ResNet50, self).__init__()
        self.model = resnet.resnet50(pretrained=pretrained)
        self.relu = self.model.relu  # Place a hook

        layers_cfg = [4, 5, 6, 7]
        self.blocks = []
        for i, num_this_layer in enumerate(layers_cfg):
            self.blocks.append(list(self.model.children())[num_this_layer]) 
開發者ID:JaveyWang,項目名稱:Pyramid-Attention-Networks-pytorch,代碼行數:12,代碼來源:networks.py

示例6: initialize_encoder

# 需要導入模塊: import resnet [as 別名]
# 或者: from resnet import resnet50 [as 別名]
def initialize_encoder(model_name, num_classes, use_pretrained=True):
    # Initialize these variables which will be set in this if statement. Each of these
    #   variables is model specific.
    model_ft = None

    if model_name == "resnet18":
        """ Resnet18
        """
        model_ft = resnet.resnet18(pretrained=use_pretrained, num_classes=1000)
        num_ftrs = model_ft.fc.in_features
        model_ft.fc = nn.Linear(num_ftrs, num_classes)

    elif model_name == "resnet34":
        """ Resnet34
        """
        model_ft = resnet.resnet34(pretrained=use_pretrained, num_classes=1000)
        num_ftrs = model_ft.fc.in_features
        model_ft.fc = nn.Linear(num_ftrs, num_classes)

    elif model_name == "resnet50":
        """ Resnet50
        """
        model_ft = resnet.resnet50(pretrained=use_pretrained, num_classes=1000)
        num_ftrs = model_ft.fc.in_features
        model_ft.fc = nn.Linear(num_ftrs, num_classes)

    else:
        print("Invalid model name, exiting...")
        exit()

    return model_ft

# full model 
開發者ID:zouchuhang,項目名稱:Silhouette-Guided-3D,代碼行數:35,代碼來源:model.py

示例7: __init__

# 需要導入模塊: import resnet [as 別名]
# 或者: from resnet import resnet50 [as 別名]
def __init__(self, pretrain=False):
        super(ResDown, self).__init__()
        self.features = resnet50(layer3=True, layer4=False)
        if pretrain:
            load_pretrain(self.features, 'resnet.model')

        self.downsample = ResDownS(1024, 256)
        self.layers = [self.downsample, self.features.layer2, self.features.layer3]
        self.train_nums = [1, 3]
        self.change_point = [0, 0.5]

        self.unfix(0.0) 
開發者ID:foolwood,項目名稱:SiamMask,代碼行數:14,代碼來源:custom.py

示例8: __init__

# 需要導入模塊: import resnet [as 別名]
# 或者: from resnet import resnet50 [as 別名]
def __init__(self, pretrain=False):
        super(ResDown, self).__init__()
        self.features = resnet50(layer3=True, layer4=False)
        if pretrain:
            load_pretrain(self.features, 'resnet.model')

        self.downsample = ResDownS(1024, 256)

        self.layers = [self.downsample, self.features.layer2, self.features.layer3]
        self.train_nums = [1, 3]
        self.change_point = [0, 0.5]

        self.unfix(0.0) 
開發者ID:foolwood,項目名稱:SiamMask,代碼行數:15,代碼來源:custom.py

示例9: __init__

# 需要導入模塊: import resnet [as 別名]
# 或者: from resnet import resnet50 [as 別名]
def __init__(self):
        super(ResNetBackBone, self).__init__()
        
        modelPreTrain50 = resnet.resnet50(pretrained=True)
        self.model = modelPreTrain50 
開發者ID:zhangboshen,項目名稱:A2J,代碼行數:7,代碼來源:model.py


注:本文中的resnet.resnet50方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。