Vision Mamba Mender

January 15, 2025 Β· View on GitHub

For more information, please visit https://vision-mamba-mender.github.io/.

Requirements

  • causal_conv1d: pip install causal-conv1d
  • mamba: pip install mamba-ssm
  • pip install -U openmim
  • mim install mmcv
  • pip install mmsegmentation
  • pip install mmengine
  • pip install ftfy

Algorithms

🐍 Preparation

  1. Train a pre-trained model:
bash scripts/train.sh
  1. Select high-confidence samples and low-confidence samples:
bash scripts/sample_selection.sh
  1. Extract intermediate features from the model, including activations and gradients of samples:
bash scripts/feature_selection.sh

πŸ” Interpreting

  1. Visualize external interactions of states or internal interactions of states
bash state_external_visualize.sh
bash state_internal_visualize.sh
  1. Binarize external interactions of states or internal interactions of states
bash state_external_mask.sh
bash state_internal_mask.sh # Steps necessary for calibration!
  1. Compute interpretability scores for external interactions of states or internal interactions of states
bash state_external_score.sh
bash state_internal_score.sh

πŸ”§ Calibrating

  1. Calibrate external interactions of states or internal interactions of states
bash scripts/train_repair.sh

Future Plans

This repository contains the initial version of the code for the Vision Mamba Mender paper. Please stay tuned for further refinements and detailed explanations in future updates.

Others

  • The directory structure of the files outputted by the algorithm:
output_path # Overall output directory as defined by you
    β”œβ”€β”€ exp_name # Experiment name defined by you
            β”œβ”€β”€ models
            βŽͺ       └── xxx.pth       
            β”œβ”€β”€ samples
            βŽͺ       β”œβ”€β”€ htrain # Selected high-confidence samples
            βŽͺ       └── ltrain # Selected low-confidence samples
            β”œβ”€β”€ features
            βŽͺ       β”œβ”€β”€ hdata # Selected intermediate features of the high-confidence samples
            βŽͺ       βŽͺ       └── xxx.pkl 
            βŽͺ       └── ldata # Selected intermediate features of the low-confidence samples
            β”œβ”€β”€ visualize
            βŽͺ       β”œβ”€β”€ hdata
            βŽͺ       βŽͺ       β”œβ”€β”€ external # Visualization results of external interactions of states
            βŽͺ       βŽͺ       βŽͺ       └── xxx.JPEG/PNG
            βŽͺ       βŽͺ       └── internal # Visualization results of internal interactions of states
            βŽͺ       └── ldata # Same as above
            β”œβ”€β”€ masks
            βŽͺ       β”œβ”€β”€ hdata
            βŽͺ       βŽͺ       β”œβ”€β”€ external # Binarization results of external interactions of states
            βŽͺ       βŽͺ       βŽͺ       └── xxx.pt
            βŽͺ       βŽͺ       └── internal # Binarization results of internal interactions of states
            βŽͺ       └── ldata # Same as above
            └── scores
                    β”œβ”€β”€ hdata
                    βŽͺ       β”œβ”€β”€ external # Interpretability scores of external interactions of states
                    βŽͺ       βŽͺ       └── xxx.PNG
                    βŽͺ       └── internal # Interpretability scores of internal interactions of states
                    └── ldata # Same as above