ConvIR-B trained on O-Haze
Demo: this checkpoint on the 5 O-Haze test images (full views and detail crops), wiping from the hazy input to the model output, with each image's PSNR against the ground truth. Rendered with the official code.
Unofficial mirror of the official ConvIR weights from c-yn/ConvIR. The weights are unchanged; this repository adds a weights-only
model.safetensorscopy, aconfig.json, an independent evaluation and rendered examples.
Model
- Architecture: ConvIR, ConvIR-B (base)
- Task: single image dehazing
- Trained on: O-Haze (NTIRE 2018, 45 real hazy/clean pairs made with a haze machine), images 41-45 held out
- Dataset on the Hub: O-Haze (our mirror)
- Parameters: 8.63M
- Paper: Revitalizing Convolutional Network for Image Restoration (IEEE TPAMI 2024)
- Code: https://github.com/c-yn/ConvIR
- License: MIT (from the official repository)
ConvIR is a purely convolutional three-scale U-Net in the multi-input, multi-output style: the image enters at full, 1/2 and 1/4 resolution and the network predicts a residual at each scale, so it returns three outputs (the last one is the full-resolution result). The last residual block of every stage holds a deep pooling layer: features pooled by 8, 4 and 2 pass through multi-shape kernels (input-dependent square filters plus horizontal and vertical strip attention) that split low- and high-frequency content. Small, base and large use 4, 8 and 16 residual blocks per stage.
Results
On O-Haze images 41-45 (5 pairs, full resolution):
| PSNR (dB) | SSIM | |
|---|---|---|
| Reported in the official README | 25.36 | 0.780 |
| Measured for this mirror | 25.35 | 0.934 |
The PSNR matches the README. The README's O-Haze SSIM is not what the official eval.py computes: eval.py average-pools these large images (about 4,600 x 3,000) before SSIM and gives the value in our table, while SSIM computed at full resolution gives 0.79 for ConvIR-S, in line with the README. The README's I-Haze SSIM does match eval.py, so the O-Haze figures appear to come from a different SSIM setting. We ran the official checkpoint with the official model code and reproduced the official eval.py: the input is reflect-padded on the right and bottom to a multiple of 32 and the full-resolution output (the last of the three) is cropped back, PSNR is 10 * log10(1 / MSE) on the clamped output and SSIM is pytorch-msssim on images average-pooled by round(min(H, W) / 256) of the padded size, as the authors do. Evaluated on the O-HAZE subset of our NTIRE-Haze mirror.
Files
| File | Content |
|---|---|
ohaze-base.pkl |
original checkpoint, exactly as released ({"model": state_dict}) |
model.safetensors |
the model weights, bit-exact, nothing else |
config.json |
architecture, data, results and provenance (including the SHA-256 of the original file) |
assets/ |
demo video, poster and the examples grid above |
Usage
The model code lives in the official repository; clone it:
git clone https://github.com/c-yn/ConvIR
import sys
import numpy as np
import torch
import torch.nn.functional as F
from huggingface_hub import hf_hub_download
from PIL import Image
from safetensors.torch import load_file
sys.path.insert(0, "ConvIR/Dehazing/ITS")
from models.ConvIR import build_net
net = build_net('base', 'ITS')
net.load_state_dict(load_file(hf_hub_download("dronefreak/convir-b-o-haze", "model.safetensors")))
net.eval()
img = np.asarray(Image.open("input.png").convert("RGB"), dtype=np.float32) / 255.0
x = torch.from_numpy(img).permute(2, 0, 1)[None]
h, w = x.shape[2:]
x = F.pad(x, (0, -w % 32, 0, -h % 32), mode="reflect") # sides must be multiples of 32
with torch.no_grad():
y = net(x)[2][:, :, :h, :w].clamp(0, 1) # outputs at 1/4, 1/2 and full size; keep the last
Image.fromarray((y[0].permute(1, 2, 0).numpy() * 255).round().astype(np.uint8)).save("output.png")
To use the original file instead:
sd = torch.load(hf_hub_download("dronefreak/convir-b-o-haze", "ohaze-base.pkl"), map_location="cpu")["model"]
net.load_state_dict(sd)
O-Haze has only 45 image pairs from one haze-machine setup, so expect limited generalisation to other kinds of haze.
All mirrors of Yuning Cui's restoration models
PSNR / SSIM as measured by us with the authors' evaluation code on each checkpoint's test set (Y channel for deraining, shown on Rain100H).
| Repository | Model | Trained on | Task | Params | Test set | PSNR / SSIM |
|---|---|---|---|---|---|---|
| convir-s-reside-its | ConvIR-S | RESIDE-ITS | dehazing | 5.53M | SOTS indoor | 41.53 / 0.996 |
| convir-s-csd | ConvIR-S | CSD | desnowing | 5.53M | CSD test | 38.43 / 0.988 |
| convir-s-dense-haze | ConvIR-S | Dense-Haze | dehazing | 5.53M | Dense-Haze | 17.45 / 0.648 |
| convir-s-nh-haze | ConvIR-S | NH-Haze | dehazing | 5.53M | NH-Haze | 20.65 / 0.806 |
| convir-s-i-haze | ConvIR-S | I-Haze | dehazing | 5.53M | I-Haze | 21.95 / 0.888 |
| convir-s-o-haze | ConvIR-S | O-Haze | dehazing | 5.53M | O-Haze | 25.25 / 0.937 |
| convir-b-reside-its | ConvIR-B | RESIDE-ITS | dehazing | 8.63M | SOTS indoor | 42.72 / 0.997 |
| convir-b-csd | ConvIR-B | CSD | desnowing | 8.63M | CSD test | 39.10 / 0.990 |
| convir-b-dense-haze | ConvIR-B | Dense-Haze | dehazing | 8.63M | Dense-Haze | 16.86 / 0.621 |
| convir-b-nh-haze | ConvIR-B | NH-Haze | dehazing | 8.63M | NH-Haze | 20.66 / 0.802 |
| convir-b-i-haze | ConvIR-B | I-Haze | dehazing | 8.63M | I-Haze | 22.45 / 0.887 |
| convir-b-o-haze (this repo) | ConvIR-B | O-Haze | dehazing | 8.63M | O-Haze | 25.35 / 0.934 |
| convir-l-rain13k | ConvIR-L | Rain13K | deraining | 14.83M | Rain100H | 31.10 / 0.903 |
| oknet-reside-its | OKNet | RESIDE-ITS | dehazing | 4.72M | SOTS indoor | 40.79 / 0.996 |
| oknet-csd | OKNet | CSD | desnowing | 4.72M | CSD test | 37.99 / 0.988 |
| oknet-dense-haze | OKNet | Dense-Haze | dehazing | 4.72M | Dense-Haze | 16.92 / 0.643 |
| oknet-nh-haze | OKNet | NH-Haze | dehazing | 4.72M | NH-Haze | 20.48 / 0.804 |
| oknet-i-haze | OKNet | I-Haze | dehazing | 4.72M | I-Haze | 21.72 / 0.870 |
| oknet-o-haze | OKNet | O-Haze | dehazing | 4.72M | O-Haze | 25.64 / 0.939 |
| sfnet-reside-its | SFNet | RESIDE-ITS | dehazing | 13.27M | SOTS indoor | 41.24 / 0.996 |
| sfnet-rain13k | SFNet | Rain13K | deraining | 13.27M | Rain100H | 31.86 / 0.908 |
Citation
If you use these weights, please cite the original work:
@article{cui2024revitalizing,
title = {Revitalizing Convolutional Network for Image Restoration},
author = {Cui, Yuning and Ren, Wenqi and Cao, Xiaochun and Knoll, Alois},
journal = {IEEE Transactions on Pattern Analysis and Machine Intelligence},
year = {2024}
}
Disclaimer
This is not an official release. All credit goes to the original authors (Yuning Cui, Wenqi Ren, Xiaochun Cao, Alois Knoll). The weights are redistributed under the MIT license of the official repository (copyright Yuning Cui). If you are an author and want this mirror changed or removed, please open a discussion.
- Downloads last month
- 2
