pystiche.pyramid
¶
Image pyramid¶
- class pystiche.pyramid.ImagePyramid(edge_sizes, num_steps, edge='short', interpolation_mode='bilinear', resize_targets=())¶
Image pyramid for a coarse-to-fine optimization on different levels. If iterated on yields
PyramidLevel
s and handles the resizing of all set images and guides ofresize_targets
.- Parameters
num_steps (
Union
[Sequence
[int
],int
]) – Number of steps for each level. If sequence ofint
its length has to match the length ofedge_sizes
.edge (
Union
[Sequence
[str
],str
]) – Corresponding edge to the edge size for each level. Can be"short"
or"long"
. If sequence ofstr
its length has to match the length ofedge_sizes
. Defaults to"short"
.interpolation_mode (
str
) –Interpolation mode used for the resizing of the images. Defaults to
"bilinear"
.Note
For the resizing of guides
"nearest"
is used regardless of theinterpolation_mode
.resize_targets (
Collection
[Loss
]) – Targets for resizing of set images and guides during iteration.
- class pystiche.pyramid.OctaveImagePyramid(max_edge_size, num_steps, num_levels=None, min_edge_size=64, **image_pyramid_kwargs)¶
Bases:
pystiche.pyramid.pyramid.ImagePyramid
Image pyramid that comprises levels spaced by a factor of two.
- Parameters
max_edge_size (
int
) – Maximum edge size.num_steps (
Union
[int
,Sequence
[int
]]) –Number of steps for each level.
Note
If
num_steps
is specified as sequence ofint``s, you should also specify ``num_levels
to match the lengthsnum_levels (
Optional
[int
]) – Optional number of levels. IfNone
, the number is determined by the number of steps of factor two betweenmax_edge_size
andmin_edge_size
.min_edge_size (
int
) – Minimum edge size for the automatic calculation ofnum_levels
.image_pyramid_kwargs (
Any
) – Additional options. SeeImagePyramid
for details.
Pyramid level¶
- class pystiche.pyramid.PyramidLevel(edge_size, num_steps, edge)¶
Level with an
pystiche.pyramid.ImagePyramid
. If iterated on, yields the step beginning at 1 and ending innum_steps
.- Parameters
- resize_guide(guide, aspect_ratio=None, interpolation_mode='nearest')¶
Resize a guide to the
edge_size
on the correspondingedge
of thePyramidLevel
.
- resize_image(image, aspect_ratio=None, interpolation_mode='bilinear')¶
Resize an image to the
edge_size
on the correspondingedge
of thePyramidLevel
.- Parameters
Warning
The resizing is performed without gradient calculation. Do not use this if the image needs a gradient.
- Return type