iTranslated by AI
Just Image Transformer: Predicting Real Images in Pixel Space with Flow Matching
Overview
- JiT (Just image Transformer) performs flow-matching in pixel space without using a VAE.
- The model achieves better performance by predicting the actual image
rather than predicting velocityx (v x-pred). - However, it is better to calculate the loss using the velocity
derived from the actual imagev and the noisy imagex (z v-loss).
Introduction
Image generation models based on diffusion, such as Stable Diffusion, have primarily been U-Net based models. The derivative SDXL is still a base model used as of December 2025 due to its ease of handling.
Recently, in addition to these, diffusion models that primarily use Transformers—starting with DiT—such as Flux.1, Qwen-Image, and Z-Image, have become widely used due to the high quality of their generated images.
A common feature of these diffusion models is that they generate (latent) images in latent space using a VAE.
On the other hand, the Just image Transformer introduced here is a model that does not use a VAE and predicts actual images in pixel space. In this article, we will review the basic prerequisites and explain how this was achieved and the mechanisms behind it.
Review of Prerequisites
Let's briefly review the prerequisite technologies and related methods.
-
Image Generation
- DDPM: Denoising Diffusion Probabilistic Models
- → Proposed diffusion models.
- Adopts U-Net.
- Learns the reverse of the process where images become noise (reverse diffusion process).
- The model predicts noise
in pixel space (\epsilon eps-pred).- Challenge: High computational cost for high-resolution generation.
- Calculates loss using predicted noise and ground-truth noise
(\epsilon eps-loss).
- LDM: Latent Diffusion Model
- → Reduces computational cost by compressing images into latent space using a VAE!
- Adopts VAE in addition to U-Net.
- Learns the reverse diffusion process.
- The model predicts noise
in latent space (\epsilon eps-pred). - Calculates loss using predicted noise and ground-truth noise
(\epsilon eps-loss).
- Velocity Prediction: Imagen Video, SD2.1, NAI Diffusion V3, etc.
- → Predicts velocity instead of noise.
- Adopts VAE in addition to U-Net.
- Learns the reverse diffusion process.
- The model predicts velocity
in latent space (v v-pred). - Calculates loss using predicted noise and ground-truth velocity
(v v-loss).
- DiT: Scalable Diffusion Models with Transformers
- → Replaces the U-Net of LDM with a Transformer.
- Adopts a modified Transformer; VAE remains.
- Uses VAE to compress into latent space.
- Learns the reverse diffusion process.
- The model predicts noise
in latent space (\epsilon eps-pred). - Calculates loss using predicted noise and ground-truth noise
(\epsilon eps-loss).
- Post-MMDiT: SD3, Flux.1, Qwen-Image, Z-Image, etc.
- → Simplified flow-matching formulas are trendy.
- Adopts modified Transformers; VAE remains.
- Uses VAE to compress into latent space.
- Learns the flow from noise to image (flow-matching).
- The model predicts velocity
in latent space (v v-pred). - Calculates loss using predicted velocity and ground-truth velocity
(v v-loss).
- DDPM: Denoising Diffusion Probabilistic Models
-
Image Recognition
- ViT: An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
- Adopted Transformers for image recognition tasks.
- Processes pixel-space images by dividing them into small patches.
- ViT: An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
Why is a VAE used?
The adoption of VAEs, which began with LDM, was introduced for the purpose of reducing computational cost in high-resolution image generation. A VAE compresses images in pixel space into a latent space, and the model then performs prediction and denoising in that latent space.
To see how much it is compressed, for example, SD-VAE increases the number of channels from 3 to 4 when compressing an image, but the height and width become 1/8. As a result, it is 1/8 * 1/8 * 4/3 = 1/48, which can reduce the original computational cost to about 2%.
In addition, the Flux.1 VAE, which is frequently adopted recently, also has a height/width of 1/8, but the number of channels becomes 16, so it becomes 1/8 * 1/8 * 16/3 = 1/12, which is about 8%.
Since computational cost can be reduced by using a VAE in this way, it becomes possible to generate high resolutions with the same computational budget compared to when not using a VAE. Although the initial goal was to reduce computational cost, if the quality of the VAE itself is poor, it becomes a bottleneck when decoding from latent space to pixel images, and fine details may be crushed no matter how much effort the main model puts in. Therefore, the performance of the VAE itself significantly affects the quality of the generated images. Flux.2 seems to be working hard to improve VAE quality.
Just image Transformer

