当前位置: 首页>>代码示例>>Python>>正文


Python vgg.model_urls方法代码示例

本文整理汇总了Python中torchvision.models.vgg.model_urls方法的典型用法代码示例。如果您正苦于以下问题:Python vgg.model_urls方法的具体用法?Python vgg.model_urls怎么用?Python vgg.model_urls使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在torchvision.models.vgg的用法示例。


在下文中一共展示了vgg.model_urls方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load_base_weights

# 需要导入模块: from torchvision.models import vgg [as 别名]
# 或者: from torchvision.models.vgg import model_urls [as 别名]
def load_base_weights(self):
        """This is complicated because we converted the base model to be fully
        convolutional, so some surgery needs to happen here."""
        base_state_dict = model_zoo.load_url(vgg.model_urls['vgg16'])
        vgg_state_dict = {k[len('features.'):]: v
                          for k, v in base_state_dict.items()
                          if k.startswith('features.')}
        self.vgg.load_state_dict(vgg_state_dict)
        vgg_head_params = self.vgg_head.parameters()
        for k, v in base_state_dict.items():
            if not k.startswith('classifier.'):
                continue
            if k.startswith('classifier.6.'):
                # skip final classifier output
                continue
            vgg_head_param = next(vgg_head_params)
            vgg_head_param.data = v.view(vgg_head_param.size()) 
开发者ID:jhoffman,项目名称:cycada_release,代码行数:19,代码来源:fcn8s.py

示例2: load_base_weights

# 需要导入模块: from torchvision.models import vgg [as 别名]
# 或者: from torchvision.models.vgg import model_urls [as 别名]
def load_base_weights(self):
		"""This is complicated because we converted the base model to be fully
		convolutional, so some surgery needs to happen here."""
		base_state_dict = model_zoo.load_url(vgg.model_urls['vgg16'])
		vgg_state_dict = {k[len('features.'):]: v
		                  for k, v in base_state_dict.items()
		                  if k.startswith('features.')}
		self.vgg.load_state_dict(vgg_state_dict)
		vgg_head_params = self.vgg_head.parameters()
		for k, v in base_state_dict.items():
			if not k.startswith('classifier.'):
				continue
			if k.startswith('classifier.6.'):
				# skip final classifier output
				continue
			vgg_head_param = next(vgg_head_params)
			vgg_head_param.data = v.view(vgg_head_param.size()) 
开发者ID:Luodian,项目名称:MADAN,代码行数:19,代码来源:fcn8s.py

示例3: vgg11

# 需要导入模块: from torchvision.models import vgg [as 别名]
# 或者: from torchvision.models.vgg import model_urls [as 别名]
def vgg11(config_channels, anchors, num_cls):
    model = VGG(config_channels, anchors, num_cls, make_layers(config_channels, cfg['A']))
    if config_channels.config.getboolean('model', 'pretrained'):
        url = model_urls['vgg11']
        logging.info('use pretrained model: ' + url)
        state_dict = model.state_dict()
        for key, value in model_zoo.load_url(url).items():
            if key in state_dict:
                state_dict[key] = value
        model.load_state_dict(state_dict)
    return model 
开发者ID:ruiminshen,项目名称:yolo2-pytorch,代码行数:13,代码来源:vgg.py

示例4: vgg11_bn

# 需要导入模块: from torchvision.models import vgg [as 别名]
# 或者: from torchvision.models.vgg import model_urls [as 别名]
def vgg11_bn(config_channels, anchors, num_cls):
    model = VGG(config_channels, anchors, num_cls, make_layers(config_channels, cfg['A'], batch_norm=True))
    if config_channels.config.getboolean('model', 'pretrained'):
        url = model_urls['vgg11_bn']
        logging.info('use pretrained model: ' + url)
        state_dict = model.state_dict()
        for key, value in model_zoo.load_url(url).items():
            if key in state_dict:
                state_dict[key] = value
        model.load_state_dict(state_dict)
    return model 
开发者ID:ruiminshen,项目名称:yolo2-pytorch,代码行数:13,代码来源:vgg.py

示例5: vgg13

# 需要导入模块: from torchvision.models import vgg [as 别名]
# 或者: from torchvision.models.vgg import model_urls [as 别名]
def vgg13(config_channels, anchors, num_cls):
    model = VGG(config_channels, anchors, num_cls, make_layers(config_channels, cfg['B']))
    if config_channels.config.getboolean('model', 'pretrained'):
        url = model_urls['vgg13']
        logging.info('use pretrained model: ' + url)
        state_dict = model.state_dict()
        for key, value in model_zoo.load_url(url).items():
            if key in state_dict:
                state_dict[key] = value
        model.load_state_dict(state_dict)
    return model 
