Yu-Fan Lin1, Chia-ming Lee1, Chih-Chung Hsu2
1National Cheng Kung University 2National Yang Ming Chiao Tung University
Abstract
Shadows are a common factor degrading image quality. Single-image shadow removal (SR), particularly under challenging indirect illumination, is hampered by non-uniform content degradation and inherent ambiguity. Consequently, traditional methods often fail to simultaneously recover intra-shadow details and maintain sharp boundaries, resulting in inconsistent restoration and blurring that negatively affect both downstream applications and the overall viewing experience. To overcome these limitations, we propose the DenseSR, approaching the problem from a dense prediction perspective to emphasize restoration quality. This framework uniquely synergizes two key strategies: (1) deep scene understanding guided by geometric-semantic priors to resolve ambiguity and implicitly localize shadows, and (2) high-fidelity restoration via a novel Dense Fusion Block (DFB) in the decoder. The DFB employs adaptive component processing-using an Adaptive Content Smoothing Module (ACSM) for consistent appearance and a Texture-Boundary Recuperation Module (TBRM) for fine textures and sharp boundaries-thereby directly tackling the inconsistent restoration and blurring issues. These purposefully processed components are effectively fused, yielding an optimized feature representation preserving both consistency and fidelity. Extensive experimental results demonstrate the merits of our approach over existing methods.- Model Flexibility: Choose between DINOv3 (default) or DINOv2 for feature extraction.
- Enhanced Depth Estimation: Supports DepthPro (via
rgb2depth.ipynb) for superior depth maps compared to Depth Anything v2.
conda create -n densesr python=3.10 -y
conda activate densesr
pip install torch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 --index-url https://download.pytorch.org/whl/cu118
pip install -r requirements.txt
You can download WSRD dataset from here.
train_dir
├── origin <- Put the shadow affected images in this folder
│ ├── 0000.png
│ ├── 0001.png
│ ├── ...
├── depth
├── normal
├── shadow_free
│ ├── 0000.png
│ ├── 0001.png
│ ├── ...
test_dir
├── origin <- Put the shadow affected images in this folder
│ ├── 0000.png
│ ├── 0001.png
│ ├── ...
├── depth
├── normal
output_dir
├── 0000.png
├── 0001.png
├──...- Clone Depth anything v2 or you can just use the rgb2depth.ipynb file with DepthPro model
git clone https://github.com/DepthAnything/Depth-Anything-V2.git-
Download the pretrain model of depth anything v2
-
Run
get_depth_normap.pyto create depth and normal map.
python get_depth_normap.pyNow folder structure will be
train_dir
├── origin
│ ├── 0000.png
│ ├── 0001.png
│ ├── ...
├── depth
│ ├── 0000.npy
│ ├── 0001.npy
│ ├── ...
├── normal
│ ├── 0000.npy
│ ├── 0001.npy
│ ├── ...
├── shadow_free
│ ├── 0000.png
│ ├── 0001.png
│ ├── ...
test_dir
├── origin
│ ├── 0000.png
│ ├── 0001.png
│ ├── ...
├── depth
│ ├── 0000.npy
│ ├── 0001.npy
│ ├── ...
├── normal
│ ├── 0000.npy
│ ├── 0001.npy
│ ├── ...
output_dir
├── 0000.png
├── 0001.png
├──...git clone https://github.com/facebookresearch/dinov2.git- Download Pretrained weight
- Run
densesr_train.shto start training.
# Default training (uses DINOv3)
bash densesr_train.shTo switch to DINOv2, you can modify densesr_train.sh or run the command manually:
CUDA_VISIBLE_DEVICES="0" torchrun --nproc_per_node 1 --master_port 29500 densesr_train_DDP.py \
--win_size 8 \
--train_ps 256 \
--dino_version dinov2 \
--dino_model vitl14- Run
run_test.shto get inference results.
bash run_test.sh✔ 2026/01/30 Release training code
✔ 2026/01/11 Release ISTD pretrained model
✔ 2025/08/11 Release WSRD pretrained model
✔ 2025/08/11 Release inference code
✔ 2025/07/05 Paper Accepted by ACMMM'25
If you find this project useful, please consider citing us and giving us a star.
@misc{lin2025densesrimageshadowremoval,
title={DenseSR: Image Shadow Removal as Dense Prediction},
author={Yu-Fan Lin and Chia-Ming Lee and Chih-Chung Hsu},
year={2025},
eprint={2507.16472},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2507.16472},
}This code repository is release under MIT License.


