FeatInv: Spatially resolved mapping from feature space to input space using conditional diffusion models

Nils Neukirch, Johanna Vielhaben, Nils Strodthoff

TL;DR

FeatInv introduces a powerful method to invert the internal feature representations of vision models back into high-fidelity images using conditional diffusion models. By preserving the spatial resolution of feature maps rather than pooling them, it provides a probabilistic, visually accurate window into how CNNs and ViTs perceive the world, opening up new avenues for concept steering and feature space analysis.

What Problem Does This Paper Address?

Deep neural networks are notoriously difficult to interpret. To understand their inner workings, researchers often try to map internal feature representations back to the input space (images)—a process known as feature inversion.

However, existing approaches suffer from major drawbacks: they either discard crucial spatial details by using average-pooled global feature maps, rely on crude deterministic approximations that ignore the inherent uncertainty of the inversion problem, or fail to leverage state-of-the-art generative models. FeatInv addresses these gaps by creating a faithful, probabilistic mapping that preserves fine-grained spatial structures, allowing us to see exactly what information a specific layer retains.

Methods

FeatInv leverages a ControlNet architecture built on top of a frozen, pretrained text-to-image diffusion model (MiniSD).

Schematic overview of the FeatInv approach

Key components of the pipeline include:

  • Spatially Resolved Conditioning: Instead of global vectors, the model conditions on the unpooled, spatially resolved feature maps ($c_f$) from the penultimate layer of a target vision model (e.g., ResNet50, ConvNeXt, SwinV2).
  • Conditional Input Encoder: A shallow convolutional network combined with bilinear upsampling bridges the spatial resolution gap between the classifier's low-resolution feature map and the diffusion model's latent space.
  • Generic Prompting: To avoid class-specific bias and rely purely on the feature map's information, the diffusion model is fed a generic text prompt: "a high-quality, detailed and professional image".
  • Probabilistic Sampling: Because it uses a diffusion model, FeatInv can generate multiple diverse image variations from a single feature map, capturing the ill-posed nature of the inversion problem.

Datasets

The authors evaluated FeatInv across several benchmarks to test fidelity and robustness:

  • ImageNet: The primary dataset used for training the ControlNet and evaluating standard reconstruction performance.
  • BAID (Beauty Aesthetics Image Dataset): Used to test how well the model generalizes to out-of-distribution (OOD) artistic styles.
  • ImageNet-A: A dataset of natural adversarial images used to evaluate performance on complex, misleading samples.
  • ImageNet-C: Used to benchmark robustness against common image corruptions like blur, noise, and weather effects.

Key Insights and Ideas

  • Spatial Resolution is Crucial: Retaining unpooled spatial tokens is the "secret sauce." Moving from pooled to unpooled features causes the image generation quality (FID) to plummet (lower is better) and classification alignment to skyrocket.
  • Modern Backbones "See" More Coherently: Modern architectures like ConvNeXt and SwinV2 yield significantly more detailed and faithful reconstructions than older architectures like ResNet50. This suggests a qualitative leap in how modern models organize deep semantic features.
  • Concept Steering in Input Space: By isolating a linear concept subspace (e.g., "sky" or "bird head") and attenuating it directly in the feature space, FeatInv can visually mask out or alter that specific concept in the generated image. This provides a much sharper, high-resolution alternative to traditional coarse activation maps.
FeatInv-Viz concept steering visualization
  • Localized Feature Arithmetic: Linearly interpolating or spatially mixing feature maps from two different images results in coherent composite images (e.g., placing a foreground object from one image onto the background of another), proving that the feature space is highly localized.

Key Results

FeatInv achieves state-of-the-art fidelity when reconstructing images from deep feature spaces:

  • Quantitative Performance: For ConvNeXt, unpooled FeatInv achieved a cosine similarity of 0.61, a 94% top-5 match with the original classifier's predictions, and an exceptional FID score of 8.20. SwinV2 achieved a 95% top-5 match and an FID of 12.69.
  • Unpooled vs. Pooled: In comparison, pooled variants performed poorly, with top-5 classification matches dropping to ~44-48% and FID scores degrading to the 31–49 range.
Figure 3: Qualitative comparison of reconstructed samples for the ResNet50, ConvNeXt, SwinV2 and ConvNeXt pooled models. The cosine similarity of the original feature map and that of the reconstruction is noted at the bottom edge of the images. The qualitative comparison confirms the insights from the quantitative analysis in Tab. 1. The two modern vision backbones, ConvNeXt and SwinV2, show reconstructions that resemble the original very closely, not only in terms of semantic content and spatial alignment but also in terms of color schemes and finegrained details. Semantic content and composition also mostly matches in case of the ResNet50, but not even the semantic content seems to be captured when using pooled representations (ConvNeXt pooled as an example).
  • Robustness: The method demonstrated strong cross-model transferability and maintained semantic coherence even on OOD artistic data (BAID, FID 12.98) and adversarial images, though severe noise and contrast corruptions (ImageNet-C level 5) remain challenging.

Limitations and Future Work

  • Domain Restrictions: The current framework is bound to the natural image domain due to its reliance on the MiniSD prior. Extending FeatInv to specialized domains like medical imaging remains an open challenge.
  • Computational Bottleneck: A separate ControlNet must be trained for every unique model architecture and specific layer choice, which demands significant compute time.
  • Out-of-Distribution Vulnerability: The system lacks an explicit mechanism to detect when a manipulated feature map falls completely outside the valid distribution of the model, which can occasionally lead to visual hallucinations.

Summary updated

BibTeX
@article{neukirch2025featinv,
  author = {Nils Neukirch and Johanna Vielhaben and Nils Strodthoff},
  title = {{FeatInv: Spatially resolved mapping from feature space to input space using conditional diffusion models}},
  journal = {Accepted by TMLR},
  year = {2025},
  url = {https://openreview.net/forum?id=UtE1YnPNgZ},
}
Figure