Python chainer.links.VGG16Layers() Examples

The following are 4 code examples of chainer.links.VGG16Layers(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module chainer.links , or try the search function .
Example #1
Source File: model.py    From chainer with MIT License 5 votes vote down vote up
def __init__(self):
        super(VGG16FeatureExtractor, self).__init__()
        with self.init_scope():
            self.cnn = L.VGG16Layers()
        self.cnn_layer_name = 'fc7' 
Example #2
Source File: model.py    From pfio with MIT License 5 votes vote down vote up
def __init__(self):
        super(VGG16FeatureExtractor, self).__init__()
        with self.init_scope():
            self.cnn = L.VGG16Layers()
        self.cnn_layer_name = 'fc7' 
Example #3
Source File: models.py    From chainer-gogh with MIT License 5 votes vote down vote up
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 
Example #4
Source File: main.py    From style_transfer_3d with MIT License 4 votes vote down vote up
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