paraphernalia.torch.direct module

Generate images “directly” i.e. without a latent space.

class Direct(start=None, scale=1, **kwargs)[source]

A direct generator i.e. a directly trainable RGB tensor.

Initialize a direct generator.

Individual pixels in the latent space are upscaled via scale. If greater than the default of 1, this yields a pixel-art effect.

Parameters
  • start ([type], optional) – [description]. Defaults to None.

  • scale (int, optional) – Pixel size. Defaults to 1.

forward()[source]

Generate a batch of images.

class DirectPalette(start=None, colors=[(0.1, 0.1, 0.1), (0.6, 0.1, 0.1), (1.0, 0.1, 0.1), (0.9, 0.9, 0.9)], scale=1, **kwargs)[source]

A palettized generator using gumbel sampling versus a provided palette.

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

forward(tau=None, hard=None)[source]

Generate a batch of images.

encode(img)[source]

Encode an image or tensor.

Parameters

img (Union[PIL.Image.Image, torch.Tensor]) –

class DirectTileset(atlas=None, scale=1, **kwargs)[source]

A generator using gumbel sampling versus a provided tile atlas.

Suggested learning rate: 0.8

Initialize a discrete direct tileset generator.

Parameters

atlas (Tensor) – TODO

Raises

ValueError – if the atlas is the wrong size

forward(tau=None, hard=None)[source]

Generate a batch of images.