DiffEx (CVPR 2025) – Official Repository
This repository contains the code for DiffEx, a diffusion-based framework for explaining image classifiers using semantic image edits.
pip install torch torchvision transformers diffusers pillowUse this only if you want to automatically extract high-level semantic categories from images.
python parent_semantic_ext.pyConverts flat categories from first step output into nested, fine-grained semantic keywords.
python expand_categories.py \
--in_json data_parent_semantic.json \
--out_json data_nested.jsonOutput: nested taxonomy JSON (required by DiffEx).
Main script. Applies diffusion-based edits and measures classifier sensitivity.
python diffex_run.py \
--taxonomy_json data_nested.json \
--image_path 0004.png \
--out_json diffex_output.json \
--clip_labels "male" "female" \
--clip_target_index 1