Add l-reside-its checkpoint
Browse files- README.md +121 -0
- config.json +4 -0
- model.safetensors +3 -0
README.md
CHANGED
|
@@ -1,3 +1,124 @@
|
|
| 1 |
---
|
| 2 |
license: mit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: mit
|
| 3 |
+
tags:
|
| 4 |
+
- pytorch_model_hub_mixin
|
| 5 |
+
- model_hub_mixin
|
| 6 |
+
- image-dehazing
|
| 7 |
+
- spiking-neural-network
|
| 8 |
+
- computer-vision
|
| 9 |
+
pipeline_tag: image-to-image
|
| 10 |
---
|
| 11 |
+
|
| 12 |
+
# DehazeSNN
|
| 13 |
+
|
| 14 |
+
> U-Net-Like Spiking Neural Networks for Single Image Dehazing
|
| 15 |
+
|
| 16 |
+
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.
|
| 17 |
+
|
| 18 |
+
## Available Checkpoints
|
| 19 |
+
|
| 20 |
+
| Revision | Size | Dataset | Load Command |
|
| 21 |
+
|----------|------|---------|--------------|
|
| 22 |
+
| `main` | L | RESIDE-ITS | `DehazeSNNHub.from_pretrained("FengShaner/DehazeSNN")` |
|
| 23 |
+
| `l-reside-its` | L | RESIDE-ITS | `DehazeSNNHub.from_pretrained("FengShaner/DehazeSNN", revision="l-reside-its")` |
|
| 24 |
+
| `l-reside-ots` | L | RESIDE-OTS | `DehazeSNNHub.from_pretrained("FengShaner/DehazeSNN", revision="l-reside-ots")` |
|
| 25 |
+
| `l-reside-6k` | L | RESIDE-6k | `DehazeSNNHub.from_pretrained("FengShaner/DehazeSNN", revision="l-reside-6k")` |
|
| 26 |
+
| `l-rs-haze` | L | RS-Haze | `DehazeSNNHub.from_pretrained("FengShaner/DehazeSNN", revision="l-rs-haze")` |
|
| 27 |
+
| `m-reside-its` | M | RESIDE-ITS | `DehazeSNNHub.from_pretrained("FengShaner/DehazeSNN", revision="m-reside-its")` |
|
| 28 |
+
| `m-reside-6k` | M | RESIDE-6k | `DehazeSNNHub.from_pretrained("FengShaner/DehazeSNN", revision="m-reside-6k")` |
|
| 29 |
+
| `m-rs-haze` | M | RS-Haze | `DehazeSNNHub.from_pretrained("FengShaner/DehazeSNN", revision="m-rs-haze")` |
|
| 30 |
+
|
| 31 |
+
## Quick Start
|
| 32 |
+
|
| 33 |
+
### Installation
|
| 34 |
+
|
| 35 |
+
```bash
|
| 36 |
+
# Clone the DehazeSNN repository (for model code + custom CUDA kernels)
|
| 37 |
+
git clone https://github.com/FengShaner/DehazeSNN.git
|
| 38 |
+
cd DehazeSNN
|
| 39 |
+
|
| 40 |
+
# Create environment (requires CUDA 12.x)
|
| 41 |
+
conda create -n DehazeSNN python=3.11 -y
|
| 42 |
+
conda activate DehazeSNN
|
| 43 |
+
|
| 44 |
+
# Install PyTorch with CUDA 12.1
|
| 45 |
+
conda install pytorch=2.1.2 torchvision pytorch-cuda=12.1 -c pytorch -c nvidia -y
|
| 46 |
+
|
| 47 |
+
# Install dependencies
|
| 48 |
+
pip install huggingface_hub safetensors cupy-cuda12x timm
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
### Load and Run Inference
|
| 52 |
+
|
| 53 |
+
```python
|
| 54 |
+
import torch
|
| 55 |
+
from PIL import Image
|
| 56 |
+
import numpy as np
|
| 57 |
+
|
| 58 |
+
# Import from the cloned repository
|
| 59 |
+
from models.hub import DehazeSNNHub
|
| 60 |
+
|
| 61 |
+
# Load model (default: DehazeSNN-L trained on RESIDE-ITS)
|
| 62 |
+
model = DehazeSNNHub.from_pretrained("FengShaner/DehazeSNN")
|
| 63 |
+
model.cuda().eval()
|
| 64 |
+
|
| 65 |
+
# Load a different variant
|
| 66 |
+
# model = DehazeSNNHub.from_pretrained("FengShaner/DehazeSNN", revision="m-reside-6k")
|
| 67 |
+
|
| 68 |
+
# Prepare input image (RGB, normalized to [-1, 1])
|
| 69 |
+
img = Image.open("hazy_image.jpg").convert("RGB")
|
| 70 |
+
img_np = np.array(img).astype(np.float32) / 255.0
|
| 71 |
+
img_tensor = torch.from_numpy(img_np).permute(2, 0, 1).unsqueeze(0) # [1, 3, H, W]
|
| 72 |
+
img_tensor = (img_tensor - 0.5) / 0.5 # normalize to [-1, 1]
|
| 73 |
+
img_tensor = img_tensor.cuda()
|
| 74 |
+
|
| 75 |
+
# Inference
|
| 76 |
+
with torch.no_grad():
|
| 77 |
+
output = model(img_tensor).clamp(-1, 1)
|
| 78 |
+
|
| 79 |
+
# Convert output back to image
|
| 80 |
+
output = (output * 0.5 + 0.5).squeeze(0).permute(1, 2, 0).cpu().numpy()
|
| 81 |
+
output = (output * 255).astype(np.uint8)
|
| 82 |
+
Image.fromarray(output).save("dehazed_image.jpg")
|
| 83 |
+
```
|
| 84 |
+
|
| 85 |
+
## Requirements
|
| 86 |
+
|
| 87 |
+
- **CUDA GPU required**: The custom LIF CUDA kernels require an NVIDIA GPU with CUDA support
|
| 88 |
+
- **CuPy**: `cupy-cuda12x` (for CUDA 12.x) - CPU-only inference is **not supported**
|
| 89 |
+
- PyTorch >= 2.1 with CUDA 12.1
|
| 90 |
+
- Python 3.11 recommended
|
| 91 |
+
|
| 92 |
+
## Model Sizes
|
| 93 |
+
|
| 94 |
+
| Variant | Depths | Parameters |
|
| 95 |
+
|---------|--------|------------|
|
| 96 |
+
| S (Small) | [2, 4, 8, 4, 2] | ~2M |
|
| 97 |
+
| M (Medium) | [8, 12, 16, 12, 8] | ~7M |
|
| 98 |
+
| L (Large) | [8, 16, 32, 16, 8] | ~14M |
|
| 99 |
+
|
| 100 |
+
## Citation
|
| 101 |
+
|
| 102 |
+
If you find this work useful, please cite our paper:
|
| 103 |
+
|
| 104 |
+
```bibtex
|
| 105 |
+
@INPROCEEDINGS{11228727,
|
| 106 |
+
author={Li, Huibin and Liu, Haoran and Liu, Mingzhe and Xiao, Yulong and Li, Peng and Zan, Guibin},
|
| 107 |
+
booktitle={2025 International Joint Conference on Neural Networks (IJCNN)},
|
| 108 |
+
title={U-Net-Like Spiking Neural Networks for Single Image Dehazing},
|
| 109 |
+
year={2025},
|
| 110 |
+
pages={1-9},
|
| 111 |
+
doi={10.1109/IJCNN64981.2025.11228727}
|
| 112 |
+
}
|
| 113 |
+
```
|
| 114 |
+
|
| 115 |
+
## License
|
| 116 |
+
|
| 117 |
+
This project is released under the MIT License.
|
| 118 |
+
|
| 119 |
+
## Links
|
| 120 |
+
|
| 121 |
+
- [GitHub Repository](https://github.com/FengShaner/DehazeSNN)
|
| 122 |
+
- [Paper (IEEE IJCNN 2025)](https://doi.org/10.1109/IJCNN64981.2025.11228727)
|
| 123 |
+
- [Pretrained Models & Results (Zenodo)](https://doi.org/10.5281/zenodo.15486831)
|
| 124 |
+
|
config.json
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"dataset": "RESIDE-ITS",
|
| 3 |
+
"variant": "L"
|
| 4 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:30de1401c53dc52c1fc40b3860fdac025d3313f4f4d3be436b0dab5204d5dd21
|
| 3 |
+
size 19270012
|