开发者ID:ruiminshen,项目名称:yolo2-pytorch,代码行数:13,代码来源:vgg.py

示例6: vgg13_bn

# 需要导入模块: from torchvision.models import vgg [as 别名]
# 或者: from torchvision.models.vgg import model_urls [as 别名]
def vgg13_bn(config_channels, anchors, num_cls):
    model = VGG(config_channels, anchors, num_cls, make_layers(config_channels, cfg['B'], batch_norm=True))
    if config_channels.config.getboolean('model', 'pretrained'):
        url = model_urls['vgg13_bn']
        logging.info('use pretrained model: ' + url)
        state_dict = model.state_dict()
        for key, value in model_zoo.load_url(url).items():
            if key in state_dict:
                state_dict[key] = value
        model.load_state_dict(state_dict)
    return model 
开发者ID:ruiminshen,项目名称:yolo2-pytorch,代码行数:13,代码来源:vgg.py

示例7: vgg16

# 需要导入模块: from torchvision.models import vgg [as 别名]
# 或者: from torchvision.models.vgg import model_urls [as 别名]
def vgg16(config_channels, anchors, num_cls):
    model = VGG(config_channels, anchors, num_cls, make_layers(config_channels, cfg['D']))
    if config_channels.config.getboolean('model', 'pretrained'):
        url = model_urls['vgg16']
        logging.info('use pretrained model: ' + url)
        state_dict = model.state_dict()
        for key, value in model_zoo.load_url(url).items():
            if key in state_dict:
                state_dict[key] = value
        model.load_state_dict(state_dict)
    return model 
开发者ID:ruiminshen,项目名称:yolo2-pytorch,代码行数:13,代码来源:vgg.py

示例8: vgg19

# 需要导入模块: from torchvision.models import vgg [as 别名]
# 或者: from torchvision.models.vgg import model_urls [as 别名]
def vgg19(config_channels, anchors, num_cls):
    model = VGG(config_channels, anchors, num_cls, make_layers(config_channels, cfg['E']))
    if config_channels.config.getboolean('model', 'pretrained'):
        url = model_urls['vgg19']
        logging.info('use pretrained model: ' + url)
        state_dict = model.state_dict()
        for key, value in model_zoo.load_url(url).items():
            if key in state_dict:
                state_dict[key] = value
        model.load_state_dict(state_dict)
    return model 
开发者ID:ruiminshen,项目名称:yolo2-pytorch,代码行数:13,代码来源:vgg.py

示例9: vgg19_bn

# 需要导入模块: from torchvision.models import vgg [as 别名]
# 或者: from torchvision.models.vgg import model_urls [as 别名]
def vgg19_bn(config_channels, anchors, num_cls):
    model = VGG(config_channels, anchors, num_cls, make_layers(config_channels, cfg['E'], batch_norm=True))
    if config_channels.config.getboolean('model', 'pretrained'):
        url = model_urls['vgg19_bn']
        logging.info('use pretrained model: ' + url)
        state_dict = model.state_dict()
        for key, value in model_zoo.load_url(url).items():
            if key in state_dict:
                state_dict[key] = value
        model.load_state_dict(state_dict)
    return model 
开发者ID:ruiminshen,项目名称:yolo2-pytorch,代码行数:13,代码来源:vgg.py

示例10: __init__

# 需要导入模块: from torchvision.models import vgg [as 别名]
# 或者: from torchvision.models.vgg import model_urls [as 别名]
def __init__(self, pretrained=True, freeze=True):
        super(vgg16_bn, self).__init__()
        model_urls['vgg16_bn'] = model_urls['vgg16_bn'].replace('https://', 'http://')
        vgg_pretrained_features = models.vgg16_bn(pretrained=pretrained).features
        self.slice1 = torch.nn.Sequential()
        self.slice2 = torch.nn.Sequential()
        self.slice3 = torch.nn.Sequential()
        self.slice4 = torch.nn.Sequential()
        self.slice5 = torch.nn.Sequential()
        for x in range(12):         # conv2_2
            self.slice1.add_module(str(x), vgg_pretrained_features[x])
        for x in range(12, 19):         # conv3_3
            self.slice2.add_module(str(x), vgg_pretrained_features[x])
        for x in range(19, 29):         # conv4_3
            self.slice3.add_module(str(x), vgg_pretrained_features[x])
        for x in range(29, 39):         # conv5_3
            self.slice4.add_module(str(x), vgg_pretrained_features[x])

        # fc6, fc7 without atrous conv
        self.slice5 = torch.nn.Sequential(
                nn.MaxPool2d(kernel_size=3, stride=1, padding=1),
                nn.Conv2d(512, 1024, kernel_size=3, padding=6, dilation=6),
                nn.Conv2d(1024, 1024, kernel_size=1)
        )

        if not pretrained:
            init_weights(self.slice1.modules())
            init_weights(self.slice2.modules())
            init_weights(self.slice3.modules())
            init_weights(self.slice4.modules())

        init_weights(self.slice5.modules())        # no pretrained model for fc6 and fc7

        if freeze:
            for param in self.slice1.parameters():      # only first conv
                param.requires_grad= False 
