pystiche_papers.ulyanov_et_al_2016
Title |
Texture Networks: Feed-forward Synthesis of Textures and Stylized Images |
Authors |
Dmitry Ulyanov, Vadim Lebedev, Andrea Vedaldi, and Viktor S. Lempitsky |
Citation |
[ULVL2016] / [UVL2017] |
Reference implementation |
|
Variant |
Model optimization |
Content loss |
|
Style loss |
Instance norm
The authors published an improved version [UVL2017] of their initial paper
[ULVL2016] with only a single but significant change: they developed
InstanceNorm2d
and used it as drop-in replacement for
BatchNorm2d
layers. To account for this we provide instance_norm
flag, which defaults to True
.
The original authors also use the same repository for both implementations and only differentiate between them with the branches:
Paper |
Branch |
---|---|
[ULVL2016] |
|
[UVL2017] |
|
Behavioral changes
See also
The following parts are affected:
ConvBlock()
,
level()
,
Transformer()
.
Hyper parameters
See also
Although there are four possible combinations for impl_params
and instance_norm
only three are listed below. Since the hyper-parameters in both papers are equal,
both combinations with ìmpl_params=False
are equal and thus not reported.
content_loss()
Parameter |
|
||
---|---|---|---|
|
|
|
|
|
|
||
|
|
|
|
style_loss()
Parameter |
|
||
---|---|---|---|
|
|
|
|
|
|
|
|
|
|
||
|
|
|
|
content_transform()
Parameter |
Value |
---|---|
|
|
style_transform()
Parameter |
|
||
---|---|---|---|
|
|
|
|
|
|
||
|
|
||
|
|
|
batch_sampler()
Parameter |
|
||
---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
optimizer()
Parameter |
|
||
---|---|---|---|
|
|
|
|
|
|
|
lr_scheduler()
Parameter |
|
||
---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
Miscellaneous
Parameter |
|
||
---|---|---|---|
|
|
|
|
|
|
|
API
- pystiche_papers.ulyanov_et_al_2016.content_transform(impl_params=True, instance_norm=True, hyper_parameters=None)
Content transform from [ULVL2016][UVL2017].
- Parameters
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.instance_norm (
bool
) – Switch the behavior and hyper-parameters between both publications of the original authors. For details see here.hyper_parameters (
Optional
[HyperParameters
]) – Hyper parameters. If omitted,hyper_parameters()
is used.
- Return type
- pystiche_papers.ulyanov_et_al_2016.style_transform(impl_params=True, instance_norm=True, hyper_parameters=None)
Style transform from [ULVL2016][UVL2017].
- Parameters
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.instance_norm (
bool
) – Switch the behavior and hyper-parameters between both publications of the original authors. For details see here.hyper_parameters (
Optional
[HyperParameters
]) – Hyper parameters. If omitted,hyper_parameters()
is used.
- Return type
- pystiche_papers.ulyanov_et_al_2016.images()
Images from [ULVL2016][UVL2017].
- Return type
- pystiche_papers.ulyanov_et_al_2016.dataset(root, impl_params=True, instance_norm=True, transform=None, hyper_parameters=None)
- Return type
- pystiche_papers.ulyanov_et_al_2016.image_loader(dataset, impl_params=True, instance_norm=True, num_workers=0, pin_memory=True, hyper_parameters=None)
- Return type
- pystiche_papers.ulyanov_et_al_2016.content_loss(impl_params=True, instance_norm=True, multi_layer_encoder=None, hyper_parameters=None)
Content loss from [ULVL2016][UVL2017].
- Parameters
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.instance_norm (
bool
) – Switch the behavior and hyper-parameters between both publications of the original authors. For details see here.multi_layer_encoder (
Optional
[MultiLayerEncoder
]) – PretrainedMultiLayerEncoder
. If omitted,multi_layer_encoder()
is used.hyper_parameters (
Optional
[HyperParameters
]) – Hyper parameters. If omitted,hyper_parameters()
is used.
- Return type
- class pystiche_papers.ulyanov_et_al_2016.GramLoss(encoder, impl_params=True, **gram_op_kwargs)
Gram loss from [ULVL2016][UVL2017].
- Parameters
encoder (
Encoder
) – Encoder used to encode the input.impl_params (
bool
) – IfTrue
, normalize the score twice by the batch size.**gram_op_kwargs – Additional parameters of a
pystiche.loss.GramLoss
.
See also
- pystiche_papers.ulyanov_et_al_2016.style_loss(impl_params=True, instance_norm=True, multi_layer_encoder=None, hyper_parameters=None)
Style loss from [ULVL2016][UVL2017].
- Parameters
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.instance_norm (
bool
) – Switch the behavior and hyper-parameters between both publications of the original authors. For details see here.multi_layer_encoder (
Optional
[MultiLayerEncoder
]) – PretrainedMultiLayerEncoder
. If omitted,multi_layer_encoder()
is used.hyper_parameters (
Optional
[HyperParameters
]) – Hyper parameters. If omitted,hyper_parameters()
is used.
- Return type
- pystiche_papers.ulyanov_et_al_2016.perceptual_loss(impl_params=True, instance_norm=True, multi_layer_encoder=None, hyper_parameters=None)
Perceptual loss from [ULVL2016][UVL2017].
- Parameters
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.instance_norm (
bool
) – Switch the behavior and hyper-parameters between both publications of the original authors. For details see here.multi_layer_encoder (
Optional
[MultiLayerEncoder
]) – PretrainedMultiLayerEncoder
. If omitted,multi_layer_encoder()
is used.hyper_parameters (
Optional
[HyperParameters
]) – Hyper parameters. If omitted,hyper_parameters()
is used.
See also
- Return type
- pystiche_papers.ulyanov_et_al_2016.transformer(style=None, impl_params=True, instance_norm=True, levels=6)
Transformer from [ULVL2016][UVL2017].
- Parameters
style (
Optional
[str
]) – Style the transformer was trained on. Can be one of styles given byimages()
. If omitted, the transformer is initialized with random weights.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.instance_norm (
bool
) – Switch the behavior and hyper-parameters between both publications of the original authors. For details see here.levels (
int
) – Number of levels in the transformer. Defaults to6
.
- Return type
Transformer
- pystiche_papers.ulyanov_et_al_2016.training(content_image_loader, style, impl_params=True, instance_norm=True, hyper_parameters=None, quiet=False)
Training a transformer for the NST.
- Parameters
content_image_loader (
DataLoader
) – Content images used as input for thetransformer
.style (
Union
[str
,Tensor
]) – Style image on which thetransformer
should be trained. If the input isstr
, the style image is read fromimages()
.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.instance_norm (
bool
) – Switch the behavior and hyper-parameters between both publications of the original authors. For details see here.hyper_parameters (
Optional
[HyperParameters
]) – Hyper parameters. If omitted,hyper_parameters()
is used.quiet (
bool
) – IfTrue
, not information is logged during the optimization. Defaults toFalse
.
- Return type
- pystiche_papers.ulyanov_et_al_2016.stylization(input_image, transformer, impl_params=True, instance_norm=False, hyper_parameters=None)
Transforms an input image into a stylised version using the transformer.
- Parameters
input_image (
Tensor
) – Image to be stylised.transformer (
Union
[Module
,str
]) – Pretrained transformer for style transfer or string to load a pretrained transformer.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.instance_norm (
bool
) – Switch the behavior and hyper-parameters between both publications of the original authors. For details see here.hyper_parameters (
Optional
[HyperParameters
]) – Hyper parameters. If omitted,hyper_parameters()
is used.
- Return type
- pystiche_papers.ulyanov_et_al_2016.hyper_parameters(impl_params=True, instance_norm=True)
Hyper parameters from [ULVL2016][UVL2017].
- Return type
- pystiche_papers.ulyanov_et_al_2016.multi_layer_encoder()
Multi-layer encoder from [ULVL2016][UVL2017].
- Return type
- pystiche_papers.ulyanov_et_al_2016.preprocessor()
- Return type
CaffePreprocessing
- pystiche_papers.ulyanov_et_al_2016.postprocessor()
- Return type
CaffePostprocessing
- pystiche_papers.ulyanov_et_al_2016.optimizer(transformer, impl_params=True, instance_norm=True, hyper_parameters=None)
Optimizer from [ULVL2016][UVL2017].
- Parameters
transformer (
Module
) – Transformer to be optimized.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.instance_norm (
bool
) – Switch the behavior and hyper-parameters between both publications of the original authors. For details see here.hyper_parameters (
Optional
[HyperParameters
]) – Hyper parameters. If omitted,hyper_parameters()
is used.
- Return type
- pystiche_papers.ulyanov_et_al_2016.lr_scheduler(optimizer, impl_params=True, instance_norm=True, hyper_parameters=None)
Learning rate scheduler from [ULVL2016][UVL2017].
- Parameters
optimizer (
Optimizer
) – Wrapped optimizer.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.instance_norm (
bool
) – Switch the behavior and hyper-parameters between both publications of the original authors. For details see here.hyper_parameters (
Optional
[HyperParameters
]) – Hyper parameters. If omitted,hyper_parameters()
is used.
- Return type