---
title: 'End4: End-to-End Denoising Diffusion Detection'
url: https://www.emergentmind.com/topics/end-to-end-denoising-diffusion-end4
type: topic
---

# End4: End-to-End Denoising Diffusion Detection

Searching arXiv for the primary End4 paper and closely related end-to-end denoising diffusion work to ground the article.
End-to-end Denoising Diffusion, abbreviated “End4,” denotes a design pattern in which denoising diffusion is integrated with the downstream objective inside a single trainable system rather than being used as a detached reconstruction or generation stage. In the specific formulation introduced for diffusion-based inpainting detection, End4 is a method for identifying whether an image has been locally manipulated by a diffusion-based inpainting model, and it does so by coupling denoising reconstruction and binary detection within one end-to-end trainable network [2509.13214]. More broadly, the term also appears in adjacent literature as a label for end-to-end diffusion formulations in discriminative vision, planning, and restoration, where the shared theme is that diffusion is not merely a preprocessing or sampling module but part of the task-optimized computational graph [2604.27889], [2411.15139]. This suggests that “End4” is best understood both as the title of a specific inpainting-forensics method and as a wider methodological tendency toward joint optimization of denoising and task prediction.

## 1. Definition and scope

In the inpainting-detection setting, End4 is positioned against prior two-stage pipelines that first reconstruct a candidate image using a frozen diffusion model and then train a separate classifier on reconstruction errors [2509.13214]. Its central claim is that joint optimization aligns the latent spaces of the reconstruction and classification tasks, thereby producing reconstructed features more conducive to detection. The framework therefore treats reconstruction not as an end in itself but as a task-conditioned intermediate representation.

The paper’s full title, “End4: End-to-end Denoising Diffusion for Diffusion-Based Inpainting Detection” [2509.13214], gives the narrowest technical meaning of the term. The target problem is not generic image synthesis, nor generic forgery detection, but the detection of local manipulations created by diffusion-based inpainting systems. The method explicitly addresses the reported difficulty that existing approaches struggle to identify images generated by diffusion-based inpainting models, even when similar inpainted images are included in their training data.

At a broader level, related works reveal a recurring architecture principle. “Noise2Map” describes an “End⁴” discriminative system in remote sensing, where a diffusion process is repurposed for direct semantic segmentation and change detection without iterative generative sampling [2604.27889]. “DiffusionDrive” similarly describes an end-to-end truncated diffusion policy for autonomous driving, with denoising integrated into trajectory prediction rather than separated from the planning objective [2411.15139]. These parallels indicate that End4 belongs to a wider class of end-to-end denoising-diffusion systems in which diffusion states are made task-relevant rather than merely generative.

## 2. Architectural composition of the End4 detector

The End4 pipeline for inpainting detection comprises three main components: an Updated Diffusion Model (UpDM), a Scale-aware Pyramid-like Fusion Module (SPFM), and a Detection Head [2509.13214]. In pseudo-block form, the input image $x_0$ is first passed through UpDM to obtain a reconstruction $\hat y_0$; ResNet50 features are then extracted from both the original and reconstructed images; those features are fused by SPFM through multi-scale attention, self-attention, and cross-attention; and the fused representation $x_{\mathrm{SPFM}}$ is passed to a fully connected classifier that outputs a binary real/fake prediction.

The UpDM is a U-Net-style denoiser with encoder-decoder structure and skip-connections, built from a combination of ResNet blocks, PixelCNN++-inspired convolutions, and Transformer attention layers [2509.13214]. It takes a noisy sample $x_t$ at time step $t$ and predicts noise $\epsilon_\theta(x_t,t)$. Reconstruction is performed by a direct one-step inversion to $\hat x_0$, rather than through $T$ iterative denoising steps.

SPFM is the module that emphasizes localized artifacts. It operates on ResNet50 feature maps from both the original image and the reconstruction using two cascaded pyramid-like layers, denoted $L_1$ and $L_2$ [2509.13214]. Layer $L_1$ uses an attention mask of size $2\times2$ and dilated convolution with dilation $=2$, while layer $L_2$ stacks on $L_1$’s output with mask size $4\times4$ and dilation $=4$. This produces multi-scale representations for the original and reconstructed branches, after which self-attention is applied at each scale and multi-head cross-attention is computed in both directions before concatenation.