Image generated with JiT-H/32 at 512x512 resolution
Regarding the authors of the paper, Tianhong Li is the lead author of MAR and its pixel-space version FractalMAR, and Kaiming He is the author of ResNet.
Below, I explain what JiT does and how it works.
Manifold Hypothesis
Since it concerns the fundamental design of the model, let's first explain the manifold hypothesis.
The manifold hypothesis posits that (in the context of images) natural images exist on a low-dimensional "manifold" within the high-dimensional pixel space. Clean images
In essence, I believe this means that ordinary images we see generally are distributed only in a certain portion of the vast combinations of possible pixels, whereas random noise or representations involving noise are not. It makes sense, as generating pixels randomly won't produce meaningful pictures.
Reference:
Therefore, the idea that predicting real images, which are inherently low-dimensional, is actually easier for the model than predicting high-dimensional noise becomes important.
JiT leverages this insight.
Architecture
Since JiT does not use a VAE, it has a simple structure like this.
The input noisy image is first divided into multiple patches. Then, it passes through Linear Embed (the so-called Patch Embedding layer) to increase the channel count, goes through Transformer Blocks several times, and finally, a Linear Predict layer converts it back to the original channel count before reshaping the predicted patches back into an image.
First, let me explain what is done during patchification.
Patchify
Patchification is a process performed to handle images efficiently with Transformers, and it was adopted in ViT (Vision Transformer), a model that performs image classification using Transformers. This process itself is also used in DiT.
As shown in the image, an
If you treat one pixel as one token without patchification, you get
For example, with a 256x256 image,
On the other hand, you can shorten the sequence length by dividing the image into patches. If the patch size is
ViT often uses patch sizes of 16 or 14. DiT experimented with patch sizes of 8, 4, and 2, and showed in experiments that the smaller the patch size, the better the performance (though computational cost increases).
My personal interpretation is that since DiT is already compressed to 1/8 by the VAE, patchifying it further might make learning more difficult.

Modified from DiT Paper Figure 7
Models since MMDiT, such as SD3, Flux.1[1], Qwen-Image, and CogView4, follow this trend and adopt patch size 2.
In contrast, JiT, which does not use a VAE, primarily experimented with patch size 16. In this case, a 256x256 resolution image results in
Bottleneck Layer
After patchifying, it is necessary to align the hidden dimensions for processing through the Transformer. Instead of projecting directly to the hidden dimension, the model first projects to a smaller bottleneck dimension and then to the hidden dimension.

Dimensional changes per patch. An RGB 256x256 image with 3 channels is first divided into 256 patches of 3x16x16. Each patch is flattened to channels x patch_size x patch_size (3x16x16) and projected to a bottleneck dimension of 128. Finally, it is projected to a hidden dimension of 768. (The coincidence between the flattened dimension and the hidden dimension is incidental.)
In other words, rather than using a single linear layer in the Patch Embedding to project to the hidden dimension, two layers are used: the first projects to a lower rank, and the second restores it to the hidden dimension. While the final hidden dimension remains the same, the bottleneck restricts the rank.
However, the official code uses a Conv layer for computation:
Bottleneck Code
What it does is the same as explained above, but according to Gemini, using Conv is more efficient when computing on a GPU.
Notably, there is no activation function between proj1 and proj2. While it is typical to include an activation function in an MLP, it is omitted here, simply projecting via low-rank matrices. According to MobileNetV2, not including an activation function has the advantage of not destroying the manifold.
The graph below shows changes in quality when changing the bottleneck size. (Lower FID indicates better performance.)

