This is the official PyTorch implementation of the paper "SMG-Fusion: A Superpixel-guided Mixture of Experts Graph Network for Multi-Modality Image Fusion".
The directory structure is organized as follows:
SMG-Fusion/
├── models/ # Pre-trained SMG-Fusion weights (.pth)
├── test_img/ # Source images for inference
│ ├── MSRS/ # Dataset Name
│ │ ├── ir/ # Infrared images
│ │ └── vi/ # Visible images
│ └── ...
├── test_result/ # Output folder for fused images
├── utils/ # Utility scripts (image I/O, logger, etc.)
├── dataprocessing.py # Script to convert raw images to .h5 format for training
├── eval.py # Script for quantitative evaluation (Compute EN, SD, SSIM, etc.)
├── net.py # Backbone network definitions (Encoder/Decoder)
├── RGB.py # Tool to restore color from grayscale fusion results
├── smg_fusion.py # Core fusion network architecture (MS_GAT_Fusion)
├── test_IVF.py # Main inference script
└── train.py # Script for training the model
Please ensure you have Python and PyTorch installed. Install the required dependencies:
pip install torch torchvision opencv-python numpy h5py scipyIf you want to train on a custom dataset, organize your images and run the processing script to convert them into .h5 format:
python dataprocessing.pyTo train the SMG-Fusion model from scratch:
python train.pyThe training configurations (epochs, batch size, learning rate) can be modified inside train.py.
To fuse infrared and visible images:
- Place your source images in the
test_imgdirectory following this structure:- Infrared:
test_img/[Dataset_Name]/ir/ - Visible:
test_img/[Dataset_Name]/vi/
- Infrared:
- Open
test_IVF.pyand modify the dataset name/path variable to match your target folder (e.g.,'TNO'or'MSRS'). - Run the inference script:
python test_IVF.pyThe fused images will be saved in the test_result/ folder.
To calculate quantitative metrics (such as EN, SD, SF, SSIM, etc.) for the fused images, run the evaluation script:
python eval.pyYou can obtain the following performance metrics on the TNO dataset by running the evaluation program:
| Model | EN | SD | SF | MI | SCD | VIF | Qabf | SSIM | CC | AG | FMI | MS-SSIM |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| SMG | 7.10 | 44.53 | 13.57 | 2.68 | 1.63 | 0.83 | 0.61 | 1.31 | 0.49 | 5.01 | 1.51 | 1.36 |
Make sure to configure the paths to your ground truth (ir/vi) and generated fusion results inside eval.py before running.
Since the network processes images in grayscale to focus on structure and texture, the raw output might be single-channel. To restore the color information from the original visible image (YCbCr conversion), run:
python RGB.pyWe evaluated our method on the following public datasets:
If you have any questions, please contact: 2408540010@kmu.stu.edu.cn