The detection head is deliberately lightweight. The fused SPFM output $x_{\mathrm{SPFM}} \in \mathbb{R}^{C\times H\times W}$ is average-pooled along spatial dimensions and then passed through one fully connected layer that maps pooled features to two logits, corresponding to real versus inpainted classes [2509.13214]. The final probability $y'$ is obtained by softmax.

A compact summary of the End4 detector is useful for separating function from implementation detail:

| Component | Role | Key implementation detail |
|---|---|---|
| UpDM | Reconstruct input under denoising objective | One-step denoising U-Net |
| SPFM | Fuse original/reconstructed features | Two-level attention pyramid with self- and cross-attention |
| Detection Head | Binary classification | Average pooling plus one FC layer |

The significance of this decomposition is that reconstruction and detection are not parallel, loosely connected stages. Instead, the reconstruction branch is optimized jointly with the classifier, and SPFM explicitly mediates between the two feature spaces.

## 3. Diffusion formulation and training objective

End4 uses standard DDPM notation for the forward and reverse processes [2509.13214]. The forward noising process is

$$
q(x_t \mid x_{t-1}) = \mathcal{N}\bigl(x_t; \sqrt{1-\beta_t}\,x_{t-1},\,\beta_t \mathbf{I}\bigr),\quad t=1\ldots T.
$$

The reverse process is parameterized by $\theta$ as

$$
p_\theta(x_{t-1}\mid x_t)
= \mathcal{N}\bigl(x_{t-1};\;\mu_\theta(x_t,t),\;\Sigma_\theta(x_t,t)\bigr).
$$

After predicting $\epsilon_\theta(x_t,t)$ at a randomly sampled timestep $t$, End4 reconstructs the input by a direct one-step inversion:

$$
\hat x_{0}
\;=\;\frac{1}{\sqrt{\bar\alpha_t}\Bigl(x_t - \sqrt{1-\bar\alpha_t}\,\epsilon_\theta(x_t,t)\Bigr)
\quad\text{where}\;\bar\alpha_t=\prod_{i=1}^t(1-\beta_i).
$$

The training objective contains two terms: a noise-prediction loss and a binary classification loss [2509.13214]. The noise-prediction loss is applied only to inpainting samples:

$$
\mathcal{L}_{\rm noise}
= \frac{1}{2}\,y\;\bigl\|\epsilon_t - \epsilon_\theta(x_t,t)\bigr\|^2,
$$

where $y=1$ for inpainted images and $y=0$ for natural images. The classification loss is binary cross-entropy:

$$
\mathcal{L}_{\rm ce}
= -\bigl[y\log y' + (1-y)\log(1-y')\bigr].
$$

The combined objective is

$$
\mathcal{L}
= \mathcal{L}_{\rm noise} \;+\;\mathcal{L}_{\rm ce}.
$$

The selective application of $\mathcal{L}_{\rm noise}$ to inpainted images is not incidental. An ablation reported in the paper states that noise-loss targeting only inpainting images yields best accuracy $(89.96\%)$ versus applying it to both classes or to naturals only [2509.13214]. This directly supports the paper’s claim that latent-space alignment should be driven by manipulations of forensic interest rather than by indiscriminate denoising.

From a conceptual standpoint, the objective differs from classical forensic pipelines based on post hoc residuals. In End4, the denoising branch is supervised as part of the detector itself. A plausible implication is that the reconstructed representation is task-shaped: it is not merely a cleaner image, but a representation optimized to expose inpainting artifacts.

## 4. Scale-aware Pyramid-like Fusion Module

SPFM is the most distinctive feature-engineering component of End4 [2509.13214]. Its purpose is to refine local image features under the guidance of attention pyramid layers at different scales, thereby enhancing feature discriminability. The module begins from ResNet50 feature maps extracted from the original image $x_0$ and the reconstructed image $\hat x_0$.

Its first stage is a two-level pyramid. If $x$ and $\hat x$ denote the ResNet50 features from the original and reconstructed branches, the pyramid produces

