arrow_back Projects
PERSONAL // 2026 Duccio Meconcelli

Stable Diffusion 3.5 Feature Extractor

Python PyTorch Stable Diffusion 3.5 MMDiT Feature Extraction

Project Visualization

Stable Diffusion 3.5 Feature Extractor

Visit Live Sitearrow_outward
auto_awesome Abstract

A package for extracting hidden states and attention maps from Stable Diffusion 3.5 MM-DiT models for AI-image detection, attribution, and interpretability experiments.

Purpose

Stable Diffusion 3.5 Feature Extractor is a Python package for collecting internal representations from Stable Diffusion 3.5 MM-DiT models. I built it for my current work on AI-generated image detection, model attribution, and diffusion-model interpretability.

A detector usually sees only the final image. A diffusion model, by contrast, transforms that image through a sequence of latent representations and attention operations. These intermediate states may preserve traces of how generated content is organized, including information that is difficult to recover from pixels alone. The package makes those states available for controlled downstream experiments; it is the data-collection layer, not a finished detector.

Extraction controls

The extractor hooks into the joint transformer blocks of the MM-DiT architecture without changing the model weights. Users can select any subset of blocks; Stable Diffusion 3.5 Large exposes 38 of them. Image-branch hidden states, text-context states, and attention maps can be saved separately, which makes it possible to compare where useful detection signals appear inside the network.

Diffusion timestep is another explicit control. An image can be encoded and inspected close to its clean latent representation or after adding a chosen level of noise. This supports experiments on whether early and late diffusion states emphasize different visual or semantic properties.

Raw activations are large, so the package includes several ways to control storage and compute: mean pooling, image-only extraction, selectable layers, batch processing, and one Safetensors file per image. Preprocessing modes cover direct resizing, crop-and-resize workflows, and ImageNet-style preparation.

Research use

One practical risk in fake-image detection is learning a shortcut from file format or compression rather than from the image-generation process. The extractor therefore includes optional JPEG augmentation, allowing compression to vary during feature collection and making that source of bias easier to study.

I use the exported representations as inputs for downstream classifiers and attribution experiments. Keeping extraction separate from classification makes comparisons easier: the same stored features can be evaluated with different heads, layer combinations, pooling strategies, and train-test splits without repeatedly running the full diffusion model.

The project is still evolving with the research questions around it. The repository documents the command-line interface, Python API, model-download workflow, output naming, and examples for processing image folders.

Resource