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


Python links.VGG16Layers方法代碼示例

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


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

示例1: __init__

# 需要導入模塊: from chainer import links [as 別名]
# 或者: from chainer.links import VGG16Layers [as 別名]
def __init__(self):
        super(VGG16FeatureExtractor, self).__init__()
        with self.init_scope():
            self.cnn = L.VGG16Layers()
        self.cnn_layer_name = 'fc7' 
開發者ID:chainer,項目名稱:chainer,代碼行數:7,代碼來源:model.py

示例2: __init__

# 需要導入模塊: from chainer import links [as 別名]
# 或者: from chainer.links import VGG16Layers [as 別名]
def __init__(self, alpha=[0,0,1,1], beta=[1,1,1,1]):
        from chainer.links import VGG16Layers
        print ("load model... vgg_chainer")
        self.model = VGG16Layers()
        self.alpha = alpha
        self.beta = beta 
開發者ID:pfnet-research,項目名稱:chainer-gogh,代碼行數:8,代碼來源:models.py

示例3: __init__

# 需要導入模塊: from chainer import links [as 別名]
# 或者: from chainer.links import VGG16Layers [as 別名]
def __init__(
            self,
            filename_mesh,
            filename_style,
            texture_size=4,
            camera_distance=2.732,
            camera_distance_noise=0.1,
            elevation_min=20,
            elevation_max=40,
            lr_vertices=0.01,
            lr_textures=1.0,
            lambda_style=1,
            lambda_content=2e9,
            lambda_tv=1e7,
            image_size=224,
    ):
        super(StyleTransferModel, self).__init__()
        self.image_size = image_size
        self.camera_distance = camera_distance
        self.camera_distance_noise = camera_distance_noise
        self.elevation_min = elevation_min
        self.elevation_max = elevation_max
        self.lambda_style = lambda_style
        self.lambda_content = lambda_content
        self.lambda_tv = lambda_tv

        # load feature extractor
        self.vgg16 = cl.VGG16Layers()

        # load reference image
        reference_image = scipy.misc.imread(filename_style)
        reference_image = scipy.misc.imresize(reference_image, (image_size, image_size))
        reference_image = reference_image.astype('float32') / 255.
        reference_image = reference_image[:, :, :3].transpose((2, 0, 1))[None, :, :, :]
        reference_image = self.xp.array(reference_image)
        with chainer.no_backprop_mode():
            features_ref = [f.data for f in self.extract_style_feature(reference_image)]
        self.features_ref = features_ref
        self.background_color = reference_image.mean((0, 2, 3))

        with self.init_scope():
            # load .obj
            self.mesh = neural_renderer.Mesh(filename_mesh, texture_size)
            self.mesh.set_lr(lr_vertices, lr_textures)
            self.vertices_original = self.xp.copy(self.mesh.vertices.data)

            # setup renderer
            renderer = neural_renderer.Renderer()
            renderer.image_size = image_size
            renderer.background_color = self.background_color
            self.renderer = renderer 
開發者ID:hiroharu-kato,項目名稱:style_transfer_3d,代碼行數:53,代碼來源:main.py


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