paraphernalia.torch.taming module

Generate images with Taming Transformers.

See also:

clamp_with_grad()
class TamingModel(name, config_url, checkpoint_url, is_gumbel, scale)[source]

Specification for a published Taming Transformers model.

Parameters
  • name (str) –

  • config_url (str) –

  • checkpoint_url (str) –

  • is_gumbel (bool) –

  • scale (int) –

Return type

None

name: str

Slug for this model e.g. vqgan_gumbel_f8

config_url: str

URL of the associated config.yaml

checkpoint_url: str

URL of the associated checkpoint file

is_gumbel: bool

True iff this is a discrete model

scale: int

Generated pixels per latent space pixel

class Taming(model_spec=TamingModel(name='vqgan_imagenet_f16_16384', config_url='https://heibox.uni-heidelberg.de/d/a7530b09fed84f80a887/files/?p=%2Fconfigs%2Fmodel.yaml&dl=1', checkpoint_url='https://heibox.uni-heidelberg.de/d/a7530b09fed84f80a887/files/?p=%2Fckpts%2Flast.ckpt&dl=1', is_gumbel=False, scale=16), start=None, **kwargs)[source]

Image generator based on a Taming Transformers model.

Parameters
  • model_spec (TamingModel, optional) – Defaults to VQGAN_IMAGENET_F16_16384.

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

forward(z=None)[source]

Generate a batch of images.

Returns

An image batch tensor

Return type

Tensor

encode(img)[source]

Encode an image.

Parameters

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

Return type

torch.Tensor