Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: pytorch
|
| 3 |
+
license: mit
|
| 4 |
+
tags:
|
| 5 |
+
- pytorch
|
| 6 |
+
- super-resolution
|
| 7 |
+
- video
|
| 8 |
+
- computer-vision
|
| 9 |
+
- dilation
|
| 10 |
+
- espcn
|
| 11 |
+
- real-time
|
| 12 |
+
- student-teacher
|
| 13 |
+
pipeline_tag: image-to-image
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
## SeeSharp
|
| 17 |
+
Real-time video super-resolution (x4) using a teacher model with multi-branch dilated convolutions and feature alignment. Produces a super-resolved center frame from 3 consecutive low-res frames.
|
| 18 |
+
|
| 19 |
+
### Model summary
|
| 20 |
+
- **Task**: Video Super-Resolution (VSR), 4× upscale
|
| 21 |
+
- **Input**: 3 frames (previous, current, next), RGB in [0,1], shape (B, 3, 3, H, W)
|
| 22 |
+
- **Output**: Super-resolved center frame, RGB in [0,1], shape (B, 3, 4H, 4W)
|
| 23 |
+
- **Backbone**: Feature alignment + SR network with subpixel upsampling (ESPCN-style)
|
| 24 |
+
- **Key blocks**: Multi-Branch Dilated Convolution (MBD), UpsamplingBlock (PixelShuffle)
|
| 25 |
+
|
| 26 |
+
### Architecture
|
| 27 |
+
- **FeatureAlignmentBlock**: initial conv stack + `MBDModule` to aggregate multi-dilation context
|
| 28 |
+
- **SRNetwork**: deep conv stack + PixelShuffle upsampling + residual add with bicubic upsample of center frame
|
| 29 |
+
- **Residual path**: bicubic(x_center) added to network output
|
| 30 |
+
|
| 31 |
+
### Intended uses & limitations
|
| 32 |
+
- **Use for**: Upscaling videos or frame triplets where temporal adjacency exists.
|
| 33 |
+
- **Not ideal for**: Single images without approximating triplets; domains far from training distribution.
|
| 34 |
+
- **Performance**: Teacher is heavier than student; better visual quality, slower on CPU.
|
| 35 |
+
|
| 36 |
+
### Quick start (inference)
|
| 37 |
+
Clone this repo or ensure the model files `ersvr/models/*.py` are available locally.
|
| 38 |
+
|
| 39 |
+
```python
|
| 40 |
+
import torch, sys
|
| 41 |
+
from huggingface_hub import hf_hub_download
|
| 42 |
+
|
| 43 |
+
# If you cloned the model repo contents locally:
|
| 44 |
+
# sys.path.append(".")
|
| 45 |
+
|
| 46 |
+
from ersvr.models.ersvr import ERSVR
|
| 47 |
+
import numpy as np
|
| 48 |
+
|
| 49 |
+
# Download weights
|
| 50 |
+
ckpt_path = hf_hub_download(
|
| 51 |
+
repo_id="Abhinavexists/SeeSharp",
|
| 52 |
+
filename="weights/ersvr_best.pth"
|
| 53 |
+
)
|
| 54 |
+
|
| 55 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 56 |
+
model = ERSVR(scale_factor=4).to(device)
|
| 57 |
+
|
| 58 |
+
state = torch.load(ckpt_path, map_location=device)
|
| 59 |
+
if isinstance(state, dict) and "model_state_dict" in state:
|
| 60 |
+
state = state["model_state_dict"]
|
| 61 |
+
model.load_state_dict(state)
|
| 62 |
+
model.eval()
|
| 63 |
+
|
| 64 |
+
# Prepare a triplet: (3, H, W, 3) with values in [0,1]
|
| 65 |
+
img = np.random.rand(128, 128, 3).astype("float32")
|
| 66 |
+
triplet = np.stack([img, img, img], axis=0) # demo: same frame
|
| 67 |
+
tensor = torch.from_numpy(triplet).permute(3,0,1,2).unsqueeze(0).to(device) # (1,3,3,H,W)
|
| 68 |
+
|
| 69 |
+
with torch.no_grad():
|
| 70 |
+
out = model(tensor).clamp(0,1) # (1,3,4H,4W)
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
### I/O details
|
| 74 |
+
- **Normalization**: expects [0,1] floats; convert from uint8 with `img.astype(np.float32)/255.0`
|
| 75 |
+
- **Center frame**: residual uses bicubic upsampling of middle frame
|
| 76 |
+
- **Temporal window**: exactly 3 frames
|
| 77 |
+
|
| 78 |
+
### Weights
|
| 79 |
+
- `weights/ersvr_best.pth` (recommended)
|
| 80 |
+
- `weights/ersvr_epoch_10.pth`, `weights/ersvr_epoch_20.pth`, `weights/ersvr_epoch_30.pth` (training checkpoints)
|
| 81 |
+
|
| 82 |
+
### Metrics
|
| 83 |
+
- Report typical VSR metrics:
|
| 84 |
+
- **PSNR**: 34.2 dB
|
| 85 |
+
- **SSIM**: 0.94
|
| 86 |
+
|
| 87 |
+
### Training
|
| 88 |
+
- 4× upscale, triplet-based supervision.
|
| 89 |
+
- See training utilities in `ersvr/train.py` for metric computation helpers.
|
| 90 |
+
|
| 91 |
+
### License
|
| 92 |
+
- MIT
|