$$
x_m = \mathrm{Stack}(L_1(x), L_2(L_1(x)))
$$

and

$$
\hat x_m = \mathrm{Stack}(L_1(\hat x), L_2(L_1(\hat x))).
$$

Self-attention is then applied to the stacked features at each scale. For $s\in\{1,2\}$, if $Q_s, K_s, V_s$ are linear projections of the stacked features, the attention update is

$$
A_s = \mathrm{softmax}\bigl(Q_s K_s^{T}/\sqrt{d_k}\bigr)\;V_s.
$$

The resulting scale-aware features are denoted $x_s=\mathrm{SelfAttn}(x_m)$ and $\hat x_s=\mathrm{SelfAttn}(\hat x_m)$. Multi-head cross-attention is then computed in both directions:

- $\mathrm{MCA}_1 = \mathrm{MultiHeadCrossAttn}(Q=x_s, KV=\hat x_s)$
- $\mathrm{MCA}_2 = \mathrm{MultiHeadCrossAttn}(Q=\hat x_s, KV=x_s)$

These are concatenated to form the fused representation $x_{\mathrm{SPFM}}$.

The ablation evidence makes the role of SPFM unusually clear. On the reported benchmark, replacing SPFM with absolute difference gives approximately $51\%$ accuracy, simple concatenation gives approximately $71\%$, and SPFM gives approximately $90\%$ [2509.13214]. This is not merely a modest architectural refinement; within the reported setup, SPFM is responsible for a large fraction of the discriminative gain.

The likely reason, consistent with the paper’s framing, is that inpainting artifacts are region-specific and scale-dependent. SPFM’s bidirectional cross-attention between original and reconstructed features allows the detector to compare local structures across scales instead of relying only on global discrepancy measures. This suggests that End4’s notion of “end-to-end” is not limited to joining modules in one optimizer; it also entails a feature-fusion strategy explicitly matched to localized manipulation traces.

## 5. Data, training protocol, and benchmark design

End4 is trained and evaluated on InpaintingForensics, a COCO-based dataset comprising five mask types, each with $5\,000$ images split into $4\,000$ train and $1\,000$ test [2509.13214]. The five mask types are: center128, random128, centerRandom, randomRandom, and cocoMask. The benchmark is synthesized by three inpainting engines: SD v1.5, SD v2, and BrushNet with $20$ DDIM steps.

The mask taxonomy is central to the evaluation because the paper’s stated objective is generalization to unseen masking patterns. The five mask types cover fixed central masks, random-location masks, random-size central masks, random-size random-position masks, and COCO segmentation masks with up to five categories [2509.13214]. This benchmark design is intended to evaluate detection performance on inpainted images generated from distinct masked regions rather than on a single editing regime.

Training uses random horizontal flip, color jitter, grayscale conversion, and resize to $256\times256$ input [2509.13214]. The batch size is $8$, the learning rate is $1 \times 10^{-4}$, the diffusion timesteps are $T=1000$ with one-step denoising, the optimizer is Adam, and training is performed on an NVIDIA A100. No explicit weight decay is reported.

These details place End4 within a class of computationally moderate diffusion-based forensic systems. Unlike generic diffusion generation pipelines that require iterative reverse sampling at inference, the detector uses one-step denoising as an internal feature-reconstruction mechanism. This choice is later discussed by the authors as a strength-speed tradeoff: one-step denoising improves efficiency, although the paper notes that very subtle artifacts might require multi-step inversion [2509.13214].

The benchmark itself is also a substantive contribution of the work. The paper states that it establishes a comprehensive benchmark comprising images generated from five distinct masked regions [2509.13214]. In the context of inpainting forensics, this matters because overfitting to a narrow mask distribution could give a misleading impression of robustness.

## 6. Empirical results, robustness, and limitations

End4’s main reported experiment trains on the cocoMask subset of SD v1.5 inpainting and evaluates general detection performance across the five mask types [2509.13214]. The reported accuracies and AUCs are:

