End4: End-to-End Denoising Diffusion Detection
- The paper introduces End4, which jointly optimizes one-step denoising and binary classification to detect diffusion-based inpainting, achieving around 90% accuracy.
- It employs a U-Net style denoiser (UpDM), a Scale-aware Pyramid-like Fusion Module (SPFM) with multi-head self and cross-attention, and a lightweight detection head for latent-space alignment.
- The method demonstrates robustness under common image perturbations like JPEG compression and blur, setting a new benchmark in inpainting forensics and end-to-end diffusion systems.
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 (Wang et al., 16 Sep 2025). 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 (Shibli et al., 30 Apr 2026, Liao et al., 2024). 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 (Wang et al., 16 Sep 2025). 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” (Wang et al., 16 Sep 2025), 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 (Shibli et al., 30 Apr 2026). “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 (Liao et al., 2024). 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 (Wang et al., 16 Sep 2025). In pseudo-block form, the input image is first passed through UpDM to obtain a reconstruction ; 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 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 (Wang et al., 16 Sep 2025). It takes a noisy sample at time step and predicts noise . Reconstruction is performed by a direct one-step inversion to , rather than through 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 and (Wang et al., 16 Sep 2025). Layer 0 uses an attention mask of size 1 and dilated convolution with dilation 2, while layer 3 stacks on 4’s output with mask size 5 and dilation 6. 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 7 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 (Wang et al., 16 Sep 2025). The final probability 8 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 (Wang et al., 16 Sep 2025). The forward noising process is
9
The reverse process is parameterized by 0 as
1
After predicting 2 at a randomly sampled timestep 3, End4 reconstructs the input by a direct one-step inversion:
4
The training objective contains two terms: a noise-prediction loss and a binary classification loss (Wang et al., 16 Sep 2025). The noise-prediction loss is applied only to inpainting samples:
5
where 6 for inpainted images and 7 for natural images. The classification loss is binary cross-entropy:
8
The combined objective is
9
The selective application of 0 to inpainted images is not incidental. An ablation reported in the paper states that noise-loss targeting only inpainting images yields best accuracy 1 versus applying it to both classes or to naturals only (Wang et al., 16 Sep 2025). 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 (Wang et al., 16 Sep 2025). 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 2 and the reconstructed image 3.
Its first stage is a two-level pyramid. If 4 and 5 denote the ResNet50 features from the original and reconstructed branches, the pyramid produces
6
and
7
Self-attention is then applied to the stacked features at each scale. For 8, if 9 are linear projections of the stacked features, the attention update is
0
The resulting scale-aware features are denoted 1 and 2. Multi-head cross-attention is then computed in both directions:
- 3
- 4
These are concatenated to form the fused representation 5.
The ablation evidence makes the role of SPFM unusually clear. On the reported benchmark, replacing SPFM with absolute difference gives approximately 6 accuracy, simple concatenation gives approximately 7, and SPFM gives approximately 8 (Wang et al., 16 Sep 2025). 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 9 images split into 0 train and 1 test (Wang et al., 16 Sep 2025). 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 2 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 (Wang et al., 16 Sep 2025). 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 3 input (Wang et al., 16 Sep 2025). The batch size is 4, the learning rate is 5, the diffusion timesteps are 6 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 (Wang et al., 16 Sep 2025).
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 (Wang et al., 16 Sep 2025). 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 (Wang et al., 16 Sep 2025). 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 7 and all accuracies around 8 to 9 (Wang et al., 16 Sep 2025). Within this setting, End4 clearly outperforms the listed baselines.
Robustness results indicate that End4 maintains 0 AUC under JPEG compression with 1, Gaussian blur with 2, saturation changes with factor in 3, and contrast shifts with factor in 4 (Wang et al., 16 Sep 2025). 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 (Wang et al., 16 Sep 2025). 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 (Wang et al., 16 Sep 2025). 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 (Shibli et al., 30 Apr 2026). 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 5 denoising steps at inference while achieving 6 PDMS and real-time speed of 7 FPS on an NVIDIA 4090 (Liao et al., 2024). “E2ED8” 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 (Tan et al., 2024).
These works are technically heterogeneous. End4 uses one-step denoising as a reconstruction-aligned forensic feature learner (Wang et al., 16 Sep 2025). Noise2Map avoids iterative sampling and directly predicts discriminative maps from noisy inputs (Shibli et al., 30 Apr 2026). DiffusionDrive uses truncated denoising from anchored Gaussian mixtures for planning (Liao et al., 2024). E2ED9 treats the entire diffusion chain as a differentiable function from isotropic Gaussian noise to data (Tan et al., 2024). 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 (Wang et al., 16 Sep 2025), Noise2Map performs one-shot inference (Shibli et al., 30 Apr 2026), and DiffusionDrive reports superior diversity and quality in just 0 steps (Liao et al., 2024). 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 (Wang et al., 16 Sep 2025). In that sense, End4 is both a specific method and an instance of a wider methodological realignment in diffusion-based learning.