DehazeSNN

U-Net-Like Spiking Neural Networks for Single Image Dehazing

[📄 Paper] [💻 GitHub]

DehazeSNN integrates a U-Net-like encoder-decoder architecture with Spiking Neural Networks (SNNs), using an Orthogonal Leaky-Integrate-and-Fire Block (OLIFBlock) for efficient cross-channel communication. This yields competitive dehazing quality with fewer parameters and MACs compared to Transformer-based methods.

Available Checkpoints

Revision Size Dataset Load Command
main L RESIDE-ITS DehazeSNNHub.from_pretrained("FengShaner/DehazeSNN")
l-reside-its L RESIDE-ITS DehazeSNNHub.from_pretrained("FengShaner/DehazeSNN", revision="l-reside-its")
l-reside-ots L RESIDE-OTS DehazeSNNHub.from_pretrained("FengShaner/DehazeSNN", revision="l-reside-ots")
l-reside-6k L RESIDE-6k DehazeSNNHub.from_pretrained("FengShaner/DehazeSNN", revision="l-reside-6k")
l-rs-haze L RS-Haze DehazeSNNHub.from_pretrained("FengShaner/DehazeSNN", revision="l-rs-haze")
m-reside-its M RESIDE-ITS DehazeSNNHub.from_pretrained("FengShaner/DehazeSNN", revision="m-reside-its")
m-reside-6k M RESIDE-6k DehazeSNNHub.from_pretrained("FengShaner/DehazeSNN", revision="m-reside-6k")
m-rs-haze M RS-Haze DehazeSNNHub.from_pretrained("FengShaner/DehazeSNN", revision="m-rs-haze")

Quick Start

Installation

# Clone the DehazeSNN repository (for model code + custom CUDA kernels)
git clone https://github.com/HaoranLiu507/DehazeSNN.git
cd DehazeSNN

# Create environment (requires CUDA 12.x)
conda create -n DehazeSNN python=3.11 -y
conda activate DehazeSNN

# Install PyTorch with CUDA 12.1
conda install pytorch=2.1.2 torchvision pytorch-cuda=12.1 -c pytorch -c nvidia -y

# Install dependencies
pip install huggingface_hub safetensors cupy-cuda12x timm

Load and Run Inference

import torch
from PIL import Image
import numpy as np

# Import from the cloned repository
from models.hub import DehazeSNNHub

# Load model (default: DehazeSNN-L trained on RESIDE-ITS)
model = DehazeSNNHub.from_pretrained("FengShaner/DehazeSNN")
model.cuda().eval()

# Load a different variant
# model = DehazeSNNHub.from_pretrained("FengShaner/DehazeSNN", revision="m-reside-6k")

# Prepare input image (RGB, normalized to [-1, 1])
img = Image.open("hazy_image.jpg").convert("RGB")
img_np = np.array(img).astype(np.float32) / 255.0
img_tensor = torch.from_numpy(img_np).permute(2, 0, 1).unsqueeze(0)  # [1, 3, H, W]
img_tensor = (img_tensor - 0.5) / 0.5  # normalize to [-1, 1]
img_tensor = img_tensor.cuda()

# Inference
with torch.no_grad():
    output = model(img_tensor).clamp(-1, 1)

# Convert output back to image
output = (output * 0.5 + 0.5).squeeze(0).permute(1, 2, 0).cpu().numpy()
output = (output * 255).astype(np.uint8)
Image.fromarray(output).save("dehazed_image.jpg")

Requirements

  • CUDA GPU required: The custom LIF CUDA kernels require an NVIDIA GPU with CUDA support.
  • CuPy: cupy-cuda12x (for CUDA 12.x) - CPU-only inference is not supported.
  • PyTorch >= 2.1 with CUDA 12.1.
  • Python 3.11 recommended.

Model Sizes

Variant Depths Parameters
M (Medium) [8, 12, 16, 12, 8] 2.70M
L (Large) [8, 16, 32, 16, 8] 4.75M

Citation

If you find this work useful, please cite our paper:

@INPROCEEDINGS{11228727,
  author={Li, Huibin and Liu, Haoran and Liu, Mingzhe and Xiao, Yulong and Li, Peng and Zan, Guibin},
  booktitle={2025 International Joint Conference on Neural Networks (IJCNN)}, 
  title={U-Net-Like Spiking Neural Networks for Single Image Dehazing}, 
  year={2025},
  pages={1-9},
  doi={10.1109/IJCNN64981.2025.11228727}
}

License

This project is released under the MIT License.

Downloads last month
32
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Paper for FengShaner/DehazeSNN