开发者ID:clovaai,项目名称:CRAFT-pytorch,代码行数:38,代码来源:vgg16_bn.py

示例11: vgg11

# 需要导入模块: from torchvision.models import vgg [as 别名]
# 或者: from torchvision.models.vgg import model_urls [as 别名]
def vgg11(config_channels):
    model = VGG(config_channels, make_layers(config_channels, cfg['A']))
    if config_channels.config.getboolean('model', 'pretrained'):
        url = model_urls['vgg11']
        logging.info('use pretrained model: ' + url)
        state_dict = model.state_dict()
        for key, value in model_zoo.load_url(url).items():
            if key in state_dict:
                state_dict[key] = value
        model.load_state_dict(state_dict)
    return model 
开发者ID:ruiminshen,项目名称:openpose-pytorch,代码行数:13,代码来源:vgg.py

示例12: vgg11_bn

# 需要导入模块: from torchvision.models import vgg [as 别名]
# 或者: from torchvision.models.vgg import model_urls [as 别名]
def vgg11_bn(config_channels):
    model = VGG(config_channels, make_layers(config_channels, cfg['A'], batch_norm=True))
    if config_channels.config.getboolean('model', 'pretrained'):
        url = model_urls['vgg11_bn']
        logging.info('use pretrained model: ' + url)
        state_dict = model.state_dict()
        for key, value in model_zoo.load_url(url).items():
            if key in state_dict:
                state_dict[key] = value
        model.load_state_dict(state_dict)
    return model 
开发者ID:ruiminshen,项目名称:openpose-pytorch,代码行数:13,代码来源:vgg.py

示例13: vgg13

# 需要导入模块: from torchvision.models import vgg [as 别名]
# 或者: from torchvision.models.vgg import model_urls [as 别名]
def vgg13(config_channels):
    model = VGG(config_channels, make_layers(config_channels, cfg['B']))
    if config_channels.config.getboolean('model', 'pretrained'):
        url = model_urls['vgg13']
        logging.info('use pretrained model: ' + url)
        state_dict = model.state_dict()
        for key, value in model_zoo.load_url(url).items():
            if key in state_dict:
                state_dict[key] = value
        model.load_state_dict(state_dict)
    return model 
开发者ID:ruiminshen,项目名称:openpose-pytorch,代码行数:13,代码来源:vgg.py

示例14: vgg13_bn

# 需要导入模块: from torchvision.models import vgg [as 别名]
# 或者: from torchvision.models.vgg import model_urls [as 别名]
def vgg13_bn(config_channels):
    model = VGG(config_channels, make_layers(config_channels, cfg['B'], batch_norm=True))
    if config_channels.config.getboolean('model', 'pretrained'):
        url = model_urls['vgg13_bn']
        logging.info('use pretrained model: ' + url)
        state_dict = model.state_dict()
        for key, value in model_zoo.load_url(url).items():
            if key in state_dict:
                state_dict[key] = value
        model.load_state_dict(state_dict)
    return model 
开发者ID:ruiminshen,项目名称:openpose-pytorch,代码行数:13,代码来源:vgg.py

示例15: vgg16

# 需要导入模块: from torchvision.models import vgg [as 别名]
# 或者: from torchvision.models.vgg import model_urls [as 别名]
def vgg16(config_channels):
    model = VGG(config_channels, make_layers(config_channels, cfg['D']))
    if config_channels.config.getboolean('model', 'pretrained'):
        url = model_urls['vgg16']
        logging.info('use pretrained model: ' + url)
        state_dict = model.state_dict()
        for key, value in model_zoo.load_url(url).items():
            if key in state_dict:
                state_dict[key] = value
        model.load_state_dict(state_dict)
    return model 
开发者ID:ruiminshen,项目名称:openpose-pytorch,代码行数:13,代码来源:vgg.py


注:本文中的torchvision.models.vgg.model_urls方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。