Package: bim
BIM - Benchmark Interpretability MethodThis repository contains dataset, models, and metrics for benchmarking
interpretability methods (BIM) described in paper:Title: "BIM: Towards Quantitative Evaluation of Interpretability Methods
with Ground Truth"Authors: Sherry (Mengjiao) Yang, Been KimUpon using this library, please cite:@Article{BIM2019,
  title = {{BIM: Towards Quantitative Evaluation of Interpretability Methods with Ground Truth}},
  author = {Yang, Mengjiao and Kim, Been},
  year = {2019}
}SetupRun the following from the home directory of this repository to install python
dependencies, download BIM models, downloadMSCOCOandMiniPlaces, and construct BIM
dataset.pip install bim
source scripts/download_models.sh
source scripts/download_datasets.sh
python scripts/construct_bim_dataset.pyDatasetImages indata/objanddata/sceneare the same but have object and scene
labels respectively, as shown in the figure above.val_loc.txtrecords the
top-left and bottom-right corner of the object andval_maskhas the binary
masks of the object in the validation set. Additional sets and their usage are
described in the table below.NameTrainingValidationUsageDescriptionobj90,00010,000Model contrastObjects and scenes with object labelsscene90,00010,000Model contrast & Input dependenceObjects and scenes with scene labelsscene_only90,00010,000Input dependenceScene-only images with scene labelsdog_bedroom-200Relative model contrastDog in bedroom labeled as bedroombamboo_forest-100Input independenceScene-only images of bamboo forestbamboo_forest_patch-100Input independenceBamboo forest with functionally insignificant dog patchModelsModels inmodels/obj,models/scene, andmodels/scene_onlyare trained ondata/obj,data/scene, anddata/scene_onlyrespectively. Models inmodels/sceneiforiin{1...10}are trained on images where dog is added
toiscene classes, and the rest scene classes do not contain any added
objects. All models are in TensorFlow'sSavedModelformat.MetricsBIM metrics compare how interpretability methods perform across models (model
contrast), across inputs to the same model (input dependence), and across
functionally equivalent inputs (input independence).Model contrast scoresGiven images that contain both objects and scenes, model contrast measures the
difference in attributions between the model trained on object labels and the
model trained on scene labels.Input dependence rateGiven a model trained on scene labels, input dependence measures the percentage
of inputs where the addition of objects results in the region being attributed
as less important.Input independence rateGiven a model trained on scene-only images, input independence measures the
percentage of inputs where a functionally insignificant patch (e.g., a dog) does
not affect explanations significantly.Evaluate saliency methodsTo compute model contrast score (MCS) over randomly selected 10 images, you can
runpython bim/metrics.py --metrics=MCS --num_imgs=10To compute input dependence rate (IDR), change--metricstoIDR. To compute
input independence rate (IIR), you need to first constructs a set of
functionally insignificant patches by runningpython scripts/construct_delta_patch.pyand then evaluate IIR by runningpython bim/metrics.py --metrics=IIR --num_imgs=10Evaluate TCAVTCAVis a global concept attribution
method whose MCS can be measured by comparing the TCAV scores of a particular
object concept for the object model and the scene model. Run the following to
compute the TCAV scores of the dog concept for the object model.python bim/run_tcav.py --model=objDisclaimerThis is not an officially supported Google product.