Encoding into Continuous Latent Space and Encoding into Discrete Tokens are two different approaches used in the Cosmos Tokenizer for image and video tokenization.
Encoding into Continuous Latent Space involves representing the input data as a continuous vector in a high-dimensional space. This is typically done using an autoencoder, which consists of an encoder that maps the input data to a lower-dimensional latent space, and a decoder that maps the latent space back to the original input data. The latent space is continuous, meaning that the values in the latent space can take on any value within a certain range.
On the other hand, Encoding into Discrete Tokens involves representing the input data as a sequence of discrete tokens. This is typically done using a quantizer, which maps the input data to a finite set of discrete values. The discrete tokens are often represented as integers, and the quantizer is trained to minimize the difference between the input data and the reconstructed data from the discrete tokens.
The main difference between the two approaches is the nature of the representation. Continuous latent space representations are often more compact and can capture subtle variations in the input data, but they can be more difficult to work with and may require more complex models to generate realistic samples. Discrete token representations, on the other hand, are often more interpretable and can be easier to work with, but they may lose some of the nuance and detail of the original input data.
In the context of the Cosmos Tokenizer, Encoding into Continuous Latent Space is used for the Continuous Image Tokenizer (Cosmos-Tokenizer-CI) and the Continuous Video Tokenizer (Cosmos-Tokenizer-CV), while Encoding into Discrete Tokens is used for the Discrete Image Tokenizer (Cosmos-Tokenizer-DI) and the Discrete Video Tokenizer (Cosmos-Tokenizer-DV).
Here is some sample code that demonstrates the difference between Encoding into Continuous Latent Space and Encoding into Discrete Tokens:
Note that the latent variable in the first example has a shape of (1, 16, 3, 64, 64), which represents a continuous latent space with 16 channels, 3 spatial dimensions, and a spatial resolution of 64x64. In contrast, the indices variable in the second example has a shape of (1, 3, 64, 64), which represents a sequence of discrete tokens with 3 spatial dimensions and a spatial resolution of 64x64. The codes variable has a shape of (1, 6, 3, 64, 64), which represents the pre-quantization continuous latent space with 6 channels, 3 spatial dimensions, and a spatial resolution of 64x64.