Downloads · 30 days
107
19% of all-time downloads
FengShaner/DehazeSNN
DehazeSNN is a image-to-image model from FengShaner. Use it when you need one image transformed into another. It is set up for pytorch. The card lists the license as mit.
U-Net-Like Spiking Neural Networks for Single Image Dehazing
Downloads · 30 days
107
19% of all-time downloads
All-time downloads
558
Public
Parameters
4.8M
110 MB on disk
Likes
2
Trending 1
Click a slice to open those files.
.safetensors19.3 MB · 100%
From the Hugging Face model README
U-Net-Like Spiking Neural Networks for Single Image Dehazing
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.
| 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") |
# 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
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")
cupy-cuda12x (for CUDA 12.x) - CPU-only inference is not supported.| Variant | Depths | Parameters |
|---|---|---|
| M (Medium) | [8, 12, 16, 12, 8] | 2.70M |
| L (Large) | [8, 16, 32, 16, 8] | 4.75M |
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}
}
This project is released under the MIT License.