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)
input_node should be a 4-D Tensor representing a batch 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.
input_node will be the input of the block.
in_channels should be the number of channels at the input of the block.
out_channels should be the number of channels at the output of the block.
kernel_size should be the width and height of the convolution matrix used within the block.
strides should indicate the 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.
input_node will be the input of the layer.
in_channels should be the number of channels at the input of the layer.
out_channels should be the number of channels at the output of the layer.
kernel_size should be the width and height of the convolution matrix used within the block.
strides should indicate the stride of the sliding window for each dimension of input_node.
activation should indicate whether a ‘relu’ node should be added after the convolution layer.
-
stylish.transform.
conv2d_transpose_layer
(input_node, operation_name, in_channels, out_channels, kernel_size, strides, activation=None)[source]¶ Apply a transposed 2-D convolution layer to the network.
input_node will be the input of the layer.
in_channels should be the number of channels at the input of the layer.
out_channels should be the number of channels at the output of the layer.
kernel_size should be the width and height of the convolution matrix used within the block.
strides should indicate the stride of the sliding window for each dimension of input_node.
activation should indicate whether a ‘relu’ node should be added after the convolution layer.
-
stylish.transform.
instance_normalization
(input_node, channels)[source]¶ Apply an instance normalization to the network.
input_node will be the input of the layer.
See also
Ulyanov et al. (2017). Instance Normalization: The Missing Ingredient for Fast Stylization. CoRR, abs/1607.08022.