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] [Supplementary] [Poster] [Slides] [Zhihu]
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/
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
python main_test.py --dataset SRD --datasetpath [path_to_SRD dataset] --use_original_name False
Results in: results/SRD/[iteration]/outputB
; results/SRD/[iteration]/inputA_outputB
- Implement On the removal of shadows from images (TPAMI,05) and Recovery of Chromaticity Image Free from Shadows via Illumination Invariance (ICCV,03)
[Update] We have released our MATLAB and Python implementations on Sep 8, 2023. We recommend the MATLAB.
1.1 MATLAB: inputs are in 0_Shadow-Free_Chromaticity_matlab/input/
, outputs are in 0_Shadow-Free_Chromaticity_matlab/sfchroma/
.
0_Shadow-Free_Chromaticity_matlab/physics_all.m
1.2 Python: inputs are in 0_Shadow-Free_Chromaticity_python/input/
, outputs are in 0_Shadow-Free_Chromaticity_python/sfchroma/
.
0_Shadow-Free_Chromaticity_python/physics_all.py
- Download datasets and run
0_Shadow-Free_Chromaticity_matlab/physics_all.m
to get the Shadow-Free Chromaticity Maps after Illumination Compensation, and put them in thetrainC
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]
[Update] We have releasedDCShadowNet_train.py
on Dec 7, 2022.
Get the following Figure 5 in the main paper, VGG feature visualization code is in the feature_release
folder,
python test_VGGfeatures.py
Results in: ./results_VGGfeatures/shadow_VGGfeatures/layernumber/imagenumber/visual_featurenumber_RMSE.jpg
Code is implemented based U-GAT-IT, we would like to thank them.
One trick used in networks.py
is to change out = self.UpBlock2(x)
to out = (self.UpBlock2(x)+input).tanh() to learn a residual.
The code and models in this repository are licensed under the MIT License for academic and other non-commercial uses.
For commercial use of the code and models, separate commercial licensing is available. Please contact:
- Yeying Jin ([email protected])
- Robby T. Tan ([email protected])
- Jonathan Tan ([email protected])
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}
}