pystiche.misc

pystiche.misc.get_input_image(starting_point='content', content_image=None, style_image=None)

Generates an input image for NST from the given starting_point.

Parameters
  • starting_point (Union[str, Tensor]) – If Tensor returns a copy. If "content" or "style" returns a copy of content_image or style_image, respectively. If "random" returns a white noise image with the dimensions of content_image or style_image, respectively. Defaults to "content".

  • content_image (Optional[Tensor]) – Content image. Only required if starting_point is "content" or "random".

  • style_image (Optional[Tensor]) – Style image. Only required if starting_point is "style" or "random".

Return type

Tensor

pystiche.misc.get_device(device=None)

Selects a device to perform an NST on.

Parameters

device (Optional[str]) – If str, returns the corresponding device. If None selects CUDA if available and otherwise CPU. Defaults to None.

Return type

device

pystiche.misc.reduce(x, reduction)

Reduces a Tensor as specified.

Parameters
  • x (Tensor) – Input tensor.

  • reduction (str) – Reduction method to be applied to x. If "none", no reduction will be applied. If "sum" or "mean", the sum() or mean() will be applied across all dimensions of x.

Return type

Tensor

pystiche.misc.build_complex_obj_repr(name, properties=None, named_children=(), line_length=80, num_indent=2)
Return type

str