TL;DR
DiffEx is a novel explainability framework that pairs diffusion models with contrastive learning to uncover the specific visual attributes driving a classifier's decisions. By identifying disentangled semantic directions in a latent space, it successfully extracts subtle, fine-grained biological phenotypes from complex microscopy images where traditional explainability methods fail.
What Problem Does This Paper Address?
Deep learning classifiers are incredibly powerful tools in biology, capable of distinguishing between healthy and diseased cells or identifying complex treatment effects. However, these models operate as "black boxes." Traditional explainability methods like Class Activation Maps (CAMs) only highlight where a model looks, failing to explain what features (such as changes in cell shape, size, or texture) actually influenced the decision.
While generative approaches like Generative Adversarial Networks (GANs) can create counterfactual images to visualize these changes, they suffer from training instability. Furthermore, existing diffusion-based explanation methods struggle with the high biological variability found across different cell samples, often failing to generate high-quality, meaningful counterfactuals for complex biological datasets.
Methods
DiffEx introduces a three-stage pipeline to generate interpretable, classifier-aware visual explanations:
- Classifier-Aware Semantic Latent Space: The authors train an encoder alongside a Denoising Diffusion Implicit Model (DDIM). The encoder maps an input image to a latent space, which is then concatenated with the classifier's prediction score to form a semantic code ($z_{sem}$). The model is optimized using both a standard diffusion loss and a classifier loss (KL divergence) to ensure generated images preserve the classifier's original predictions.
- Contrastive Learning for Attribute Disentanglement: To find distinct visual attributes, DiffEx uses a self-supervised contrastive learning approach within the encoder's latent space. Multi-layer perceptrons (MLPs) learn directional shifts ($\Delta z_k$). A contrastive loss forces shifts representing the same attribute to cluster together, while forcing different attributes to repel each other. A regularization term minimizes covariance to ensure the discovered directions are completely decorrelated.
- Direction Ranking: Discovered directions are ranked by shifting images along them and measuring the average change in the classifier's output score, isolating the most influential attributes.
Datasets
The method was evaluated on three distinct datasets:
- FFHQ: A standard benchmark of 70,000 high-resolution human face images, used to evaluate the method on a natural image gender classification task.
- BBBC021: A public fluorescent microscopy dataset of MCF-7 breast cancer cells, comparing untreated cells against cells treated with the compound Latrunculin B.
- Golgi: A microscopy dataset of HeLa cells (untreated vs. Nocodazole-treated) exhibiting highly subtle structural changes (Golgi apparatus scattering).
Key Insights and Ideas
- Classifier-Conditioned Generation: Merely using a generative model to create counterfactuals isn't enough. Explicitly forcing the diffusion latent space to be "classifier-aware" via a KL-divergence loss prevents the generation of adversarial artifacts and ensures semantic fidelity.
- Contrastive Disentanglement: Contrastive learning can be effectively repurposed to discover unsupervised, interpretable semantic vectors directly inside a diffusion encoder's latent space, removing the need for manual attribute labeling.
- Deconstructing Complex Phenotypes: Instead of showing a single, monolithic "treated vs. untreated" transformation, DiffEx breaks down complex biological responses into distinct visual components (e.g., separating cytoplasm reduction from nuclear clustering), making it easier for biologists to interpret drug effects.
Key Results
- High Fidelity & Accuracy: DiffEx achieved excellent image reconstruction quality across all datasets (e.g., an SSIM of 1.0 on FFHQ and Golgi, and 0.99 on BBBC021) while maintaining near-perfect classification accuracy on the generated images.
- Outperforming the State-of-the-Art: When compared to Global Counterfactual Directions (GCD), DiffEx demonstrated superior performance. While GCD completely failed to generate meaningful counterfactual images for the highly variable biological datasets, DiffEx successfully uncovered subtle cellular variations, achieving a Kernel Inception Distance (KID) of 0.032 on the Golgi dataset.
- Phenotype Replication: In the BBBC021 dataset, DiffEx successfully isolated known drug toxicity effects, such as the complete elimination of cytoplasm and nuclear clustering. For the Golgi dataset, it accurately simulated the scattering and aggregation of the Golgi apparatus induced by Nocodazole treatment.
Limitations and Future Work
- Channel Limitations: On the Golgi dataset, all discovered directions ended up replicating the exact same phenotype. The authors note this lack of variety might be due to the limited information available in the dataset, which only utilized two imaging channels (green and blue).
- Future Directions: The authors suggest extending DiffEx to other complex domains beyond biology where explaining black-box classifier outputs is critical for safety, compliance, or scientific discovery.
Summary updated