|
Download README.md from Donghyun99/SFRNet: direct link, hf CLI and curl.
- Browser
- Download file 6.83 kB
-
https://huggingface.co/Donghyun99/SFRNet/resolve/main/README.md
- Command line
-
hf download hf://Donghyun99/SFRNet/README.md
-
curl -L -o README.md https://huggingface.co/Donghyun99/SFRNet/resolve/main/README.md
6.83 kB
| license: mit | |
| library_name: pytorch | |
| pipeline_tag: image-to-image | |
| tags: | |
| - shadow-removal | |
| - image-restoration | |
| - knowledge-distillation | |
| - lama | |
| - pytorch | |
| metrics: | |
| - rmse | |
| - psnr | |
| - ssim | |
| # SFR-Net: Shadow Feature Refinement Network | |
| **Shadow Feature Refinement Network: Progressive Feature Refinement based on Knowledge Distillation for Effective Shadow Removal**<br> | |
| Donghyun Han, Byoung-dai Lee (Kyonggi University)<br> | |
| *Multimedia Systems* 31, 449 (2025) | |
| [](https://arxiv.org/abs/2610.05325) | |
| [](https://doi.org/10.1007/s00530-025-02036-5) | |
| [](https://github.com/DongHyun99/SFRNet) | |
| | | | | |
| |---|---| | |
| | Paper (arXiv) | https://arxiv.org/abs/2610.05325 | | |
| | Journal version | https://doi.org/10.1007/s00530-025-02036-5 | | |
| | Code | https://github.com/DongHyun99/SFRNet | | |
| ## Abstract | |
| Shadow removal remains a persistent challenge owing to the variable sizes and colors of shadows influenced by | |
| lighting conditions. This study proposes a novel shadow feature refinement network (SFR-Net), which leverages | |
| supervised learning, feature refinement loss, and knowledge distillation to enhance shadow removal performance. | |
| A dedicated post-processing algorithm is further introduced to restore natural color consistency in the generated | |
| shadow-free images. We evaluated our method on two public datasets: the adjusted image shadow triplet dataset | |
| (ISTD+) and the shadow removal dataset (SRD), which demonstrate strong generalization capabilities under diverse | |
| conditions. On ISTD+, our model achieved a root mean square error (RMSE) of 3.4627 and structural similarity index | |
| measure (SSIM) of 0.9382 across the entire image. On SRD, it recorded an RMSE of 4.3781 and an SSIM of 0.9341. | |
| ## Method | |
| SFR-Net treats shadow removal as mask-guided image restoration on top of the | |
| [LaMa](https://github.com/advimman/lama) inpainting generator (fast Fourier convolutions, 18 residual blocks). | |
| - **Guided network G_S** (this checkpoint) takes the shadow image together with its shadow mask and produces the | |
| shadow-free image. | |
| - **Guiding network G_I** (frozen, used only during training) reconstructs the shadow-free image from an empty mask. | |
| - **Feature refinement loss L_fr** distills G_I's features into G_S. The best setting (Config #3) applies it to the | |
| deep stage, i.e. the last six FFC residual blocks. | |
| - **Color restoration post-processing**: for each RGB channel, a linear regression `I_S = b0 + b1 * I_sf` is fitted | |
| on the non-shadow pixels and applied to the whole output, aligning its colors with the input image. | |
| Training objective: `10·Adv + 30·HRFPL + 100·FM + 10·L_mix + 100·L_fr + 0.001·R1`. | |
| ## Files | |
| | File | Size | Description | | |
| |---|---|---| | |
| | `sfrnet_istd_plus.pth` | 205 MB | Guided network G_S trained on ISTD+ (51.0M parameters, fp32). A dict with a `generator` state dict. | | |
| ## Results | |
| ISTD+ test set (540 images, 640×480), from Table 1 of the paper. RMSE is computed in LAB color space, PSNR and SSIM | |
| in RGB; the numbers were produced with the MATLAB evaluation code. | |
| | Region | RMSE ↓ | SSIM ↑ | PSNR ↑ | | |
| |---|---|---|---| | |
| | Shadow | 4.9750 | 0.9865 | 37.8747 | | |
| | Non-shadow | 3.0631 | 0.9550 | 34.5793 | | |
| | All | 3.4627 | 0.9382 | 32.3872 | | |
| The SRD results in the paper (All RMSE 4.3781, SSIM 0.9341) come from a separate model that is not released here. | |
| The Python evaluation script in the GitHub repository re-implements the MATLAB protocol; its numbers are close to, | |
| but not identical with, the paper's tables. | |
| ## Usage | |
| The model code lives in the GitHub repository. | |
| ```bash | |
| git clone https://github.com/DongHyun99/SFRNet && cd SFRNet | |
| pip install -r requirements.txt | |
| wget https://huggingface.co/Donghyun99/SFRNet/resolve/main/sfrnet_istd_plus.pth -P checkpoints | |
| ``` | |
| Process a folder of images. Masks are binary shadow masks with the same file names as the images: | |
| ```bash | |
| python predict.py --checkpoint checkpoints/sfrnet_istd_plus.pth \ | |
| --input_dir datasets/ISTD+/test/test_A --mask_dir datasets/ISTD+/test/test_B \ | |
| --output_dir results/istd_plus | |
| ``` | |
| Process a single image from Python, run from the repository root (`pip install huggingface_hub`): | |
| ```python | |
| import torch | |
| import torch.nn.functional as F | |
| from huggingface_hub import hf_hub_download | |
| from inference import SFRNetPredictor, linear_color_restoration, to_uint8 | |
| from utils import load_rgb_uint8, load_mask_uint8, save_rgb | |
| ckpt = hf_hub_download('Donghyun99/SFRNet', 'sfrnet_istd_plus.pth') | |
| predictor = SFRNetPredictor(ckpt, device='cuda') | |
| image = load_rgb_uint8('shadow.png') # (H, W, 3) uint8 | |
| mask = load_mask_uint8('mask.png') # (H, W) uint8, shadow pixels > 0 | |
| h, w = mask.shape | |
| x = torch.from_numpy(image).permute(2, 0, 1)[None].float() / 255 | |
| m = torch.from_numpy(mask)[None, None].float() | |
| pad = (0, -w % 8, 0, -h % 8) # the generator needs sides divisible by 8 | |
| out = predictor(F.pad(x, pad, mode='reflect'), F.pad(m, pad)) | |
| predicted = to_uint8(out['predicted'][0, :, :h, :w]) | |
| result = linear_color_restoration(image, predicted, mask) # final SFR-Net output | |
| save_rgb('result.png', result) | |
| ``` | |
| `predict.py --postprocess none` writes the output without color restoration, i.e. the generator output inside | |
| the mask and the input image outside it. | |
| ## Training | |
| Training code, configs and loss implementations are in the GitHub repository. Training initializes both G_S and G_I | |
| from the LaMa big-lama checkpoint and uses an ADE20k ResNet-50 encoder for the perceptual (HRFPL) loss; see the | |
| repository README for download instructions. | |
| ## Limitations | |
| - The model needs a shadow mask as input. For images without ground-truth masks, a shadow detector must provide one. | |
| - The released model was trained only on ISTD+, whose images are outdoor ground scenes captured by one camera | |
| setup; quality may drop on other domains. | |
| ## Citation | |
| ```bibtex | |
| @article{han2025sfrnet, | |
| title = {Shadow Feature Refinement Network: Progressive Feature Refinement based on Knowledge Distillation for Effective Shadow Removal}, | |
| author = {Donghyun Han and Byoung-dai Lee}, | |
| journal = {Multimedia Systems}, | |
| volume = {31}, | |
| pages = {449}, | |
| year = {2025}, | |
| doi = {10.1007/s00530-025-02036-5}, | |
| eprint = {2610.05325}, | |
| archivePrefix = {arXiv} | |
| } | |
| ``` | |
| ## License and acknowledgements | |
| The weights are released under the MIT license. The generator architecture and parts of the training code are | |
| adapted from [LaMa](https://github.com/advimman/lama) (Apache-2.0), and the model is initialized from LaMa's big-lama | |
| weights. The HRFPL encoder comes from | |
| [CSAIL semantic-segmentation-pytorch](https://github.com/CSAILVision/semantic-segmentation-pytorch). | |