From JiT Paper Figure 4. The dashed line is the baseline without a bottleneck. The blue graph represents the FID when changing the bottleneck size.
Since it is based on JiT-B/16, the 16x16 patches would be 768 dimensions if handled directly. Even when the bottleneck size was reduced to 16, there was some minor performance degradation, but no catastrophic collapse occurred. Furthermore, when the bottleneck size was 32-512, performance improved compared to not using a bottleneck at all.
Lowering the dimension improving performance might seem counterintuitive at first, but it is a common technique when learning low-dimensional representations. Personally, I was reminded of LoRA, which seems to have the effect of preventing memorization and making it easier to generalize. Also, the fact that it shares similarities with the linear bottleneck method adopted in MobileNetV2 suggests that "the dimension required to decompose natural data representation is not actually that large." This is consistent with the manifold hypothesis, suggesting that the distribution of real images can be fully represented in a lower dimension.
MobileNetV2 reference:
Additionally, as an experiment supporting this, the following compares performance when keeping the base model size and image sequence length fixed while changing the patch size and image resolution:

From JiT Paper Table 5. Changes in FID when only the image resolution and patch size (the 16 in JiT-B/16) were changed.
When using patch size 64 at 1024x1024 resolution, the dimension of one patch before passing through the bottleneck (128-dimensional) is
Although there is some degradation, it is a viable option to increase the patch size since you can generate higher resolution images with similar computational costs.
Flow-Matching Predicting Real Images
JiT is a model that performs flow-matching.
Standard Flow-Matching
In flow-matching, we learn the flow from the distribution of noise
Thus, at time
Explanation for a beginner
Think of moving from noise
If we know the velocity
we can obtain the clean image
Thus, flow-matching can be solved if we can determine the velocity
However, from our discussion so far, I hope it is clear that this should not be done. If the manifold hypothesis holds true, it should be easier for the model to predict the real image
Experiment on Model Prediction Targets
To verify whether it is truly easier for the model to predict the real data
The following shows the generation results using a 5-layer MLP with ReLU (hidden dimension 256) trained on
Dataset Settings
- Manifold data:
(\hat{x} \in \mathbb{R}^d is smaller thand , always low-dimensional. In experiments,D )d = 2 - Observable data:
(x = P\hat{x} \in \mathbb{R}^D -dimensional, withD in experiments)D \in \{2, 8, 16, 512\}
By setting it up this way, the assumption of the manifold hypothesis—that the data is low-dimensional in reality but observable in a high-dimensional space—is reproduced.

From JiT paper Figure 2. When the
When
Various Loss Formulations
While it is clear that predicting real data

From JiT paper Table 1. This shows combinations of losses where the model
Example of calculating vθ from xθ
First, as confirmed earlier:
z_t = tx + (1 - t) \epsilon v = x - \epsilon
We derive the formula for noise
Substituting this into the second equation:
By replacing
It matches the formula in the table.
As shown, when the model predicts any of the real image, noise, or velocity, it is possible to derive the others using only known information. Since the loss target can be calculated similarly, one can compute losses with arbitrary targets. Therefore, the model does not necessarily need to predict the desired parameters directly; it can achieve the same computation indirectly by predicting other parameters.
However, what is the best combination? Since I have repeatedly stated that predicting real images is simpler, is it best to predict the real image and take the loss on the real image?
Actually, it is slightly different. Below is a comparison of FID scores trained on ImageNet based on JiT-B using various model predictions and loss combinations.

