Vector quantized image modeling
The ViT-VQGAN approach enhances image generation and understanding by using vision transformers for efficient encoding and decoding, addressing scalability and quality issues in existing methods, achieving superior performance with lower resource consumption.
Patent Information
- Application Number
- JP2024520749
- Authority / Receiving Office
- JP · JP
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2022-06-10
- Filing Date
- 2022-10-05
- Publication Date
- 2024-10-10
- Estimated Expiration
- 2042-10-05
AI Technical Summary
Existing image generation techniques face limitations in expressive capabilities due to high memory consumption and computational requirements, especially when scaling to larger image resolutions, and lack effective methods for generating high-quality images from text.
A vector quantized image modeling approach using vision transformers (ViT-VQGAN) for efficient image encoding and decoding, combined with improved codebook handling, enables better reconstruction fidelity and computational efficiency, allowing for high-resolution image generation and understanding.
The proposed method achieves significant improvements in image generation quality, as evidenced by lower Fréchet Inception Distance (FID) scores and higher Inception Score (IS), outperforming existing models with reduced computational resources.
Smart Images

Figure 2024537148000001_ABST
Abstract
Description
[Technical field]
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS This application claims priority to and the benefit of U.S. Provisional Patent Application No. 63 / 351,131, filed June 10, 2022, and U.S. Provisional Patent Application No. 63 / 252,452, filed October 5, 2021. Each of the above-mentioned applications is hereby incorporated by reference in its entirety.
[0002] The present disclosure relates generally to image modeling, such as image synthesis and / or image generation. More specifically, the present disclosure relates to vector quantized image modeling using vision transformers and improved codebook handling. [Background technology]
[0003] In computer vision, most recent unsupervised or self-supervised learning techniques focus on pre-training images with different random augmentations in order to distinguish image instances, and the quality of the learned representation relies on hand-picked augmentations such as random brightness, cropping, blurring, etc.
[0004] Certain other approaches apply GPT-style generative pre-training to images to autoregressively predict pixels without incorporating knowledge of the 2D structure, where the pixels are 9-bit values generated by clustering (R,G,B) pixel values using k-means with k=512. However, color encoding does not scale to typical image resolutions due to much longer sequence lengths (e.g., 224x224 resolution results in 50176 tokens per image) and much larger memory consumption and training computations than those of language models. As a result, these works can only be applied at scale to a relatively small maximum resolution for image recognition (e.g., 64x64), which severely limits the expressive power.
[0005] On the other hand, notable image generation results have been achieved by pre-quantizing images into discrete latent variables and modeling them autoregressively, including VQVAE (Oord et al., 2017), DALL-E (Ramesh et al., 2021) and VQGAN (Esser et al., 2021). In these methods, a convolutional neural network (CNN) is trained to auto-encode the image, and a second-stage CNN or transformer is trained to model the density of the input data. Although these have proven effective for image generation, studies have not evaluated the learned representations in feature-based tasks.
[0006] One subfield of image generation is image-from-text generation, where an image is synthesized based on an input text, and the synthesized image depicts the content described by the input text. The ability to generate images through language is appealing because language is the most natural form of communication, and such generative capabilities can potentially unlock creative applications in many fields, such as art, design, and multimedia content creation. One line of research that has recently gained momentum in the text-to-image generation space is techniques that leverage diffusion-based text-to-image models that have the ability to generate higher fidelity images. These models eschew the use of individual image tokens as the core modeling technique for image stilling, and instead use diffusion models to achieve better zero-shot Fréchet Inception Distance (FID) scores and aesthetically pleasing visual output for MS-COCO. Despite these advances, the ability to apply autoregressive modeling to the task of text-to-image generation remains appealing in practice, given the rich body of prior work on large-scale language models and generic interfaces for individual tokens that are easily applicable to more modalities. Summary of the Invention [Means for solving the problem]
[0007] Aspects and advantages of embodiments of the disclosure will be set forth in part in the description that follows, or may be learned from the description, or may be learned by practice of the embodiments.
[0008] One exemplary aspect of the present disclosure is directed to a computer-implemented method of performing vector quantization of an image. The method includes obtaining, by a computing system having one or more computing devices, a plurality of input image patches of the image. The method includes processing, by the computing system, the plurality of input image patches with a machine-learned image encoder to generate a plurality of image tokens in a latent space, where the plurality of image tokens correspond to the plurality of input image patches, and the machine-learned image encoder performs one or more self-attention operations to process the plurality of input image patches to generate a plurality of image tokens in the latent space. The method includes mapping, by the computing system, the plurality of image tokens to a plurality of quantization codes included in a quantization codebook including a plurality of candidate codes. The method includes providing, by the computing system, the plurality of quantization codes as an encoded version of the image.
[0009] In some implementations, the machine-learned image encoder comprises a vision transformer model.
[0010] In some implementations, the machine-learned image encoder performs one of one or more self-attention operations on multiple input image patches.
[0011] In some implementations, the method further includes processing, by the computing system, the plurality of quantized codes with a machine-learned image decoder to generate a plurality of composite image patches that form a composite image; evaluating, by the computing system, a loss function that provides a loss value based at least in part on the composite image; and modifying, by the computing system, one or more of the machine-learned image encoder, the machine-learned image decoder, and the plurality of candidate codes based at least in part on the loss function.
[0012] In some implementations, the machine learning image decoder comprises a vision transformer model.
[0013] In some implementations, the loss function includes a logit-Laplace loss term, an L2 loss term, a perceptual loss term, and / or a generative adversarial network loss term.
[0014] In some implementations, the step of mapping, by a computing system, a plurality of image tokens to a plurality of quantization codes included in a quantization codebook including a plurality of candidate codes includes a step of projecting, by the computing system, the plurality of image tokens into a lower-dimensional space, and after the step of projecting the image tokens into the lower-dimensional space, a step of mapping, by the computing system, the plurality of image tokens to a plurality of quantization codes included in the quantization codebook.
[0015] In some implementations, the step of mapping, by a computing system, a plurality of image tokens to a plurality of quantization codes included in a quantization codebook including a plurality of candidate codes includes a step of applying, by the computing system, an L2 regularization to one or both of the plurality of image tokens and the plurality of candidate codes, and a step of mapping, by the computing system, after the step of applying the L2 regularization, the plurality of image tokens to a plurality of quantization codes included in the quantization codebook.
[0016] In some implementations, the method further includes autoregressively predicting, by the computing system using a machine-learned code prediction model, a plurality of predicted codes from a quantization codebook based at least in part on one or more of the plurality of quantization codes, and processing, by the computing system, the plurality of predicted codes with a machine-learned image decoder to generate a plurality of synthetic image patches that form a synthetic image.
[0017] In some implementations, the method further includes evaluating, by the computing system, a chord prediction loss function that evaluates a negative log-likelihood based on the plurality of predicted chords; and altering, by the computing system, one or more parameters of the machine-learned chord prediction model based on the chord prediction loss function.
[0018] In some implementations, autoregressively predicting a plurality of predicted chords by the computing system using the machine-learned chord prediction model includes conditioning, by the computing system, the machine-learned chord prediction model with auxiliary conditioning data that describes one or more desired characteristics of the composite image.
[0019] In some implementations, the auxiliary conditioning data includes class labels that describe a desired class of the synthetic image.
[0020] In some implementations, the auxiliary conditioning data includes natural language text tokens.
[0021] In some implementations, the method further includes extracting, by the computing system, one or more intermediate features from the machine-learned code prediction model, and predicting, by the computing system, a class label for the image based at least in part on the intermediate features.
[0022] Another exemplary aspect is directed to a computer-implemented method for performing vector quantization of an image. The method includes obtaining, by a computing system including one or more computing devices, a plurality of quantization codes forming an encoded version of the image, where the plurality of quantization codes are selected by mapping a plurality of image tokens generated by a machine-learned image encoder model to a plurality of quantization codes included in a quantization codebook including a plurality of candidate codes. The method includes processing, by the computing system, the plurality of quantization codes with a machine-learned image decoder to generate a plurality of decoded image patches forming a decoded version of the image. In some implementations, one or both of the machine-learned image encoder model and the machine-learned image decoder are configured to perform one or more self-attention operations.
[0023] Another exemplary aspect is directed to a computer system comprising one or more processors and one or more non-transitory computer-readable media that collectively store instructions that, when executed by the one or more processors, cause the one or more processors to perform any of the methods described herein.
[0024] Another exemplary aspect is directed to one or more non-transitory computer-readable media that collectively store instructions that, when executed by one or more processors, cause the one or more processors to perform any of the methods described herein.
[0025] Another exemplary aspect is directed to a computer system comprising one or more processors and one or more non-transitory computer-readable media collectively storing a machine-learned image processing model comprising an encoder configured to encode one or more input image patches into one or more image tokens in a latent space, a quantizer configured to quantize the one or more image tokens into one or more quantization codes selected from a codebook, a code predictor configured to predict one or more predicted quantization codes from the codebook based at least in part on the one or more quantization codes, and a feature predictor configured to generate one or more feature predictions for the input image patch based at least in part on data extracted from the code predictor.
[0026] In some implementations, the machine-learned image processing model further includes a decoder unit configured to generate a reconstructed image patch based on one or more quantization codes, or to generate a synthetic image patch based at least in part on one or more predicted quantization codes.
[0027] In some implementations, the one or more characteristic predictions include an image classification prediction.
[0028] Another exemplary aspect is directed to a computer-implemented method for performing image generation from text. The method includes obtaining, by a computing system comprising one or more computing devices, a natural language input describing desired image content. The method includes processing, by the computing system, the natural language input with a text encoder portion of a machine-learned code prediction model to generate a text embedding. The method includes processing, by the computing system, the text embedding with an autoregressive code selection portion of a machine-learned code prediction model to autoregressively predict a sequence of predicted codes from a quantized codebook including a plurality of candidate codes. The method includes processing, by the computing system, the sequence of quantized codes with a machine-learned image decoder to generate a plurality of synthetic image patches forming a synthetic image. The synthetic image depicts the desired image content.
[0029] In some implementations, one or more of the text encoder portion of the machine-learned chord prediction model, the autoregressive chord selection portion of the machine-learned chord prediction model, and the machine-learned image decoder are configured to perform one or more self-attention operations.
[0030] In some implementations, one or more of the text encoder portion of the machine-learned chord prediction model, the autoregressive chord selection portion of the machine-learned chord prediction model, and the machine-learned image decoder comprise a Transform Neural Network.
[0031] In some implementations, the machine-learned image decoder and / or the codebook are jointly trained with the image encoder model.
[0032] In some implementations, the text encoder portion of the machine-learned chord prediction model is pre-trained on a pre-training task.
[0033] Another exemplary aspect is directed to a computer-implemented method for training a code prediction model. The method includes obtaining, by a computing system comprising one or more computing devices, training examples including training images and natural language input describing content of the training images. The method includes processing, by the computing system, a plurality of image patches from the training images with a machine-learned image encoder to generate a plurality of image tokens in a latent space, where the plurality of image tokens correspond to the plurality of image patches. The method includes mapping, by the computing system, the plurality of image tokens to a plurality of quantized codes included in a quantized codebook including a plurality of candidate codes. The method includes processing, by the computing system, the natural language input with a text encoder portion of the code prediction model to generate a text embedding. The method includes processing, by the computing system, the text embedding with an autoregressive code selection portion of the code prediction model to autoregressively predict a sequence of predicted codes from the quantized codebook. The method includes evaluating, by the computing system, a code prediction loss function that compares the predicted sequence of codes to the plurality of quantized codes. The method includes modifying, by the computing system, one or more parameters of the code prediction model based at least in part on the code prediction loss function.
[0034] In some implementations, a machine-learned image encoder performs one or more self-attention operations to process a number of input image patches and generate a number of image tokens in a latent space.
[0035] In some implementations, the code prediction loss function evaluates the negative log-likelihood of a predicted code relative to a quantized code.
[0036] In some implementations, the machine-learned image encoder and codebook are pre-trained with the image decoder in an autoencoder architecture.
[0037] In some implementations, altering, by the computing system, one or more parameters of the chord prediction model based at least in part on the chord prediction loss function includes altering, by the computing system, one or more parameters of both a text encoder portion and an autoregressive chord selection portion of the chord prediction model based at least in part on the chord prediction loss function.
[0038] Other aspects of the present disclosure are directed to various systems, apparatus, non-transitory computer-readable media, user interfaces, and electronic devices.
[0039] These and other features, aspects, and advantages of various embodiments of the present disclosure will become better understood with reference to the following description and appended claims. The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate exemplary embodiments of the present disclosure, together with a description that helps explain the relevant principles.
[0040] A detailed discussion of embodiments directed to those skilled in the art is described herein, which makes reference to the accompanying drawings. [Brief description of the drawings]
[0041] [Figure 1] FIG. 1 illustrates an example machine learning model for performing vector quantization of an image, according to an example embodiment of the present disclosure. [Diagram 2] FIG. 1 depicts an exemplary machine learning model for performing image generation according to an exemplary embodiment of the present disclosure. [Diagram 3] FIG. 1 depicts an exemplary machine learning model for performing image generation according to an exemplary embodiment of the present disclosure. [Figure 4] FIG. 1 depicts an exemplary machine learning model for performing image generation according to an exemplary embodiment of the present disclosure. [Diagram 5]1 is a schematic diagram illustrating an approach for performing image generation from text according to an exemplary embodiment of the present disclosure. [Figure 6] FIG. 1 illustrates an example approach to scaling model training, according to an example embodiment of the present disclosure. [Figure 7] FIG. 1 depicts an exemplary model parallel processing approach according to an exemplary embodiment of the present disclosure. [Figure 8A] FIG. 1 is a block diagram illustrating an exemplary computing system according to an exemplary embodiment of the present disclosure. [Figure 8B] FIG. 1 is a block diagram illustrating an exemplary computing device according to an exemplary embodiment of the present disclosure. [Figure 8C] FIG. 1 is a block diagram illustrating an exemplary computing device according to an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0042] Reference numerals that are repeated among the figures are intended to identify like features in various implementations.
[0043] overview In general, the present disclosure is directed to vector quantized image modeling using a vision transformer and improved codebook handling. In particular, the present disclosure provides a vector quantized image modeling (VIM) technique that includes pre-training a machine learning model (e.g., a transformer model) to autoregressively predict rasterized image tokens. Individual image tokens can be encoded from a learned vision transformer-based VQGAN (an exemplary implementation of which can be referred to as ViT-VQGAN). The present disclosure proposes multiple improvements over vanilla VQGAN, from architecture to codebook learning, resulting in better efficiency and reconstruction fidelity. The improved ViT-VQGAN further improves vector quantized image modeling tasks, including unconditional image generation, conditional image generation (e.g., class-conditional image generation), and unsupervised representation learning.
[0044] The exemplary experiments demonstrate the technical effect of the proposed technique. In particular, when training on ImageNet with 256x256 resolution, the exemplary implementation of the present disclosure achieves an initiation score (IS) of 175.1 and a Frechet initiation distance (FID) of 4.17, which is a dramatic improvement over vanilla VQGAN, which obtains 70.6 and 17.04 in IS and Fréchet initiation distance (FID), respectively. Based on ViT-VQGAN and unsupervised pre-training, the exemplary experiments further evaluate the pre-trained transformer by averaging intermediate features similar to Image GPT (iGPT). This ImageNet pre-trained VIM-L significantly outperforms iGPT-L in terms of linear probe accuracy, from 60.3% to 72.1%, with similar model sizes. ViM-L also outperforms iGPT-XL, which is trained with additional web image data and larger model sizes.
[0045] Another exemplary aspect of the present disclosure is directed to the application of the proposed vector quantization image model to the task of image generation from text. Specifically, the present disclosure provides an autoregressive model capable of generating photorealistic images from text descriptions, with distinct advantages over diffusion-based approaches. An exemplary implementation of these models can be called "Babeldraw". In some implementations, Babeldraw uses an improved image tokenizer, the transformer-based ViT-VQGAN described herein, to encode images as a sequence of distinct tokens. This naturally reduces the task at hand to the well-known problem of machine translation from text to image tokens. Consistent quality improvements are obtained by scaling the second, encoder-decoder transformer parameters from 350M and 750M to 3B and 20B. Compared to recent diffusion-based models, our 20B Babeldraw model achieves a comparable zero-shot MS-COCO Fréchet Inception Distance (FID) score of 7.31 and an unprecedented FID score of 4.03 when fine-tuned on the MS-COCO training split. Using a post-super-resolution upsampler trained on a frozen 256x256 image tokenizer, Babeldraw reliably produces high-resolution photorealistic images.
[0046] Thus, example implementations of the present disclosure relate to vector quantization image modeling (VIM) methods for both image generation and image understanding tasks. Specifically, some example implementations follow the following two-stage approach:
[0047] Stage 1: Vector Quantization. Given an image (e.g., of resolution 256x256), the Vision Transformer-based VQGAN encodes it into several discretized latent codes (e.g., 32x32) contained in a codebook (e.g., the codebook size may be 8192). This disclosure proposes multiple improvements on VQGAN (Esser et al., 2021), from architecture to codebook learning. The resulting ViT-VQGAN has better efficiency and reconstruction fidelity in terms of pixel-wise reconstruction measures, initiation score (IS), and Fréchet initiation distance (FID). ViT-VQGAN can be trained exhaustively on image-only data with a combined objective function of logit-Laplace loss, L2 loss, adversarial loss, and / or perceptual loss.
[0048] Stage 2: Vector Quantization Image Modeling. Some example implementations can include training a transformer model to autoregressively predict rasterized (e.g., 32x32=1024) image tokens, which are encoded by the frozen stage 1 ViT-VQGAN. In unconditional image synthesis or unsupervised learning, a decoder-only transformer model can be trained to predict the next token. In conditional image synthesis (e.g., class-conditional image synthesis), conditioning data (e.g., class id token) can be prepended to all image tokens.
[0049] To assess the quality of the unsupervised learning, intermediate Transformer features can be extracted (and averaged) and a linear head can be trained to predict the class logits (also known as linear probe accuracy).
[0050] One key component to improve both image generation and image understanding in VIM is to have a better image quantizer in terms of computational efficiency and reconstruction quality. An efficient quantizer can speed up the training of stage 2, where random augmentation is first applied to the image and then to the image quantizer encoder as input tokens. Furthermore, an image quantizer with better reconstruction quality can potentially reduce information loss compared to the original image in pixel space, which is important for image understanding tasks.
[0051] Further exemplary aspects of the present disclosure are directed to an autoregressive image generation model that can generate photorealistic images from text descriptions. The autoregressive model provided herein can benefit from a better image tokenizer and also from model scaling. More specifically, the present disclosure provides a transformer-based sequence-to-sequence model for image generation (an exemplary implementation of which can be called "Babeldraw"). The image generation model can take tokenized text tokens as input to the encoder and predict individual image tokens using a decoder in an autoregressive manner. The image tokens can, in some examples, generate better models than VQGAN in terms of efficiency and image reconstruction fidelity by the transformer-based ViT-VQGAN image tokenizer described herein.
[0052] In some implementations, all components of the image generation model, i.e., encoder, decoder, and image tokenizer, may be based on standard transformer models. This makes it easy to scale the model. To test the limits of the above two-stage text-to-image framework, the parameter size of the exemplary Babeldraw model was scaled from 350M to 750M, 3B, and 20B, and quality improvements were observed in terms of both text-image alignment and image photorealism. The 20B Babeldraw model achieves a strong zero-shot FID score of 7.31, which is comparable to state-of-the-art diffusion-based models. Remarkably, when fine-tuned on MS-COCO, the exemplary Babeldraw model achieves an unprecedented low FID score of 4.07.
[0053] While most of the work sticks to the MS-COCO benchmark, exemplary experiments show that we can still achieve strong zero-shot and fine-tuned results on a dataset of localized annotations, which on average have 4x longer descriptions than MS-COCO. These results clearly demonstrate the strong generalization ability of the proposed model to longer descriptions.
[0054] Thus, this disclosure achieves several contributions on image generation from text. First, it is understood that for two-stage image generation from text models, the image tokenizer is one of the key factors, which is directly related to the image quality of the generated image. Second, a simple scaling encoder-decoder using the exact same image tokenizer and training data is effective for image generation from text. Third, a text encoder pre-trained only with BERT provides a mild aid to natural language understanding for image-to-text systems. The text encoder fine-tuned on image generation from text has worse results in language understanding tasks, suggesting a potential gap between general language understanding and vision-based language understanding.
[0055] The disclosed system and method provide several technical effects and advantages. As an example, the proposed technique can achieve comparable results to current state-of-the-art models (e.g., iGPT) for certain tasks (e.g., image recognition with generative pre-training), but with smaller models and less data. By enabling the use of smaller models with less data (while obtaining comparable results), the consumption of computing resources such as processor usage, memory usage, network bandwidth, etc. is reduced. Thus, the proposed technique saves computing resources and improves computer functionality.
[0056] As another example, exemplary implementations of the present disclosure have superior efficiency and reconstruction fidelity in terms of pixel-wise reconstruction measures, Initiation Score (IS) and Frechet Initiation Distance (FID), over existing models. Thus, the present disclosure represents an improvement in the ability to encode image data into a coded representation. Coded data has numerous advantages, including savings in memory space and network bandwidth. The present disclosure enables a system to encode an image to achieve such advantages, while reducing the data loss experienced when decoding the image into a decoded image.
[0057] As another exemplary technical effect and advantage, the present disclosure provides an improved image generation and image understanding using VIM by providing an improved image quantizer in terms of computational efficiency and reconstruction quality. An efficient quantizer can speed up the training of stage 2, where random augmentation is first applied to the image and then to the encoder of the image quantizer as input tokens. The faster training speed results in savings in computing resources, such as processor usage, memory usage, and / or network bandwidth usage. Furthermore, an image quantizer with better reconstruction quality can potentially reduce information loss compared to the original image in pixel space, which is important for image understanding tasks. Thus, the computational performance of image understanding tasks can be improved.
[0058] Referring now to the figures, exemplary embodiments of the present disclosure will be discussed in further detail.
[0059] Exemplary Stage 1 Techniques FIG. 1 depicts a diagram of an exemplary machine learning model for performing vector quantization of an image according to an exemplary embodiment of the present disclosure.
[0060] Specifically, as shown in FIG. 1, a computing system may obtain a number of input image patches 12 of an image 14 .
[0061] The computing system may process a plurality of input image patches 12 with a machine learning image encoder 16 to generate a plurality of image tokens 18 in a latent space. The plurality of image tokens 18 may correspond to the plurality of input image patches 12. The machine learning image encoder 16 may perform one or more self-attention operations to process the plurality of input image patches 12 to generate a plurality of image tokens 18 in a latent space.
[0062] The computing system may map the multiple image tokens 18 to multiple quantized codes 20 contained in a quantized codebook 22 that includes multiple candidate codes. The computing system may provide the multiple quantized codes 20 as an encoded version of the image.
[0063] Further, in some implementations, a computing system (i.e., a computing device of the same or different components) may process multiple quantization codes 20 with a machine-learned image encoder 24 to generate multiple composite image patches 26 that form a composite image 28.
[0064] The computing system can evaluate a loss function 30 that provides a loss value based at least in part on the synthetic image. The loss function can include a logit-Laplace loss term, an L2 loss term, a perceptual loss term, and / or a generative adversarial network loss term (e.g., a GAN evaluation is specifically illustrated at 30, while others are not illustrated).
[0065] The computing system may modify one or more of the machine-learned image encoder 16, the machine-learned image decoder 24, and the plurality of candidate codes 22 based at least in part on the loss function.
[0066] In some implementations, mapping the image tokens 18 to the quantization codes 20 may include projecting the image tokens 18 into a lower dimensional space and, after projecting the image tokens 18 into the lower dimensional space, mapping the image tokens to the quantization codes included in a quantization codebook. The quantization codes 20 may then be reprojected back into a higher dimensional space before processing by the decoder 24.
[0067] In some implementations, the step of mapping the multiple image tokens 18 to the multiple quantization codes 20 may include applying L2 regularization to one or both of the multiple image tokens 18 and the multiple candidate codes in the codebook 22, and after applying the L2 regularization, mapping the multiple image tokens 18 to the multiple quantization codes 20 included in the quantization codebook 22.
[0068] Exemplary Stage 2 Techniques FIG. 2 depicts a diagram of an exemplary machine learning model for performing vector quantization of an image according to an exemplary embodiment of the present disclosure.
[0069] Specifically, as shown in FIG. 2, a computing system may obtain one or more input image patches 212 of an image 214 .
[0070] The computing system may process one or more input image patches 212 with a machine learning image encoder 216 to generate one or more image tokens 218 in a latent space. The one or more image tokens 218 may correspond to one or more input image patches 212. The machine learning image encoder 216 may perform one or more self-attention operations to process the one or more input image patches 212 to generate one or more image tokens 218 in a latent space. For example, the machine learning image encoder 216 may have been trained or learned according to the process illustrated in FIG. 1.
[0071] The computing system can map one or more image tokens 218 to one or more quantization codes 220 contained in a quantization codebook 222 that includes a plurality of candidate codes. For example, the quantization codebook 222 can have been trained according to the process shown in FIG.
[0072] Further, in some implementations, a computing system (i.e., a computing device of the same or different components) may process one or more quantized codes 220 with a machine-learned code prediction model 224 to autoregressively predict a number of predicted codes 226 from a quantized codebook 222 based at least in part on the one or more quantized codes 220.
[0073] The computing system can process the plurality of predicted codes 226 with a machine learning image decoder 228 to generate a plurality of composite image patches 230 that form a composite image 232.
[0074] In some implementations or cases, the computing system may further evaluate a code prediction loss function that evaluates a negative log-likelihood based on the multiple predicted codes 226. The computing system may modify one or more parameters of the machine-learned code prediction model 224 based on the code prediction loss function. For example, the code prediction model 224 may be trained to learn the distribution of tokens across a corpus of images, e.g., using the code prediction loss function.
[0075] In some implementations, during training and / or inference, the machine-learned code prediction model 224 can be conditioned with auxiliary conditioning data that describes one or more desired characteristics of the synthetic image. As one example, the auxiliary conditioning data can include a class label that describes a desired class of the synthetic image 232. For example, in FIG. 2, the model 224 can be conditioned with a label of [Cat] such that the synthetic image 232 depicts a cat, but the synthetic image 232 shares visual characteristics with the image 214. As another example, the auxiliary conditioning data can include natural language text tokens and / or any other conditioning data that provides a preference for image synthesis.
[0076] 2 shows an example approach in which the image generation process is conditioned on both patches 212 from an input image 214 and also on text input (e.g., class labels). However, in some implementations, image generation can be conditioned on text alone. For example, FIG. 3 illustrates an example in which the generation of a synthetic image 332 is conditioned on the natural language input 334 of "angry cat." For example, the natural language input 334 can be converted into tokens and then provided as an input to the code prediction model 224.
[0077] According to aspects of the disclosure, in some implementations that include text conditioning and / or perform image generation tasks from text, the chord prediction model 224 can include a text encoder that generates text to embed from text input.
[0078] 4 illustrates an exemplary image generation approach in which the code prediction model 224 includes a text encoder 402 and an autoregressive code selector 404. The text encoder 402 can receive the input text 334 and generate a text embedding 406. The text embedding 406 can be provided as an input to the autoregressive code selector 404. For example, the text embedding 406 can be provided as an initial prompt token to the autoregressive code selector 404.
[0079] In some implementations, one or both of the text encoder 402 and the autoregressive code selector 404 can be or include a transformer model or other model that implements self-attention. In some implementations, the text encoder can be pre-trained (e.g., using a masked language modeling pre-training technique, a contrastive learning technique, and / or other pre-training technique). In some implementations, the parameters of the text encoder 402 and the autoregressive code selector 404 can be trained together (e.g., using a code prediction loss function) to learn the distribution of tokens over a set of text and image training examples, each of which includes a text and image pair.
[0080] Example Vector Quantization Image in ViT-VQGAN Vector Quantized Variational Autoencoder (VQVAE) is a CNN-based autoencoder whose latent space is a matrix of discrete learnable variables and is trained exhaustively by straight-through estimation. VQGAN is a model that improves VQVAE by introducing an adversarial loss generated by a discriminator. Herein, further improvements to VQGAN are realized that improve efficiency and enhance reconstruction quality.
[0081] Example VQGAN with Vision Transformer The core network architecture used by both VQVAE and VQGAN to encode and reconstruct images is CNN. VQGAN introduces a transformer-like element in the form of a non-localized attention block, allowing it to capture distance interactions with fewer layers. An exemplary implementation of this disclosure goes one step closer by replacing the CNN encoder and decoder with a vision transformer (ViT). Given sufficient data (with a lot of unlabeled image data), it is found that ViT-VQGAN is less constrained by the inductive prior imposed by convolutions. Furthermore, ViT-VQGAN brings better computational efficiency to the accelerator and produces higher quality reconstructions, as shown in Table 1 below.
[0082] [Table 1]
[0083] Throughput is benchmarked on the same 128 CloudTPUv4 device.
[0084] An exemplary encoder for ViT-VQGAN first maps 8x8 non-overlapping image patches to image tokens, then a transformer block encodes the 256x256 resolution image into a sequence of 32x32=1024 tokens. An exemplary decoder performs the inverse operation, mapping each image token back from the latent variables to 8x8 image patches and regrouping them into a 256x256 image. In some implementations, a two-layer feedforward network with a tanh activation layer in between is applied at the output of the transformer block. In some implementations, no activations are applied to the output of the ViT-VQGAN encoder or decoder (except for the mean prediction of the logit-Laplace loss). In some implementations, a sigmoid activation is applied to the mean prediction of the decoder due to the logit-Laplace loss. This exemplary approach results in high-quality reconstructions without visible lattice artifacts.
[0085] Exemplary Codebook Training Vanilla VQVAE usually suffers from low codebook usage due to insufficient initialization of the codebook. Thus, during training, a significant portion of the codes are rarely used or invalid. A reduced effective codebook size leads to worse reconstruction in stage 1 quantizer training and poor versatility in stage 2 image synthesis. As a result, VQGAN relies on top-k and top-p (kernel) sampling heuristics with a default codebook size of 1024 to achieve the best results in image synthesis. The exemplary implementation of the present disclosure includes two improvements that can significantly aid codebook usage, even with a larger codebook size of 8192. During image synthesis, the exemplary implementation implements simple sampling at a temperature of 1.0 without top-k and top-p heuristics.
[0086] One exemplary training objective for vector quantization is defined as follows:
[0087]
number
[0088] Where:
[0089]
number
[0090] is the stopping gradient operator, β is the commitment loss hyperparameter that was set to 0.25 in all our experiments, and e is the codebook vector. In some implementations, the quantized codebook index is expressed in terms of Euclidean distance to the input feature z e (x),
[0091]
number
[0092] This results in:
[0093] Factorized Codes. Some exemplary implementations of the present disclosure include a linear projection from the encoder output into a low-dimensional latent variable space (reduced from 768d vectors to 32d or 8d vectors per code) for code index lookup. This has the direct effect of increasing codebook usage. Factorization can be seen as separating code indexing and code embedding. Some exemplary implementations look up the closest variable encoded from the input on a lower dimensional search space, and then project the matched latent code into a high dimensional embedding space. Exemplary experiments show that reducing the dimensionality of the search space from 256d to 32d consistently improves the reconstruction quality.
[0094] l 2 Regularization code. Some example implementations are e (x) and the codebook latent variable e 2Regularization is also applied. In some implementations, the codebook variables start from a normal distribution. By mapping all latent variables onto a sphere, 2 Regularized latent variables
[0095]
number
[0096] The Euclidean distance of z e This is expanded to the two-vector cosine similarity between (x) and e, which further improves the training stability and reconstruction quality shown in our experiments.
[0097] Example ViT-VQGAN training loss Some example implementations include the logit Laplace loss, l 2 We use a combination of loss, a perceptual loss based on VGG network, and a GAN loss in the StyleGAN discriminator architecture. The loss balancing weights can be configured in a hyper-parameter sweep to optimize image reconstruction quality, codebook usage, FID and inception score. After the sweep, some example implementations apply the same set of training loss hyper-parameters to all datasets, including CelebA-HQ, FFHQ, and ImageNet. The logit-Laplace loss is a regularized l loss where pixel-level noise is assumed to be Laplace distributed. 1 loss, while l 2 The loss can be seen as one in which the noise is assumed to be Gaussian distributed. While the logit-Laplace loss contributes to the codebook usage, 2 It was found that loss and perceptual loss contribute significantly to FID. The final loss combination used by default is L = L VQ +0.1L Adv +0.1L Perceptual +0.1L Logit-laplace +1.0L 2 It is.
[0098] One provisional application of VGG-based perceptual loss is that the VGG network is pre-trained with supervised classification loss, so supervision may leak into stage 2 for linear probe accuracy measurements. Therefore, for all reported unsupervised learning results, some example implementations exclude the perceptual loss during ViT-VQGAN training. For all unconditional and class-conditional image synthesis, some example implementations use the ViT-VQGAN quantizer trained with the perceptual loss, resulting in higher fidelity reconstruction.
[0099] Exemplary Vector Quantization Image Modeling Using the trained ViT-VQGAN, we can encode an image into a distinct latent code id flattened in raster order, similar to image GPT. Using a decoder-only transformer model, we can autoregressively model the density of the image data P(x) as follows:
[0100]
number
[0101] where θ are learnable weights. The training objective is the negative log-likelihood of the data
[0102]
number
[0103] The aim is to minimize
[0104] Table 2 summarizes example architectural configurations for the transformer. Some example implementations first embed the individual image token id at each position into a learnable embedding space with an additional learnable 2D position embedding. Both embedding dimensions are the same as the model dimensions. Some example implementations apply a stack of transformer blocks to the input with causal attention across the entire sequence. A dropout rate of 0.1 can be used on all remaining, activation, and attention outputs. At the final layer of all transformer blocks, some example implementations apply an additional layer regularization.
[0105] [Table 2]
[0106] Exemplary Image Synthesis With a pre-trained generative transformer model, unconditional image generation can be achieved by simply sampling, token-by-token, from the output softmax distribution. All samples used in both qualitative and quantitative results can be obtained without temperature degradation. The sampled tokens can then be fed into the decoder of ViT-VQGAN to decode the output image. An exemplary default stage-1 ViT-VQGAN encodes input images of resolution 256x256 into latent codes of 32x32 with a codebook size of 8192, while the stage-2 transformer takes flattened image tokens with a total length of 1024.
[0107] Class-conditional ImageNet generation is also a widely used benchmark to measure the ability of models for image synthesis. Some exemplary implementations extend unconditional generation to class-conditional generation by adding a class id token before the image token. A separate embedding layer can learn the class id token and the image token from scratch, and the embedding dimension is the same as the transformer model dimension. During the sampling period, the class id token can be placed in the first position and the remaining image tokens can be autoregressively decoded.
[0108] Exemplary Unsupervised Learning For image understanding tasks, some example implementations feed all image tokens of the input to a pre-trained transformer, resulting in a sequence of 1024 token features. Some example implementations take the layer output at a particular block l over the total blocks L, average it over the sequence of (frozen) token features, and insert a (learnable) softmax layer to project the averaged feature to the class logit. Some example implementations only take one particular transformer block output, instead of concatenating different block outputs as in iGPT. Often, the most discriminatory features for linear probing are typically near the middle of all the transformer blocks.
[0109] Example Babeldraw model Some example implementations of Babeldraw are two-stage models consisting of an image tokenizer and an autoregressive model across both language and image tokens.
[0110] Exemplary Image Tokenizer Autoregressive text-image models rely on some form of linearization of 2D images into a 1D sequence of patch representations. In the limit, these are just pixels, but they are necessary to model very long sequences even for relatively small images (e.g., a 256x256 image results in 65536 rasterized pixels). Worse, it is based on a very low-level representation of the input, rather than a richer one informed by the pixel's location in the image context. Many works have solved the above problem by using a discrete variational autoencoder to learn quantized representations of image patches across a set of raw images. Instead of learning a representation that can take any value in the latent space, a visual codebook is learned that fits the patch embedding to its nearest codebook entry, a location that can be learned and indexed in the entire latent space. These entries are considered visual word types, and the representation of any of these words in a given image patch is therefore an image token.
[0111] To be most useful for second stage models, an image tokenizer should (a) learn an effective visual codebook that supports balanced use of its entries across a wide range of images, and (b) support the reconstruction of sequences of visual tokens as high quality output images. Some exemplary implementations use the example ViT-VQGAN described herein, which addresses both requirements by using techniques that improve codebook learning, i.e., regularized and factorized codes that contribute to training stability, reconstruction quality, and codebook usage.
[0112] For Babeldraw's image tokenizer, some exemplary implementations train ViT-VQGAN as described above, but use images in larger image-text training data (e.g., instead of ImageNet, CelebA-HQ, or FFHQ). Some exemplary implementations first train a ViT-VQGAN-Small configuration (8 blocks, 8 heads, model dimension 512, and hidden dimension 2048) and learn 8192 image token classes for the codebook. Note that the second stage encoder-decoder training only relies on the learned quantizer encoder and codebook. To further improve the visual sensitivity of the reconstructed images, some exemplary implementations freeze the encoder and codebook after training and fine-tune with a larger size (32 blocks, 16 heads, model dimension 1280, and hidden dimension 5120) decoder. Both the input and output of the image tokenizer may be of resolution 256x256.
[0113] Some example implementations exhibit pixelated patterns (saturated pixel values) in the output of ViT-VQGAN when zooming in on parts of the image. To solve this problem, some example implementations remove the last sigmoid layer and expose the raw values as RGB pixel values (in the range [0,1]). Conveniently, this correction can be hot-swapped into an already trained model by fine-tuning the decoder.
[0114] In addition, while images with resolution 256x256 capture most of the content, structure, and texture, images with higher resolution such as 512x512 or 1024x1024 are more visually pleasing. To this end, some exemplary implementations leverage a simple super-resolution module on top of the image tokenizer. A stacked convolutional layer with remaining connections can be used as the super-resolution network module. It can be trained with ViT-VQGAN with the same losses (perceptual loss, StyleGAN loss, and L2 loss) to map from the reconstructed image to a higher resolution reconstructed image. Note that the diffusion model can also be used here as an iterative refinement super-resolution module, either with or without conditioning on the text input.
[0115] Image from Text in an Exemplary Encoder-Decoder In some exemplary implementations, a standard Encoder-Decoder Transformer model is trained in the second stage by treating the text-to-image as a sequence-to-sequence modeling problem. The model takes text as input and is trained using the next token prediction of the image latent code generated from the first stage image tokenizer. During inference, the model can autoregressively sample image tokens, which are later decoded into pixels using the previously trained image tokenizer decoder.
[0116] Text prompts can be truncated to a maximum length of 128, and images with resolution 256x256 can be encoded into tokens of length 1024 (32x32). Some example implementations train with cross-entropy loss and use an int8 quantized Adafactor optimizer with constant decaying second moment factors (beta1=0.9, beta2=0.96). Data types can be dropped to bfloat16 or attention projection and feedforward transformer layers, while all layer norms and model outputs can be kept to float32. All models can use conv-shaped mask sparse attention, and some example implementations train four size variants ranging from 350 million to 20 billion parameters.
[0117] Most of the existing two-stage text-to-image generation models are decoder-only models. Early studies at scales of 350-750 million parameters show that the encoder-decoder variant of Babeldraw outperforms the decoder-only counterparts in both training loss and text-to-image generation quality.
[0118] Example Text Encoder Pre-Training The encoder-decoder architecture separates text encoding from image token generation. Thus, some example implementations also include a straightforward way to warm-start the model with a pre-trained text encoder. Intuitively, a good text encoder for visual synthesis should be capable of general language understanding in addition to visually robust prompts. Some example implementations pre-train the text encoder on two datasets: the Colossal Clean Crawled Corpus (C4) with BERT pre-training objective, and an image-text dataset with contrasting learning objectives. After pre-training, some example implementations continue to train both the encoder and decoder for image generation from text with softmax cross-entropy loss on a vocabulary of 8192 individual image tokens.
[0119] Exemplary Classifier-Free Guidance and Reranking Classifier-free guidance is typically used in situations where we want to improve the sample quality of a diffusion model without a pre-trained classifier. In this setup, a generative model G is trained to be able to perform unconditional generation G(z) (where z represents random noise) and conditional generation G(z,c) (where c represents some condition, such as the language description in this case). It is simply implemented as a conditional vector that is randomly omitted (masked or switched to a learned embedding) with a certain probability. Then, during the inference process, the output I is sampled by using a linear combination of the unconditional and conditional predictions. I = G(z) + λ(G(z, c) - G(z)) (3) where λ is a hyperparameter that represents the weight of the guidance without the classifier. Intuitively, it can be seen as decreasing the unconditional likelihood of a sample while increasing the conditional likelihood, which improves the match of the generated sample to the conditions.
[0120] Guidance without classifiers has been applied to great effect in the context of autoregressive models for image generation from text as well. One exemplary approach randomly replaces text prompts with padding tokens while fine-tuning the model. During the estimation period, a linear combination of logits sampled from the unconditioned model (conditioned on the padding tokens) and the model conditioned on the original text prompts is taken.
[0121] Some exemplary implementations also apply classifier-free guidance to Babeldraw and find that it has a positive impact on output quality, especially difficult text prompts. Some exemplary implementations fine-tune the model for 100000 steps and randomly replace text prompts with padding tokens. During the sampling period, some exemplary implementations sample from logits from a linear combination of unconditional logits and conditional logits.
[0122] Some example implementations sample 16 images per text prompt. For each output, some example implementations re-rank based on the Contrastive Captioners model (CoCa) image and text embedding alignment scores. The CoCa base-size model can be trained on the same dataset. It is noteworthy that re-ranking over a small set of images is computationally inexpensive for image-from-text sampling.
[0123] Exemplary Scaling Techniques Some example implementations use the GSPMD and Lingvo frameworks to scale models on CloudTPUv4 hardware for both training and inference. GSPMD is an XLA compiler-based model partitioning system that treats a cluster of TPUs as a single virtual device and allows you to use sharding annotations on tensors to tell the compiler to automatically distribute data to compute on thousands of devices.
[0124] Training. For both the 350M and 750M models, some exemplary implementations simply train the model with data parallelism. For the 3B model, some exemplary implementations use 4-way in-layer model parallelism, and 128-way data parallelism. Partitioning a single dimension in each tensor is sufficient to scale the 3B model. The model weights can be partitioned on the number of feedforward hidden dimensions and attention head dimensions, and the internal activity tensors of the feedforward and attention layers can also be partitioned on the hidden and head dimensions, but the difference from Megatron-LM is that some exemplary implementations also fully partition the output activity of the feedforward and attention layers on different dimensions (they do not have hidden / head dimensions). This scheme results in a ReduceScatter and AllGather communication pattern instead of AllReduce, which significantly reduces the peak activity memory.
[0125] As an example, Figure 6 illustrates an example approach to scaling model training, according to an example embodiment of the present disclosure. In particular, Figure 6 illustrates 4-way in-layer model parallelism with fully partitioned activity to scale example 3B model training. Figure 6 illustrates a simplified transformer feedforward layer (with sequence dimensions omitted), with each shade representing data on one device. Some example implementations additionally use 128-way data parallelism.
[0126] One exemplary 20B model has 16 encoder layers and 64 decoder layers. The weight size in each layer is moderate (as opposed to very wide), which makes pipeline parallelism a good option for scaling. A general pipeline wrapper layer is implemented to allow the exemplary implementation to specify a one-stage program, which is later automatically converted to a multi-stage pipeline program. The wrapper layer reduces the pipelining to the tensor partitioning problem using vectorization and shift buffers, so all the low-level infrastructure can be reused for pipelining. There are two additional benefits from adopting the GSPMD pipeline: (1) it allows the exemplary implementation to conveniently configure pipelines within the model's subcomponents, which simplifies the overall complexity of the encoder-decoder model; and (2) because the pipelining is implemented on a vectorized program as tensor partitioning, the exemplary implementation can reuse the same set of devices for other types of parallelism outside of the transformer layer.
[0127] As an example, FIG. 7 illustrates a diagram of an exemplary model parallel processing approach according to an exemplary embodiment of the present disclosure. In particular, FIG. 7 illustrates a diagram of an exemplary 16-stage GSPMD pipeline for scaling the exemplary 20B model training. FIG. 7 shows how 16 devices are used for data parallelism at the quantizer, embedding, and softmax layers, but are repurposed for pipelining in the encoder and decoder layers. Each shade represents data or layers assigned to one device. The decoder uses a 4-round circular schedule to further reduce the pipeline bubble ratio. Moreover, the exemplary implementation additionally uses 64-way data parallelism for all layers.
[0128] Some exemplary implementations configure the model to have separate encoder and decoder pipelines, each with 16 stages. Some exemplary implementations also use 64-way data parallelism in addition to pipelining to speed up training. However, this reduces the batch size per core and exposes it to the additional challenge of excessive pipeline bubbles. To reduce the rate of pipeline bubbles, some exemplary implementations adapt a circular schedule in the decoder pipeline, with four layers at each stage being executed in round-robin order. Other than the encoder and decoder, some exemplary implementations use the same set of devices to perform data parallelism instead of pipelining for the embedding, softmax, and image tokenizer layers.
[0129] During training, an Adafactor optimizer can be used to save memory with beta1=0.9, beta2=0.96, and a separation weight decay value of 4.5e-2. The first moments of the optimizer slot variables are additionally quantized from float32 to int8. Some exemplary implementations use a default dropout rate of 0.1 for all models, both in the encoder and decoder. A deterministic version of the dropout layer can be used in the 20B model to allow model pipelining. Some exemplary implementations use a default learning rate of 4.5e-5 and an exponential learning rate schedule with 5000 warm-up steps. Exponential decay starts at training step 85000 with a total of 450000 steps, resulting in a final decay rate of 0.025. Some exemplary implementations do not use an exponential moving average of the model weights to save device memory. For text encoding, some exemplary implementations build a sentence-piece model with a vocabulary size of 16000 on a subset of the training data. Conv-shaped sparse attention can be used in the decoder transformer. Some example implementations additionally clip the gradient norm to a value of 4.0 to stabilize training, especially at the beginning. At the output of both the encoder and the decoder, some example implementations apply an additional layer regularization layer.
[0130] Inference. One primary goal for inference optimization is to speed up small batch image generation. Some example implementations choose in-layer model parallelism for both the 3B and 20B models. In contrast to training, some example implementations do not fully partition the output activations for the feedforward and attention layers for inference. This is because (1) each step of the autoregressive decoding produces much smaller tensors, and AllReduce (when writing) performs better on small data, and (2) active memory is not relevant during inference and there is no backward handoff.
[0131] Exemplary Devices and Systems 8A illustrates a block diagram of an exemplary computing system 100 according to an exemplary embodiment of the present disclosure. The system 100 includes a user computing device 102, a server computing system 130, and a training computing system 150 that are communicatively coupled via a network 180.
[0132] The user computing device 102 may be any type of computing device, such as, for example, a personal computing device (e.g., a laptop or desktop), a mobile computing device (e.g., a smartphone or tablet), a gaming console or controller, a wearable computing device, an embedded computing device, or any other type of computing device.
[0133] The user computing device 102 includes one or more processors 112 and memory 114. The one or more processors 112 may be any suitable processing device (e.g., a processor core, a microprocessor, an ASIC, an FPGA, a controller, a microcontroller, etc.) and may be a single processor or multiple processors operatively connected. The memory 114 may include one or more non-transitory computer-readable storage media, such as RAM, ROM, EEPROM, EPROM, flash memory devices, magnetic disks, and combinations thereof. The memory 114 may store data 116 and instructions 118. The instructions 118 are executed by the processor 112 to cause the user computing device 102 to perform operations.
[0134] In some implementations, the user computing device 102 may store or include one or more machine learning models 120. For example, the machine learning models 120 may be or may include various machine learning models, such as neural networks (e.g., deep neural networks) or other types of machine learning models including nonlinear and / or linear models. The neural networks may include feed-forward neural networks, recurrent neural networks (e.g., long short-term memory recurrent neural networks), convolutional neural networks, or other forms of neural networks. Some exemplary machine learning models may leverage attention mechanisms, such as self-attention. For example, some exemplary machine learning models may include multi-head self-attention models (e.g., transformer models). Exemplary machine learning models 120 are discussed with reference to FIGS. 1 and 2.
[0135] In some implementations, one or more machine learning models 120 may be received from the server computing system 130 over the network 180, stored in the user computing device memory 114, and then used or otherwise implemented by one or more processors 112. In some implementations, the user computing device 102 may implement multiple parallel instances of a single machine learning model 120 (e.g., to perform parallel image quantization across multiple instances of an image).
[0136] Additionally or alternatively, one or more machine learning models 140 may be included in or otherwise stored and implemented by a server computing system 130 that communicates with the user computing device 102 according to a client-server relationship. For example, the machine learning models 140 may be implemented by the server computing system 140 as part of a web service (e.g., an image quantization, understanding, and / or generation service). Thus, one or more models 120 may be stored and implemented by the user computing device 102 and / or one or more models 140 may be stored and implemented by the server computing system 130.
[0137] The user computing device 102 may also include one or more user input components 122 that receive user input. For example, the user input component 122 may be a touch-sensitive component (a touch-sensitive display screen or touchpad) that senses the contact of a user input object (e.g., a finger or stylus). The touch-sensitive component may serve to implement a virtual keyboard. Other exemplary user input components include a microphone, a traditional keyboard, or other means by which a user may provide user input.
[0138] The server computing system 130 includes one or more processors 132 and a memory 134. The one or more processors 132 may be any suitable processing device (e.g., a processor core, a microprocessor, an ASIC, an FPGA, a controller, a microcontroller, etc.) and may be a single processor or multiple processors operatively connected. The memory 134 may include one or more non-transitory computer-readable storage media, such as RAM, ROM, EEPROM, EPROM, flash memory devices, magnetic disks, and combinations thereof. The memory 134 may store data 136 and instructions 138. The instructions 138 are executed by the processor 132 to cause the server computing system 130 to perform operations.
[0139] In some implementations, server computing system 130 includes or is otherwise implemented by one or more server computing devices. In instances in which server computing system 130 includes multiple server computing devices, such server computing devices may operate according to a sequential computing architecture, a parallel computing architecture, or some combination thereof.
[0140] As described above, the server computing system 130 can store or otherwise include one or more machine learning models 140. For example, the models 140 can be or otherwise include various machine learning models. Exemplary machine learning models include neural networks or other multi-layer nonlinear models. Exemplary neural networks include feed-forward neural networks, deep neural networks, recurrent neural networks, and convolutional neural networks. Some exemplary machine learning models can leverage attention mechanisms such as self-attention. For example, some exemplary machine learning models can include multi-head self-attention models (e.g., transformer models). Exemplary models 140 are discussed with reference to FIGS. 1 and 2.
[0141] The user computing device 102 and / or the server computing system 130 can train the models 120 and / or 140 via cross-referencing with a training computing system 150 that is communicatively coupled via a network 180. The training computing system 150 may be separate from the server computing system 130 or may be part of the server computing system 130.
[0142] The training computing system 150 includes one or more processors 152 and memory 154. The one or more processors 152 may be any suitable processing device (e.g., a processor core, a microprocessor, an ASIC, an FPGA, a controller, a microcontroller, etc.) and may be a single processor or multiple processors operatively connected. The memory 154 may include one or more non-transitory computer-readable storage media, such as RAM, ROM, EEPROM, EPROM, flash memory devices, magnetic disks, and combinations thereof. The memory 154 may store data 156 and instructions 158. The instructions 158 are executed by the processor 152 to cause the training computing system 150 to perform operations. In some implementations, the training computing system 150 includes or is otherwise implemented by one or more server computing devices.
[0143] The training computing system 150 may include a model trainer 160 that trains the machine learning models 120 and / or 140 stored on the user computing device 102 and / or the server computing system 130 using various training or learning techniques, such as, for example, backpropagation of error. For example, a loss function may be backpropagated through the model to update one or more parameters of the model (e.g., based on the gradient of the loss function). Various loss functions may be used, such as mean squared error, likelihood loss, cross entropy loss, hinge loss, and / or various other loss functions. Gradient descent techniques may be used to iteratively update the parameters over several training iterations.
[0144] In some implementations, performing backpropagation of the error may include performing truncated backpropagation over time. The model trainer 160 may implement a number of generalization techniques (e.g., weight decay, dropout, etc.) to improve the generalization ability of the trained model.
[0145] In particular, model trainer 160 can train machine learning models 120 and / or 140 based on a set of training data 162. Training data 162 can include, for example, unsupervised and / or supervised training images.
[0146] In some implementations, if the user provides consent, the training examples may be provided by the user's computing device 102. Thus, in such implementations, the model 120 provided to the user's computing device 102 may be trained by the training computing system 150 with user-specific data received from the user computing device 102. In some instances, this process may be referred to as personalizing the model.
[0147] Model trainer 160 includes computer logic utilized to achieve desired functionality. Model trainer 160 can be implemented in hardware, firmware, and / or software controlling a general-purpose processor. For example, in some implementations, model trainer 160 includes program files stored in a storage device and loaded into memory for execution by one or more processors. In other implementations, model trainer 160 includes one or more sets of computer-executable instructions stored in a tangible computer-readable storage medium, such as RAM, a hard disk, or an optical or magnetic medium.
[0148] Network 180 may be any type of communications network, such as a local area network (e.g., an intranet), a wide area network (e.g., the Internet), or some combination thereof, and may include any number of wired or wireless links. In general, communications on network 180 may be carried over any type of wired and / or wireless connections using a wide variety of communications protocols (e.g., TCP / IP, HTTP, SMTP, FTP), encodings or formats (e.g., HTML, XML), and / or security schemes (e.g., VPN, Secure HTTP, SSL).
[0149] The machine learning models described herein can be used in a variety of tasks, applications, and / or use cases.
[0150] In some implementations, an input to the machine learning model of the present disclosure may be image data. The machine learning model may process the image data to generate an output. As an example, the machine learning model may process the image data to generate an image recognition output (e.g., a recognition of the image data, a latent embedding of the image data, an encoded representation of the image data, a hash of the image data, etc.). As another example, the machine learning model may process the image data to generate an image segmentation output. As another example, the machine learning model may process the image data to generate an image classification output. As another example, the machine learning model may process the image data to generate an image data transformation output (e.g., an alteration of the image data, etc.). As another example, the machine learning model may process the image data to generate an encoded image data output (e.g., an encoded and / or compressed representation of the image data, etc.). As another example, the machine learning model may process the image data to generate a high-quality image data output. As another example, the machine learning model may process the image data to generate a prediction output.
[0151] In some implementations, an input to a machine learning model of the present disclosure may be latent coded data (e.g., a latent space representation of the input). The machine learning model may process the latent coded data to generate an output. As an example, the machine learning model may process the latent coded data to generate a recognition output. As another example, the machine learning model may process the latent coded data to generate a reconstruction output. As another example, the machine learning model may process the latent coded data to generate a search output. As another example, the machine learning model may process the latent coded data to generate a reclustered output. As another example, the machine learning model may process the latent coded data to generate a prediction output.
[0152] In some cases, the machine learning model can be configured to perform a task that includes encoding input data for reliable and / or efficient transmission or storage (and / or corresponding decoding). For example, the task may be an audio compression task. The input may include audio data and the output may include compressed audio data. In another example, the input may include visual data (e.g., one or more images or videos) and the output may include compressed visual data, and the task is a visual data compression task. In another example, the task may include generating an embedding for the input data (e.g., input audio or visual data).
[0153] In some cases, the input includes visual data and the task is a computer vision task. In some cases, the input includes pixel data for one or more images and the task is an image processing task. For example, the image processing task may be image classification and the output is a set of scores, each score corresponding to a different object class and representing the likelihood that the one or more images depict an object belonging to the object class. The image processing task may be object detection and the image processing output identifies one or more regions in the one or more images and, for each region, the likelihood that the region depicts an object of interest. As another example, the image processing task may be image segmentation and the image processing output defines, for each pixel in the one or more images, a respective likelihood for each category in a set of predefined categories. For example, the set of categories may be foreground and background. As another example, the set of categories may be object classes. As another example, the image processing task may be depth estimation and the image processing output defines, for each pixel in the one or more images, a respective depth value. As another example, the image processing task may be motion estimation, where the network input includes multiple images and the image processing output defines, for each pixel in one of the input images, the motion of the scene depicted by that pixel between the images in the network input.
[0154] 8A illustrates one exemplary computing system that can be used to implement the present disclosure. Other computing systems can be used as well. For example, in some implementations, the user computing device 102 can include a model trainer 160 and a training dataset 162. In such implementations, the model 120 can be both trained and used locally on the user computing device 102. In some such implementations, the user computing device 102 can implement the model trainer 160 to personalize the model 120 based on user-specific data.
[0155] 8B illustrates a block diagram of an exemplary computing device 10 implemented according to an exemplary embodiment of the present disclosure. The computing device 10 may be a user computing device or a server computing device.
[0156] The computing device 10 includes several applications (e.g., applications 1 through N). Each application includes its own machine learning library and machine learning model. For example, each application may include a machine learning model. Exemplary applications include a text messaging application, an email application, a dictation application, a virtual keyboard application, a browser application, etc.
[0157] As illustrated in Figure 8B, each application can communicate with several other components of the computing device, such as, for example, one or more sensors, a context manager, a device state component, and / or additional components. In some implementations, each application can communicate with each device component using an API (e.g., a public API). In some implementations, the API that each application uses is private to that application.
[0158] 8C illustrates a block diagram of an exemplary computing device 50 for implementing according to an exemplary embodiment of the present disclosure. Computing device 50 may be a user computing device or a server computing device.
[0159] Computing device 50 includes several applications (e.g., applications 1 through N). Each application communicates with a central intelligence layer. Exemplary applications include a text messaging application, an email application, a dictation application, a virtual keyboard application, a browser application, etc. In some implementations, each application can communicate with the central intelligence layer (and the models stored therein) using an API (e.g., a common API across all applications).
[0160] The central intelligence layer includes several machine learning models. For example, as illustrated in FIG. 8C, a respective machine learning model may be provided for each application and managed by the central intelligence layer. In other implementations, two or more applications may share a single machine learning model. For example, in some implementations, the central intelligence layer may provide a single model for all of the applications. In some implementations, the central intelligence layer is included within or otherwise implemented by the operating system of the computing device 50.
[0161] The central intelligence layer can communicate with a central device data layer, which can be a central repository of data for the computing device 50. As illustrated in FIG. 8C, the central device data layer can communicate with several other components of the computing device, such as, for example, one or more sensors, a context manager, a device state component, and / or further components. In some implementations, the central device data layer can communicate with each device component using an API (e.g., a private API).
[0162] Further disclosure The techniques discussed herein make reference to servers, databases, software applications, and other computer-based systems as well as performing actions and transmitting information to and from such systems. The inherent flexibility of computer-based systems allows for a wide variety of possible configurations, combinations, and partitioning of tasks and functionality among components. For example, the processes discussed herein can be implemented using a single device or component, or multiple devices or components working in combination. Databases and applications can be implemented on a single system or distributed across multiple systems. Distributed components can operate sequentially or in parallel.
[0163] While the present subject matter has been described in detail with respect to various specific exemplary implementations thereof, each example is provided as an example and not a limitation of the present disclosure. Those skilled in the art, upon gaining the above understanding, can easily make modifications, variations, and equivalents to such embodiments. Thus, the disclosure of the present subject matter does not exclude the inclusion of such modifications, variations, and / or additions to the present subject matter that are readily apparent to those skilled in the art. For example, features illustrated or described as part of one embodiment can be used with another embodiment to produce yet a further embodiment. Thus, the present disclosure is intended to cover such modifications, variations, and equivalents. [Explanation of symbols]
[0164] 10. Computing Devices 12 Input image patches 16 Transformer Encoder, Image Encoder 18 Image Tokens 20 Quantization Code 22 Codebook, quantization codebook, candidate code 24 Transformer Decoder, Image Decoder 26 synthetic image patches 28 Composite Images 30 Loss Function 50 Computing Devices 102 User Computing Devices 112 processors 114 Memory 116 Data 118 Command 120 Machine Learning Models 122 User Input Components 130 Server Computing System 132 processors 134 Memory 136 Data 138 Command 140 Machine Learning Models 150 Training Computing System 152 processors 154 Memory 156 Data 158 Command 160 Model Trainer 162 Training data, training data set 180 Network 212 input image patches 214 Input images 216 Transformer Encoder, Image Encoder 218 Image Tokens 222 Code Book 224 Code Prediction Model 226 Expected Code 228 Transformer Encoder, Image Decoder 230 synthetic image patches 232 Composite Images 332 Composite Images 334 Natural Language Input, Input Text 402 Text Encoder 404 Autoregressive Code Selector 406 Text Embedding
Claims
1. 1. A computer-implemented method for performing vector quantization of an image, comprising the steps of: obtaining, by a computing system comprising one or more computing devices, a plurality of input image patches of an image; processing, by the computing system, the plurality of input image patches with a machine learning image encoder to generate a plurality of image tokens in a latent space, the plurality of image tokens corresponding to the plurality of input image patches, the machine learning image encoder performing one or more self-attention operations to process the plurality of input image patches to generate the plurality of image tokens in the latent space; mapping, by the computing system, the plurality of image tokens to a plurality of quantization codes contained in a quantization codebook comprising a plurality of candidate codes; providing, by the computing system, the plurality of quantization codes as an encoded version of the image; A computer-implemented method comprising:
2. 2. The computer-implemented method of claim 1, wherein the machine-learned image encoder comprises a vision transformer model.
3. 3. The computer-implemented method of claim 1 or 2, wherein the machine-learned image encoder performs one of the one or more self-attention operations on the plurality of input image patches.
4. processing, by the computing system, the plurality of quantization codes with a machine learning image decoder to generate a plurality of composite image patches that form a composite image; evaluating, by the computing system, a loss function that provides a loss value based at least in part on the synthetic image; modifying, by the computing system, one or more of the machine-learned image encoder, the machine-learned image decoder, and the plurality of candidate codes based at least in part on the loss function; 4. The computer-implemented method of claim 1, further comprising:
5. 5. The computer-implemented method of claim 4, wherein the machine-learned image decoder comprises a vision transformer model.
6. The loss function is Logit Laplace loss term, L2 loss term, a perceptual loss term, and Generative adversarial network loss term 6. The computer-implemented method of claim 4 or 5, comprising:
7. mapping, by the computing system, the plurality of image tokens to the plurality of quantization codes included in the quantization codebook including the plurality of candidate codes; projecting, by the computing system, the plurality of image tokens into a lower dimensional space; after projecting the image tokens into the lower dimensional space, mapping the image tokens to the quantization codes included in the quantization codebook by the computing system; 7. A computer-implemented method according to any one of claims 1 to 6, comprising:
8. mapping, by the computing system, the plurality of image tokens to the plurality of quantization codes included in the quantization codebook including the plurality of candidate codes; applying, by the computing system, L2 regularization to one or both of the plurality of image tokens and the plurality of candidate codes; after the step of applying the L2 regularization, mapping, by the computing system, the plurality of image tokens to the plurality of quantization codes contained in the quantization codebook; 8. A computer-implemented method according to any one of claims 1 to 7, comprising:
9. autoregressively predicting, by the computing system using a machine-learned code prediction model, a plurality of predicted codes from the quantization codebook based at least in part on one or more of the plurality of quantization codes; processing, by the computing system, the predicted codes with a machine learning image decoder to generate a plurality of synthetic image patches that form a synthetic image; 9. The computer-implemented method of claim 1, further comprising:
10. evaluating, by the computing system, a code prediction loss function that evaluates a negative log-likelihood based on the plurality of predicted codes; modifying, by the computing system, one or more parameters of the machine-learned chord prediction model based on the chord prediction loss function; 10. The computer-implemented method of claim 9, further comprising:
11. 11. The computer-implemented method of claim 9 or 10, wherein autoregressively predicting the plurality of predicted chords by the computing system using the machine-learned chord prediction model includes conditioning, by the computing system, the machine-learned chord prediction model with auxiliary conditioning data that describes one or more desired characteristics of the composite image.
12. The computer-implemented method of claim 11 , wherein the auxiliary conditioning data includes a class label describing a desired class of the synthetic image.
13. 13. The computer-implemented method of claim 11 or 12, wherein the auxiliary conditioning data comprises natural language text tokens.
14. conditioning, by the computing system, the machine-learned code prediction model with the natural language text tokens, processing, by the computing system, the natural language text tokens with a text encoder portion of the machine-learned chord prediction model to generate text embeddings; and autoregressively predicting, by the computing system, the plurality of predicted chords by providing the text embeddings as inputs to an autoregressive chord selection portion of the machine-learned chord prediction model.
14. The computer-implemented method of claim 13, comprising:
15. extracting, by the computing system, one or more intermediate features from the machine-learned code prediction model; predicting, by the computing system, a class label for the image based at least in part on the intermediate features; 15. The computer-implemented method of claim 9, further comprising:
16. 1. A computer-implemented method for performing vector quantization of an image, comprising the steps of: obtaining, by a computing system comprising one or more computing devices, a plurality of quantization codes forming an encoded version of an image, the plurality of quantization codes being selected by mapping a plurality of image tokens generated by a machine-learned image encoder model to the plurality of quantization codes included in a quantization codebook comprising a plurality of candidate codes; processing, by the computing system, the plurality of quantization codes with a machine-learned image decoder to generate a plurality of decoded image patches forming a decoded version of the image; Including, A computer-implemented method, wherein one or both of the machine-learned image encoder model and the machine-learned image decoder are configured to perform one or more self-attention operations.
17. 17. A computer system comprising one or more processors and one or more non-transitory computer-readable media that collectively store instructions that, when executed by the one or more processors, cause the one or more processors to perform a method according to any one of claims 1 to 16.
18. one or more processors; one or more non-transitory computer-readable media that collectively store the machine-learned image processing model; The machine-learned image processing model comprises: an encoder configured to encode one or more input image patches into one or more image tokens in a latent space; a quantization unit configured to quantize the one or more image tokens to one or more quantization codes selected from a codebook; a code prediction unit configured to predict, from the codebook based at least in part on the one or more quantization codes, one or more predicted quantization codes; a feature prediction unit configured to generate one or more feature predictions for the input image patch based at least in part on data extracted from the code prediction unit; and A computing system comprising:
19. 20. The computing system of claim 18, further comprising a decoder unit configured to: generate a reconstructed image patch based on the one or more quantization codes; or generate a synthetic image patch based at least in part on the one or more predicted quantization codes;
20. 20. The computing system of claim 18 or 19, wherein the one or more characteristic predictions include an image classification prediction.
21. 1. A computer-implemented method for performing image generation from text, comprising: obtaining, by a computing system comprising one or more computing devices, a natural language input describing a desired image content; processing, by the computing system, the natural language input through a text encoder portion of a machine-learned chord prediction model to generate a text embedding; processing the text embeddings with an autoregressive code selection portion of the machine-learned code prediction model by the computing system to autoregressively predict a sequence of codes to be predicted from a quantized codebook containing a plurality of candidate codes; processing, by the computing system, the sequence of quantized codes with a machine learning image decoder to generate a plurality of composite image patches forming a composite image; Including, A computer-implemented method, wherein the composite image depicts the desired image content.
22. 22. The computer-implemented method of claim 21, wherein one or more of the text encoder portion of the machine-learned chord prediction model, the autoregressive chord selection portion of the machine-learned chord prediction model, and the machine-learned image decoder are configured to perform one or more self-attention operations.
23. 23. The computer-implemented method of claim 21 or 22, wherein one or more of the text encoder portion of the machine-learned chord prediction model, the autoregressive code selection portion of the machine-learned chord prediction model, and the machine-learned image decoder comprise a Transform Neural Network.
24. 24. The computer-implemented method of claim 21, wherein one or both of the machine-learned image decoder and the codebook are jointly trained in an image encoder model.
25. 24. The computer-implemented method of claim 21, wherein the text encoder portion of the machine-learned chord prediction model is pre-trained on a pre-training task.
26. 1. A computer-implemented method for training a chord prediction model, comprising: obtaining, by a computing system comprising one or more computing devices, training examples including training images and natural language input describing content of the training images; processing, by the computing system, a plurality of image patches from the training images with a machine learning image encoder to generate a plurality of image tokens in a latent space, the plurality of image tokens corresponding to the plurality of image patches; mapping, by the computing system, the plurality of image tokens to a plurality of quantization codes contained in a quantization codebook comprising a plurality of candidate codes; processing, by the computing system, the natural language input with a text encoder portion of the chord prediction model to generate a text embedding; processing, by the computing system, the text embeddings through an autoregressive code selection portion of the code prediction model to autoregressively predict a sequence of codes to be predicted from the quantization codebook; evaluating, by the computing system, a code prediction loss function that compares the sequence of predicted codes to the plurality of quantized codes; modifying, by the computing system, one or more parameters of the chord prediction model based at least in part on the chord prediction loss function. A computer-implemented method comprising:
27. 27. The computer-implemented method of claim 26, wherein the machine-learned image encoder performs one or more self-attention operations to process the input image patches and generate the image tokens in the latent space.
28. 28. The computer-implemented method of claim 26 or 27, wherein the code prediction loss function evaluates the negative log-likelihood of the predicted code relative to the quantized code.
29. 29. The computer-implemented method of claim 26, wherein the machine-learned image encoder and the codebook are pre-trained with an image decoder in an autoencoder architecture.
30. 27. The computer-implemented method of claim 26, wherein altering, by the computing system, one or more parameters of the chord prediction model based at least in part on the chord prediction loss function comprises altering, by the computing system, one or more parameters of both the text encoder portion and the autoregressive chord selection portion of the chord prediction model based at least in part on the chord prediction loss function.