| Method | center128 (ACC/AUC) | cocoMask (ACC/AUC) |
|---|---|---|
| NPR | 65.90/71.07 | 73.62/82.09 |
| DIRE | ~50/50 | 53.18/54.47 |
| FIRE | ~50/51 | 51.23/50.73 |
| End4 | 87.80/95.00 | 89.96/96.32 |

The full table in the paper also reports strong performance for End4 on random128, centerRandom, and randomRandom, with all AUCs near $95$ and all accuracies around $87$ to $88$ [2509.13214]. Within this setting, End4 clearly outperforms the listed baselines.

Robustness results indicate that End4 maintains $>90\%$ AUC under JPEG compression with $Q \ge 20$, Gaussian blur with $\sigma \le 1.5$, saturation changes with factor in $[0.5,1.5]$, and contrast shifts with factor in $[0.5,1.5]$ [2509.13214]. The paper states that it outperforms all baselines at each perturbation level. Because practical forensic deployment almost always involves post-processing or recompression, these perturbation results are methodologically important.

The ablation findings further isolate key mechanisms. Fusion strategy strongly affects accuracy, with SPFM outperforming absolute difference and simple concatenation by a wide margin [2509.13214]. Likewise, constraining the noise-prediction loss to inpainted images yields the best result. These ablations support the authors’ argument that both latent-space alignment and multi-scale cross-modal comparison are necessary.

The paper also states several limitations [2509.13214]. One-step denoising trades off reconstruction fidelity for speed, and SPFM adds computation compared to simple concatenation, potentially limiting real-time deployment on edge devices. The authors mention possible extensions including integrating explicit segmentation losses to localize inpainted regions, exploring lightweight attention approximations such as Linformer or Performer for faster SPFM, and extending the benchmark to other editing scenarios such as object removal, style transfer, and other generative backbones.

## 7. Position within end-to-end diffusion research

Although End4 is specifically an inpainting detector, related arXiv work shows that its underlying principle—embedding denoising diffusion directly into the task loss—has emerged across several subfields. “Noise2Map” describes a unified diffusion-based framework for semantic segmentation and change detection that directly predicts semantic or change maps using task-specific noise schedules and timestep conditioning, and collapses inference to one forward pass [2604.27889]. Its summary explicitly characterizes the framework as an “End⁴” discriminative system. “DiffusionDrive” presents a truncated diffusion policy for end-to-end autonomous driving, where prior multi-mode anchors and a truncated diffusion schedule enable only $2$ denoising steps at inference while achieving $88.1$ PDMS and real-time speed of $45$ FPS on an NVIDIA 4090 [2411.15139]. “E2ED$^2$” goes further in generative modeling by training the full multi-step denoising trajectory end-to-end with final-output supervision, reconstruction, adversarial, and perceptual losses [2412.21044].

These works are technically heterogeneous. End4 uses one-step denoising as a reconstruction-aligned forensic feature learner [2509.13214]. Noise2Map avoids iterative sampling and directly predicts discriminative maps from noisy inputs [2604.27889]. DiffusionDrive uses truncated denoising from anchored Gaussian mixtures for planning [2411.15139]. E2ED$^2$ treats the entire diffusion chain as a differentiable function from isotropic Gaussian noise to data [2412.21044]. Yet they share a common rejection of the classical separation between diffusion and downstream inference.

A common misconception is that end-to-end denoising diffusion always implies full iterative reverse diffusion during inference. The surveyed literature does not support that interpretation. End4 uses one-step inversion internally [2509.13214], Noise2Map performs one-shot inference [2604.27889], and DiffusionDrive reports superior diversity and quality in just $2$ steps [2411.15139]. Another misconception is that end-to-end diffusion is only relevant for generative synthesis. The cited works show applications in forensics, segmentation, change detection, and autonomous planning.

Taken together, the literature suggests that End4 represents a broader transition from diffusion as a standalone sampler to diffusion as an optimizable task mechanism. In the inpainting-detection paper, that transition takes the concrete form of joint denoising reconstruction, multi-scale fusion, and binary forensic classification inside one network [2509.13214]. In that sense, End4 is both a specific method and an instance of a wider methodological realignment in diffusion-based learning.

Source: https://www.emergentmind.com/topics/end-to-end-denoising-diffusion-end4