Delete README.md
Browse files
README.md
DELETED
|
@@ -1,88 +0,0 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: other
|
| 3 |
-
license_name: research-use
|
| 4 |
-
license_link: LICENSE
|
| 5 |
-
library_name: pytorch
|
| 6 |
-
pipeline_tag: image-to-image
|
| 7 |
-
tags:
|
| 8 |
-
- super-resolution
|
| 9 |
-
- image-super-resolution
|
| 10 |
-
- image-to-image
|
| 11 |
-
- pytorch
|
| 12 |
-
- onnx
|
| 13 |
-
datasets:
|
| 14 |
-
- eugenesiow/Div2k
|
| 15 |
-
model-index:
|
| 16 |
-
- name: srnet-x4
|
| 17 |
-
results:
|
| 18 |
-
- task:
|
| 19 |
-
type: image-to-image
|
| 20 |
-
name: Image super-resolution (x4)
|
| 21 |
-
dataset:
|
| 22 |
-
name: DIV2K validation (100 images, bicubic degradation)
|
| 23 |
-
type: eugenesiow/Div2k
|
| 24 |
-
metrics:
|
| 25 |
-
- type: psnr
|
| 26 |
-
name: PSNR (Y channel, shave 4)
|
| 27 |
-
value: 30.28
|
| 28 |
-
---
|
| 29 |
-
|
| 30 |
-
# SRNet x4 — small, fast single-image super-resolution
|
| 31 |
-
|
| 32 |
-
A compact residual CNN (~1.25 M parameters) that upscales images 4x. It predicts a residual on top of a bicubic upscale, so it starts from — and improves on — plain bicubic interpolation. Trained in 30 minutes on 2x T4 GPUs.
|
| 33 |
-
|
| 34 |
-
## Results
|
| 35 |
-
|
| 36 |
-
Evaluated on the 100 DIV2K validation images, full images, bicubic-x4 degradation, Y-channel PSNR with a 4 px border shave, 8-bit outputs:
|
| 37 |
-
|
| 38 |
-
| Method | PSNR (dB) |
|
| 39 |
-
|---|---|
|
| 40 |
-
| Bicubic | 28.23 |
|
| 41 |
-
| **SRNet x4** | **30.28** (+2.05) |
|
| 42 |
-
|
| 43 |
-
Metrics are from this repo's own training notebook (antialiased bicubic downscale, not the official MATLAB `imresize`), so treat them as comparable between methods here but only approximately comparable to published tables.
|
| 44 |
-
|
| 45 |
-
## Usage
|
| 46 |
-
|
| 47 |
-
```python
|
| 48 |
-
import numpy as np, torch
|
| 49 |
-
from PIL import Image
|
| 50 |
-
from huggingface_hub import hf_hub_download
|
| 51 |
-
import importlib.util
|
| 52 |
-
|
| 53 |
-
spec = importlib.util.spec_from_file_location("srnet", hf_hub_download("your-username/srnet-x4", "srnet.py"))
|
| 54 |
-
srnet = importlib.util.module_from_spec(spec); spec.loader.exec_module(srnet)
|
| 55 |
-
|
| 56 |
-
model = srnet.SRNet.from_pretrained("your-username/srnet-x4").eval()
|
| 57 |
-
img = np.asarray(Image.open("photo.png").convert("RGB"), np.float32) / 255
|
| 58 |
-
x = torch.from_numpy(img).permute(2, 0, 1)[None]
|
| 59 |
-
with torch.inference_mode():
|
| 60 |
-
y = model(x).clamp(0, 1)[0].permute(1, 2, 0).numpy()
|
| 61 |
-
Image.fromarray((y * 255).round().astype("uint8")).save("photo_x4.png")
|
| 62 |
-
```
|
| 63 |
-
|
| 64 |
-
Large images: process in tiles with a margin of at least `2*nb + 6 = 38` input pixels to get output identical to whole-image inference (see the demo Space's `app.py`).
|
| 65 |
-
|
| 66 |
-
**ONNX:** `srnet_x4.onnx` takes `input` (float32 NCHW RGB in [0, 1], dynamic batch/height/width) and returns `output` (clip to [0, 1]).
|
| 67 |
-
|
| 68 |
-
## Model details
|
| 69 |
-
|
| 70 |
-
- Architecture: 3x3 conv head -> 16 residual blocks (conv-ReLU-conv, 64 channels) -> 3x3 conv with long skip -> conv to 48 channels + PixelShuffle(4) -> added to a bicubic upscale of the input. The final conv is zero-initialised, so training starts at exact bicubic.
|
| 71 |
-
- Compute: all convolutions run at input resolution; about 2.5 MFLOPs per input pixel.
|
| 72 |
-
|
| 73 |
-
## Training
|
| 74 |
-
|
| 75 |
-
- Data: DF2K (DIV2K + Flickr2K) HR training images; DIV2K validation images held out.
|
| 76 |
-
- Degradation: antialiased bicubic x4 downscale, quantised to 8 bit. No noise, blur or compression.
|
| 77 |
-
- 16,157 steps, batch 32, 64x64 LR patches (256x256 HR), random flips/rotations.
|
| 78 |
-
- AdamW, peak LR 4e-4 with cosine decay, L1 loss, then MSE for the final 8% of the schedule; EMA (0.999) weights evaluated alongside raw weights and the better one kept; fp16 mixed precision.
|
| 79 |
-
|
| 80 |
-
## Limitations
|
| 81 |
-
|
| 82 |
-
- Trained only on clean bicubic-downscaled images. On real-world inputs with noise, blur or JPEG artefacts it will not denoise or deblock and may amplify artefacts.
|
| 83 |
-
- Optimised for PSNR with L1/MSE losses, so fine texture (fur, feathers, foliage) comes out smoother than the original. It does not hallucinate detail the way GAN-based upscalers do.
|
| 84 |
-
- x4 only.
|
| 85 |
-
|
| 86 |
-
## License / data
|
| 87 |
-
|
| 88 |
-
Set the license to suit you. The training data has its own terms (DIV2K is provided for research use; Flickr2K images carry their original Flickr licenses), which may restrict commercial use of the weights — check them before choosing a license and update the YAML header above.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|