This is an implementation of the following paper.
DC-ShadowNet: Single-Image Hard and Soft Shadow Removal Using Unsupervised Domain-Classifier Guided Network. International Conference on Computer Vision (ICCV'2021)
Yeying Jin, Aashish Sharma and Robby T. Tan
[Paper Link] [Supplement] [Slides] [Video]
Shadow removal from a single image is generally still an open problem. Most existing learning-based methods use supervised learning and require a large number of paired images (shadow and corresponding non-shadow images) for training. A recent unsupervised method, Mask-ShadowGAN, addresses this limitation. However, it requires a binary mask to represent shadow regions, making it inapplicable to soft shadows. To address the problem, in this paper, we propose an unsupervised domain-classifier guided shadow removal network, DC-ShadowNet. Specifically, we propose to integrate a shadow/shadow-free domain classifier into a generator and its discriminator, enabling them to focus on shadow regions. To train our network, we introduce novel losses based on physics-based shadow-free chromaticity, shadow-robust perceptual features, and boundary smoothness. Moreover, we show that our unsupervised network can be used for test-time training that further improves the results. Our experiments show that all these novel components allow our method to handle soft shadows, and also to perform better on hard shadows both quantitatively and qualitatively than the existing state-of-the-art shadow removal methods.
conda env create -f shadow_env.yml
-
SRD (please download train BaiduNetdisk and test from the authors). Extracted Shadow Masks in the SRD Dataset
DC-ShadowNet-AISTD, AISTD-Results
DC-ShadowNet-LRSS, LRSS-Results
DC-ShadowNet-ISTD, ISTD-Results
The default root mean squared error (RMSE) evaluation code used by all methods (including ours) actually computes mean absolute error (MAE).
- The faster version MAE evaluation code
- The original version MAE evaluation code
set the paths of the shadow removal result and the dataset in demo_srd_release.m and then run it.
demo_srd_release.m
Get the following Table 1 in the main paper on the SRD (size: 256x256).
Method | Training | All | Shadow | Non-Shadow |
---|---|---|---|---|
DC-ShadowNet | Unpaired | 4.66 | 7.70 | 3.39 |
Input Image | N/A | 13.77 | 37.40 | 3.96 |
For SRD (size: 640x840)
Method | Training | All | Shadow | Non-Shadow |
---|---|---|---|---|
DC-ShadowNet | Unpaired | 6.57 | 9.84 | 5.52 |
set the paths of the shadow removal result and the dataset in demo_aistd_release.m and then run it.
demo_aistd_release.m
Get the following Table 2 in the main paper on the AISTD (size: 256x256).
Method | Training | All | Shadow | Non-Shadow |
---|---|---|---|---|
DC-ShadowNet | Unpaired | 4.6 | 10.3 | 3.5 |
For AISTD (size: 480x640)
Method | Training | All | Shadow | Non-Shadow |
---|---|---|---|---|
DC-ShadowNet | Unpaired | 6.33 | 11.37 | 5.38 |
set the paths of the shadow removal result and the dataset in demo_lrss_release.m and then run it.
demo_lrss_release.m
Get the following Table 3 in the main paper on the LRSS dataset (size: 256x256).
Method | Training | All |
---|---|---|
DC-ShadowNet | Unpaired | 3.48 |
Input Image | N/A | 12.26 |
-
Download the pre-trained SRD model, put in results/SRD/model/
-
Download the pre-trained AISTD model, put in results/AISTD/model/
-
Download the pre-trained ISTD model, put in results/ISTD/model/
python main_test.py --dataset SRD --datasetpath [path_to_SRD dataset] --use_original_name False
rename to the original name, please change the suffix of test images accordingly (.jpg or .png)
python main_test.py --dataset SRD --datasetpath [path_to_SRD dataset] --use_original_name True --im_suf_A .jpg
Results in: results/SRD/[iteration]/outputB; results/SRD/[iteration]/inputA_outputB
- Implement the papers On the removal of shadows from images (TPAMI,05) and Recovery of Chromaticity Image Free from Shadows via Illumination Invariance (ICCV,03)
- Download Datasets and run 1. get the Shadow-Free Chromaticity Maps after Illumination Compensation, and put them in the trainC folder, you should see the following directory structure.
${DC-ShadowNet-Hard-and-Soft-Shadow-Removal}
|-- dataset
|-- SRD
|-- trainA ## Shadow
|-- trainB ## Shadow-free
|-- trainC ## Shadow-Free Chromaticity Maps after Illumination Compensation
|-- testA ## Shadow
|-- testB ## Shadow-free
...
python main_train.py --dataset SRD --datasetpath [path_to_SRD dataset] --iteration [iteration]
Get the following Figure 5 in the main paper, VGG feature visualization code is in feature_release folder,
python test_VGGfeatures.py
Results in: ./results_VGGfeatures/shadow_VGGfeatures/layernumber/imagenumber/visual_featurenumber_RMSE.jpg
If this work is useful for your research, please cite our paper.
@inproceedings{jin2021dc,
title={DC-ShadowNet: Single-Image Hard and Soft Shadow Removal Using Unsupervised Domain-Classifier Guided Network},
author={Jin, Yeying and Sharma, Aashish and Tan, Robby T},
booktitle={Proceedings of the IEEE/CVF International Conference on Computer Vision},
pages={5027--5036},
year={2021}
}