stylish.transform¶
The image transformation network is a deep residual convolutional neural network parameterized by weights.
The network body consists of five residual blocks. All non-residual convolutional layers are followed by an instance normalization and ReLU non-linearities with the exception of the output layer, which instead uses a scaled “tanh” to ensure that the output image has pixels in the range [0, 255]. Other than the first and last layers which use 9 × 9 kernels, all convolutional layers use 3 × 3 kernels.
See also
Johnson et al. (2016). Perceptual losses for real-time style transfer and superresolution. CoRR, abs/1603.08155.
See also
Ulyanov et al. (2017). Instance Normalization: The Missing Ingredient for Fast Stylization. CoRR, abs/1607.08022.
-
stylish.transform.
network
(input_node)[source]¶ Apply the image transformation network.
The last node of the graph will be returned. The network will be applied to the current Tensorflow graph.
Example:
>>> g = tf.Graph() >>> with g.as_default(), tf.Session() as session: ... ... ... network(input_node)
Parameters: input_node – 4-D Tensor representing a list of images. It will be the input of the network.
-
stylish.transform.
residual_block
(input_node, operation_name, in_channels, out_channels, kernel_size, strides)[source]¶ Apply a residual block to the network.
Parameters: - input_node – Input tensor of the block
- operation_name – Name of the operation which will be set as a scope.
- in_channels – Number of channels at the input of the block.
- out_channels – Number of channels at the output of the block.
- kernel_size – width and height of the convolution matrix used within the block.
- strides – stride of the sliding window for each dimension of input_node.
-
stylish.transform.
conv2d_layer
(input_node, operation_name, in_channels, out_channels, kernel_size, strides, activation=False)[source]¶ Apply a 2-D convolution layer to the network.
Parameters: - input_node – Input tensor of the block
- operation_name – Name of the operation which will be set as a scope.
- in_channels – Number of channels at the input of the block.
- out_channels – Number of channels at the output of the block.
- kernel_size – width and height of the convolution matrix used within the block.
- strides – stride of the sliding window for each dimension of input_node.
- activation – indicate whether a ‘relu’ node should be added after the convolution layer. Default is False.
-
stylish.transform.
conv2d_transpose_layer
(input_node, operation_name, in_channels, out_channels, kernel_size, strides, activation=False)[source]¶ Apply a transposed 2-D convolution layer to the network.
Parameters: - input_node – Input tensor of the block
- operation_name – Name of the operation which will be set as a scope.
- in_channels – Number of channels at the input of the block.
- out_channels – Number of channels at the output of the block.
- kernel_size – width and height of the convolution matrix used within the block.
- strides – stride of the sliding window for each dimension of input_node.
- activation – indicate whether a ‘relu’ node should be added after the convolution layer. Default is False.
-
stylish.transform.
instance_normalization
(input_node, channels)[source]¶ Apply an instance normalization to the network.
Parameters: - input_node – Input tensor of the block
- channels – Number of channels at the input of the block.
See also
Ulyanov et al. (2017). Instance Normalization: The Missing Ingredient for Fast Stylization. CoRR, abs/1607.08022.