pystiche_papers.gatys_ecker_bethge_2016

Title

Image Style Transfer Using Convolutional Neural Networks

Authors

Leon A. Gatys, Alexander. S. Ecker, and Matthias Bethge

Citation

[GEB2016]

Reference implementation

Repository / Archive

Variant

Image optimization

Content loss

FeatureReconstructionLoss

Style loss

GramLoss

Behavioral changes

The following parts are affected:

Hyper parameters

Empty cells mean, that the parameter is not defined in the paper or no default is set in the reference implementation of the original authors. In both cases the available value is used as default.

content_loss()

Parameter

impl_params

True

False

layer

"relu4_2"

"conv4_2"

score_weight

1e0

style_loss()

Parameter

impl_params

True

False

layers | ("relu1_1", "relu2_1", "relu3_1", "relu4_1", "relu5_1")

("conv1_1", "conv2_1", "conv3_1", "conv4_1", "conv5_1")

layer_weights

(2.4e-04, 6.1e-05, 1.5e-05, 3.8e-06, 3.8e-06) 1

"mean"

score_weight

1e3 2

nst()

Parameter

impl_params

True

False

image_size

512

starting_point

"content"

"random"

num_steps

500

1

The layer_weights are computed by \(1 / n^2\) where \(n\) denotes the number of channels of a feature map from the corresponding layer in the multi_layer_encoder().

2

The paper also reports score_weight=1e-4 for some images.

API

pystiche_papers.gatys_ecker_bethge_2016.images()
Return type

DownloadableImageCollection

class pystiche_papers.gatys_ecker_bethge_2016.FeatureReconstructionLoss(encoder, impl_params=True, **feature_reconstruction_loss_kwargs)

Feature reconstruction loss from [GEB2016].

Parameters
  • encoder (Encoder) – Encoder used to encode the input.

  • impl_params (bool) – If False, calculate the score with the squared error (SE) instead of the mean squared error (MSE). Furthermore, use a score correction factor of 1/2.

  • **feature_reconstruction_loss_kwargs – Additional parameters of a pystiche.loss.FeatureReconstructionLoss.

pystiche_papers.gatys_ecker_bethge_2016.content_loss(impl_params=True, multi_layer_encoder=None, hyper_parameters=None)

Content loss from [GEB2016].

Parameters
Return type

FeatureReconstructionLoss

class pystiche_papers.gatys_ecker_bethge_2016.MultiLayerEncodingLoss(multi_layer_encoder, layers, encoding_loss_fn, impl_params=True, **multi_layer_encoding_op_kwargs)

Multi-layer encoding loss from [GEB2016].

Parameters
pystiche_papers.gatys_ecker_bethge_2016.style_loss(impl_params=True, multi_layer_encoder=None, hyper_parameters=None)

Style loss from [GEB2016].

Parameters
Return type

MultiLayerEncodingLoss

pystiche_papers.gatys_ecker_bethge_2016.perceptual_loss(impl_params=True, multi_layer_encoder=None, hyper_parameters=None)

Perceptual loss from [GEB2016].

Parameters
Return type

PerceptualLoss

pystiche_papers.gatys_ecker_bethge_2016.nst(content_image, style_image, impl_params=True, hyper_parameters=None, quiet=False)

NST from [GEB2016].

Parameters
  • content_image (Tensor) – Content image for the NST.

  • style_image (Tensor) – Style image for the NST.

  • impl_params (bool) – Switch the behavior and hyper-parameters between the reference implementation of the original authors and what is described in the paper. For details see here.

  • hyper_parameters (Optional[HyperParameters]) – If omitted, hyper_parameters() is used.

  • quiet (bool) – If True, no information is logged during the optimization. Defaults to False.

Return type

Tensor

pystiche_papers.gatys_ecker_bethge_2016.preprocessor()
Return type

Module

pystiche_papers.gatys_ecker_bethge_2016.postprocessor()
Return type

Module

pystiche_papers.gatys_ecker_bethge_2016.optimizer(input_image)

Optimizer from [GEB2016].

Parameters

input_image (Tensor) – Image to be optimized.

Return type

LBFGS

pystiche_papers.gatys_ecker_bethge_2016.multi_layer_encoder(impl_params=True)

Multi-layer encoder from [GEB2016].

Parameters

impl_params (bool) – If True, the MaxPool2d in the multi_layer_encoder are exchanged for AvgPool2d.

Return type

MultiLayerEncoder

pystiche_papers.gatys_ecker_bethge_2016.compute_layer_weights(layers, multi_layer_encoder=None)
Return type

Tuple[float, ...]

pystiche_papers.gatys_ecker_bethge_2016.hyper_parameters(impl_params=True)

Hyper parameters from [GEB2016].

Return type

HyperParameters