Command-line interfaceΒΆ
For simple tasks pystiche
provides a command-line interface (CLI). For example, a
simple NST with the builtin demo images can be performed with:
$pystiche bird1 paint
In version
$pystiche --version
1.1.0.dev45+g4ce30cb
the CLI looks like this:
$pystiche --help
usage: pystiche [-h] [-V] [-v] [-o OUTPUT_IMAGE] [-n NUM_STEPS] [-d DEVICE]
[-s STARTING_POINT]
[--multi-layer-encoder MULTI_LAYER_ENCODER]
[--content-loss CONTENT_LOSS]
[--content-layers CONTENT_LAYERS]
[--content-size CONTENT_SIZE]
[--content-weight CONTENT_WEIGHT] [--style-loss STYLE_LOSS]
[--style-layers STYLE_LAYERS] [--style-size STYLE_SIZE]
[--style-weight STYLE_WEIGHT]
content_image style_image
Performs simple Neural Style Transfers (NSTs) with image optimization. For
more complex tasks, have a look at the Python API at
https://docs.pystiche.org.
positional arguments:
content_image Image containing the content for the style transfer.
Can be a path to an image file or the name of a
pystiche.demo image.
style_image Image containing the style for the style transfer. Can
be a path to an image file or the name of a
pystiche.demo image.
optional arguments:
-h, --help Show this message and exit.
-V, --version Show pystiche's version and exit.
-v, --verbose Print additional information to STDOUT.
-o OUTPUT_IMAGE, --output-image OUTPUT_IMAGE
Path, the output image will be saved to. If omitted,
the output image will be saved to
'pystiche_{timestamp}.jpg' in the current directory.
-n NUM_STEPS, --num-steps NUM_STEPS
Number of optimization steps. Defaults to '500'.
-d DEVICE, --device DEVICE
Device, the optimization is performed on. If
available, defaults to 'cuda' and falls back to 'cpu'
otherwise.
-s STARTING_POINT, --starting-point STARTING_POINT
Starting point of the optimization. Can be 'content'
(default) to start from the content image, 'random' to
start from a white noise image, a path to an image
file, or a name of a pystiche.demo image.
--multi-layer-encoder MULTI_LAYER_ENCODER, --mle MULTI_LAYER_ENCODER
Can be any pretrained multi-layer encoder from
pystiche.enc, e.g. 'vgg19' (default) or 'alexnet'.
Content options:
--content-loss CONTENT_LOSS, --cl CONTENT_LOSS
Can be any comparison loss from pystiche.loss, e.g.
'FeatureReconstruction' (default).
--content-layers CONTENT_LAYERS, --cla CONTENT_LAYERS
Layers of the MULTI_LAYER_ENCODER used to encode the
content representation, e.g. 'relu4_2' (default).
Multiple layers can be given as a comma separated
list.
--content-size CONTENT_SIZE, --cs CONTENT_SIZE
Size in pixels the CONTENT_IMAGE will be resized to
before the optimization, e.g. '500' (default).
--content-weight CONTENT_WEIGHT, --cw CONTENT_WEIGHT
Optimization weight for the CONTENT_LOSS, e.g. '1e0'
(default). Higher values lead to more focus on the
content.
Style options:
--style-loss STYLE_LOSS, --sl STYLE_LOSS
Can be any comparison loss from pystiche.loss, e.g.
'Gram' (default) or 'MRF'.
--style-layers STYLE_LAYERS, --sla STYLE_LAYERS
Layers of the MULTI_LAYER_ENCODER used to encode the
content representation. Multiple layers can be given
as a comma separated list, e.g.
'relu1_1,relu2_1,relu3_1,relu4_1,relu5_1' (default).
--style-size STYLE_SIZE, --ss STYLE_SIZE
Size in pixels the STYLE_IMAGE will be resized to
before the optimization, e.g. '500' (default).
--style-weight STYLE_WEIGHT, --sw STYLE_WEIGHT
Optimization weight for the STYLE_LOSS, e.g. '1e3'
(default). Higher values lead to more focus on the
style.