Views
No views yet
.pth checkpoints from the v0.0 GitHub release → torch.onnx.export (one pass per variant) → these files.torch 2.4.x (CUDA 12.4), timm latest, onnx latest, onnxruntime>=1.17, opset 17, do_constant_folding=True, dynamo=False (forces the legacy TorchScript-based exporter; SwinIR's .type_as() buffer coercions trip the dynamo path's name-lineage tracking on torch >=2.5). Full conversion script: scripts/export-swinir.ps1 in the Heliosoph repo.| File | Variant | Input → Output | Use |
|---|---|---|---|
swinir_realsr_x4.onnx | SwinIR-L real-SR (4×) | 64×64 RGB → 256×256 RGB | Real-world image super-resolution (handles compression artifacts, sensor noise, mild blur as a side effect). ~110 MB. |
swinir_denoising_color_25.onnx | SwinIR-M color DN | 128×128 RGB → 128×128 RGB | Color denoising at Gaussian noise σ=25 — the standard denoising-benchmark reference. ~45 MB. |
[0, 1]) — only the spatial dims differ.swinir_realsr_x4.onnx | swinir_denoising_color_25.onnx | |
|---|---|---|
| Input name | image | image |
| Input shape | [batch, 3, 64, 64] | [batch, 3, 128, 128] |
| Input dtype | float32 | float32 |
| Input range | [0, 1] RGB | [0, 1] RGB |
| Output name | upscaled | denoised |
| Output shape | [batch, 3, 256, 256] | [batch, 3, 128, 128] |
| Dynamic axes | batch only | batch only |
1import onnxruntime as ort
2import numpy as np
3from PIL import Image
4
5# Pick the variant
6sess = ort.InferenceSession("swinir_denoising_color_25.onnx")
7# or:
8# sess = ort.InferenceSession("swinir_realsr_x4.onnx")
9
10img = Image.open("noisy.jpg").convert("RGB").resize((128, 128))
11arr = np.asarray(img, dtype=np.float32) / 255.0 # HWC, [0,1]
12arr = arr.transpose(2, 0, 1)[None, ...] # 1x3xHxW
13
14result = sess.run(None, {"image": arr.astype(np.float32)})[0][0]
15result = np.clip(result, 0.0, 1.0).transpose(1, 2, 0) # back to HWC
16result_img = Image.fromarray((result * 255).astype(np.uint8))main_test_swinir.py for a reference tiling implementation.swinir_denoising_color_25.onnx — when you specifically want the Gaussian σ=25 reference denoiser (research papers, benchmark reproduction, comparing against other denoisers).swinir_realsr_x4.onnx — when you want 4× super-resolution on real-world photos and don't mind that it'll also clean up some noise / compression artifacts in the process.noise25 variant is trained for a specific noise level and degrades when the input noise pattern differs.JingyunLiang/SwinIR repo. LICENSE file included.