paraphernalia.torch.generator module

Base class and utility types for image generators.

class Generator(batch_size=1, size=512, quantize=1, device=None, start=None)[source]

Base class for (image) generators.

Parameters
  • batch_size (int, optional) – The number of images per batch. Defaults to 1.

  • size (Union[int, Tuple[int, int]], optional) – The size of the image either a (width, height) tuple or a single size for a square image. Defaults to 512.

  • quantize (int, optional) – Model-specific quantizing. Defaults to 1.

  • device (Optional[Union[str, torch.device]], optional) – The device name or device on which to run. Defaults to None.

Raises

ValueError – if any parameter is invalid

property width: int

The width of the generated image.

property height: int

The height of the generated image.

property z: torch.Tensor

The latent tensor associated with this model.

Often but not always (b, c, h, w).

generate_image(index=None, **kwargs)[source]

Convenience to generate a single PIL image (which may be a grid of images if batch_size > 1) within a no_grad() block.

Parameters

index (int) – Specify which image of a batch to generate

Returns

A generated image

Return type

Image