From JiT paper Table 2. (b) When learning 64x64 ImageNet with JiT-B/4 (patch size 4), all
Reading this table, we understand that:
-
Model prediction: Real image prediction
performs overwhelmingly better than noise predictionx\text{-pred} or velocity prediction\epsilon\text{-pred} .v\text{-pred} -
Loss target: Using velocity
for the loss results in slightly better performance than using the raw real imagev or noisex directly.\epsilon
Furthermore, the fact that
However, why does this happen? We already established that predicting real images is easier because they lie on the manifold, but the loss is only better with velocity
Checking the table of loss target calculations again, the loss targets are represented as follows:
-
Model prediction (real image):
(wherex_\theta = \text{net}_\theta(z_t, t) is time andt is the noisy image at that time)z_t -
Real image:
(raw)x_\theta -
Noise:
\epsilon_\theta = (z_t - t x_\theta) / (1 - t) -
Velocity:
v_\theta = (x_\theta - z_t) / (1 - t)
According to the paper's authors, in the case of velocity loss, the part calculating the difference with the model's input
I initially thought the noise loss
Loss Implementation
From the above, we have found that it is optimal to predict the real image
The implementation in PyTorch is as follows:
Personally, I think it is great that this can be achieved with such a simple change.
Looking closely at the part creating v_pred:
v_pred = (x_pred - z) / (1 - t).clamp_min(self.t_eps)
It uses .clamp_min(self.t_eps), ensuring that the value of (1 - t) is at least self.t_eps. This is done to prevent numerical instability when the denominator approaches 0 as self.t_eps = 0.05 is used in the paper.
While clamp allows for stable training, it turns out that not using clamp during inference leads to better quality:
I suspect this is because when increasing the number of inference steps, if one accidentally clamps to 0.05 when denoising a time step smaller than 0.05, it results in an incorrect denoising distance. (For example, with 25-step generation, one step denoises by
Changes Inside the Architecture
Although JiT is based on DiT, the following elements have been incorporated:
- SwiGLU
- RMSNorm
- RoPE
- QKNorm
- CFG interval
- In-context class tokens
The following is a comparison of performance when adopting each of these.

JiT paper Table 4. Adopting RoPE, QKNorm, and in-context class tokens leads to a lower FID compared to the baseline (SwiGLU, RMSNorm). Parentheses indicate cases with CFG interval applied.
I will explain the less common CFG interval and in-context class tokens.
CFG Interval
In short, by limiting the time steps where CFG is applied, this technique prevents color saturation and loss of diversity even when using a high CFG scale, allowing for more detailed generation.
While the original research was intended for diffusion, it appears usable with flow-matching as well; the JiT paper and its official implementation apply CFG only when the time step
In-context Class Tokens
In ViT, a class token representing the image category is added once to the patch sequence and input into the Transformer. (Including it in the sequence is what is meant by "in-context"). DiT also experimented with processing class and time information via in-context methods, but ultimately settled on using only AdaLayerNorm-Zero.
In contrast, JiT replicates the class token several times, adds dedicated positional embeddings, and then includes them in the sequence. In the paper, the class token is repeated 32 times.
Furthermore, it was found that performance improved by inserting these conditions from midway through the Transformer blocks rather than starting from the first block. (This method is called "in-context start block"). In the experiments, they are inserted approximately at the 1/3 point of the model block count.
However, a comparison demonstrating the effect of this trick was not found in the paper.
Training Optimizations
Time Step Sampling
JiT samples the time step
In the paper, P_mean = -0.8 and P_std = 0.8 are used.
Visualizing the distribution looks like this:

Created by ChatGPT based on the sampling function above
Visualization code by ChatGPT
# Visualize the distribution of t = sigmoid(z) where z ~ N(P_mean, P_std^2)
import torch
import matplotlib.pyplot as plt
def sample_t(n: int, P_std: float, P_mean: float, device=None) -> torch.Tensor:
z = torch.randn(n, device=device) * P_std + P_mean
return torch.sigmoid(z)
# Parameters
P_std = 0.8
P_mean = -0.8
n = 100000
# Sample
t = sample_t(n, P_std, P_mean)
# Plot
plt.figure()
plt.hist(t.numpy(), bins=100, density=True)
plt.xlabel("t = sigmoid(z)")
plt.ylabel("Density")
plt.title("Distribution of t for P_std=0.8, P_mean=-0.8")
plt.show()
As seen in the graph,
Noise Scale
Noise used in training and inference is sampled from a normal distribution, but is scaled according to resolution:
self.noise_scale is defined as 1.0 for 256x256 resolution, and 2.0 for 512x512.
Conclusion
Based on the manifold hypothesis, JiT demonstrated the following:
- Real data prediction (
-pred) is paramount.x -
Velocity loss (
-loss) is effective, but not critical (it cannot savev -pred or\epsilon -pred from collapse).v - Bottlenecks are effective.
Impressions
Personally, it completely flipped my assumptions that "if you follow the formulas, it doesn't matter what the model predicts or what the loss target is," "flow-matching naturally predicts velocity," "real image prediction is too difficult to attempt," and "high-resolution generation without a VAE is impossible due to computational costs." It is fascinating. Also, realizing generation in pixel space with only simple changes while incorporating modern improvements is cool. While other pixel-space generation methods like PixelDiT were released around the same time, it is impressive that JiT achieves this with such a simple approach.
-
In public code, it appears as
patch_size = 1, but it performs equivalent processing topatch_size = 2under a different name calledpacking. ↩︎




Discussion