Skip to content

This repository contains the implementation of WSGraphCL, a weak-strong graph contrastive learning model designed for hyperspectral image (HSI) classification.

Notifications You must be signed in to change notification settings

zhu-xlab/WSGraphCL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WSGraphCL: Weak-Strong Graph Contrastive Learning for Hyperspectral Image Classification

Python

This repository contains the implementation of WSGraphCL, a weak-strong graph contrastive learning model designed for hyperspectral image (HSI) classification. The model is built to effectively handle noisy HSI data and requires only a limited amount of labeled data, making it particularly suitable for few-shot learning scenarios. For more details, please refer to our paper.

Table of Contents

Introduction

Hyperspectral images contain rich spectral and spatial information, making them valuable for various remote sensing applications. However, accurately classifying fine-grained land cover types in noisy HSIs remains challenging. Existing deep learning models often struggle with feature extraction from noisy data and require large labeled datasets for training.

To tackle these challenges, we propose WSGraphCL, a novel model that integrates contrastive learning and graph neural networks (GNNs). By leveraging weak-strong augmentations and filtering false negative pairs, our method stabilizes the pre-training process and learns robust representations. This enables effective HSI classification with minimal labeled data.

Model Pipeline

Key Features

  • Graph Neural Network Architecture: Utilizes a spectral-spatial adjacency matrix to construct K-hop subgraphs for effective feature extraction.
  • Contrastive Learning: Pre-trains a graph-based encoder on unlabeled HSI data, reducing the need for extensive manual annotations.
  • Weak-Strong Augmentations: Enhances the quality of learned representations by leveraging diverse augmentations during training.
  • Few-Shot Learning: Demonstrates superior performance even with a handful of labeled samples, addressing the challenge of data scarcity.

Installation

Clone the repository and install the required packages:

git clone https://github.com/zhu-xlab/WSGraphCL.git
cd WSGraphCL
pip install -r requirements.txt

Please note: requirements.txt is built on the Linux system, please find the matched PyTorch version with CUDA devices. These are the necessary Python libraries that users can install manually. Please use conda install instead of pip install if the package requires other dependencies.

anaconda, conda, dive-into-graphs, h5py, geopandas, ipykernel, matplotlib, numpy, pandas, Pillow, pyscf, scikit-imag, scikit-learn, scipy, tifffile, torch, torch_cluster, torch_geometric, torch_scatter, torch_sparse, torchaudio, torchmetrics, torchvision, tqdm, typing, thop, fvcore, math, datetime, time, copy

Usage

Preprocessing

Prepare the Dataset: Download and prepare your hyperspectral dataset. MDAS dataset can be downloaded from here. Ensure it is in the correct format as expected by the data loader.

Training

To train the WSGraphCL model, use the following .ipynb files:

1. model/Indian_pines_mainfile.ipynb
2. model/Pavia_uni_mainfile.ipynb
3. model/MDAS_mainfile.ipynb

Experiments

We conducted extensive experiments to validate the effectiveness of WSGraphCL under various few-shot scenarios. Our model consistently outperformed several baseline methods on benchmark HSI datasets.

Citation

If you find this work useful, please consider citing our paper:

@ARTICLE{10988682,
  author={Wang, Sirui and Braham, Nassim Ait Ali and Zhu, Xiao Xiang},
  journal={IEEE Transactions on Geoscience and Remote Sensing}, 
  title={Weak–Strong Graph Contrastive Learning Neural Network for Hyperspectral Image Classification}, 
  year={2025},
  volume={63},
  number={},
  pages={1-17},
  keywords={Hyperspectral imaging;Contrastive learning;Feature extraction;Image classification;Training;Adaptation models;Earth;Data models;Noise;Image edge detection;Contrastive learning (CL);deep learning;graph neural networks (GNNs);hyperspectral image (HSI) classification;self-supervised learning (SSL)},
  doi={10.1109/TGRS.2025.3562261}}

License

About

This repository contains the implementation of WSGraphCL, a weak-strong graph contrastive learning model designed for hyperspectral image (HSI) classification.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published