FengShaner commited on
Commit
cfeaca9
·
verified ·
1 Parent(s): 7d69540

Update README.md

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