We propose a new method for effective shadow removal by regarding it as an exposure fusion problem.

Overview

Auto-exposure fusion for single-image shadow removal

We propose a new method for effective shadow removal by regarding it as an exposure fusion problem. Please refer to the paper for details: https://openaccess.thecvf.com/content/CVPR2021/papers/Fu_Auto-Exposure_Fusion_for_Single-Image_Shadow_Removal_CVPR_2021_paper.pdf.

Framework

Dataset

  1. For data folder path (ISTD), train_A: shadow images, train_B: shadow masks, train_C: shadow free images, organize them as following:
--ISTD+
   --train
      --train_A
          --1-1.png
      --train_B
          --1-1.png 
      --train_C_fixed_official 
          --1-1.png
      --train_params_fixed  # generate later
          --1-1.png.txt
   --test
      --test_A
          --1-1.png
      --test_B
          --1-1.png
      --test_C
          --1-1.png
      --mask_threshold   # generate later
          --1-1.png
  1. Run the code ./data_processing/compute_params.ipynb for exposure parameters generation. The result will be put in ./ISTD/train/train_params_fixed. Here, names train_C_fixed_official and train_params_fixed are for ISTD+ dataset, which are consitent with self.dir_C and self.dir_param in ./data/expo_param_dataset.py .
  2. For testing masks, please run the code ./data_processing/test_mask_generation.py. The result will be put in ./ISTD/mask_threshold.

Pretrained models

We release our pretrained model (ISTD+, SRD) at models

pretrained model (ISTD) at models

Modify the parameter model in file OE_eval.sh to Refine and set ks=3, n=5, rks=3 to load the model.

Train

Modify the corresponding path in file OE_train.sh and run the following script

sh OE_train.sh
  1. For the parameters:
      DATA_PATH=./Datasets/ISTD or your datapath
      n=5, ks=3 for FusionNet,
      n=5, ks=3, rks=3 for RefineNet.
      model=Fusion for FusionNet training,
      model=Refine for RefineNet training.

The trained models are saved in ${REPO_PATH}/log/${Name}, Name are customized for parameters setting.

Test

In order to test the performance of a trained model, you need to make sure that the hyper parameters in file OE_eval.sh match the ones in OE_train.sh and run the following script:

sh OE_eval.sh
  1. The pretrained models are located in ${REPO_PATH}/log/${Name}.

Evaluation

The results reported in the paper are calculated by the matlab script used in other SOTA, please see evaluation for details. Our evaluation code will print the metrics calculated by python code and save the shadow removed result images which will be used by the matlab script.

Results

  • Comparsion with SOTA, see paper for details.

Framework

  • Penumbra comparsion between ours and SP+M Net

Framework

  • Testing result

The testing results on dataset ISTD+, ISTD, SRD are:results

More details are coming soon

Bibtex

@inproceedings{fu2021auto,
      title={Auto-exposure Fusion for Single-image Shadow Removal}, 
      author={Lan Fu and Changqing Zhou and Qing Guo and Felix Juefei-Xu and Hongkai Yu and Wei Feng and Yang Liu and Song Wang},
      year={2021},
      booktitle={accepted to CVPR}
}
Comments
  • Error when switching to test mode during training

    Error when switching to test mode during training

    Hi, @xuhangc I encounter the same problem as you. May I know how you fix this problem? As @yuhaoliu7456 suggested, I did write an if statement to skip input['param'] during the test.

    if 'param' in input:  #input['param] does not exist during the test
            self.shadow_param = input['param'].to(self.device).type(torch.float)
    

    However, I found that variable self.shadow_param will be used in forward method.

    addgt = self.shadow_param[:, [0, 2, 4]]
    mulgt = self.shadow_param[:, [1, 3, 5]]
    

    Therefore I still encounter error when switching to test mode during training. error

    Originally posted by @yx-chan131 in https://github.com/tsingqguo/exposure-fusion-shadow-removal/issues/27#issuecomment-953880303

    opened by yx-chan131 5
  • train

    train

    when i sh OE_train.sh this happend

    switching to testing mode Traceback (most recent call last): File "./OE_train.py", line 123, in model.set_input(data) File "/mnt/data/konglingwei/exposure-fusion-shadow-removal-main/models/Fusion_model.py", line 170, in set_input self.shadow_param = input['param'].to(self.device).type(torch.float) KeyError: 'param'

    opened by kkllww 4
  • Having a problem while loading pre-trained weights.

    Having a problem while loading pre-trained weights.

    I downloaded pre-trained weights from the link provided in this repo. while loading the weights there is something wrong in weight latest_net_R.pth.

    Traceback (most recent call last):
      File "/home/divus/Projects/Git/exposure-fusion-shadow-removal/OE_eval.py", line 33, in <module>
        model.setup(opt)
      File "/home/divus/Projects/Git/exposure-fusion-shadow-removal/models/base_model.py", line 84, in setup
        self.load_networks(opt.epoch)
      File "/home/divus/Projects/Git/exposure-fusion-shadow-removal/models/base_model.py", line 198, in load_networks
        net.load_state_dict(state_dict)
      File "/home/divus/Python/envs/torch/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1482, in load_state_dict
        raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
    RuntimeError: Error(s) in loading state_dict for UnetGenerator:
    	size mismatch for model.model.0.weight: copying a param with shape torch.Size([64, 19, 4, 4]) from checkpoint, the shape in current model is torch.Size([64, 13, 4, 4]).
    	size mismatch for model.model.3.weight: copying a param with shape torch.Size([128, 486, 4, 4]) from checkpoint, the shape in current model is torch.Size([128, 324, 4, 4]).
    	size mismatch for model.model.3.bias: copying a param with shape torch.Size([486]) from checkpoint, the shape in current model is torch.Size([324]).
    
    opened by yakhyo 3
  • Switch to test mode during training?

    Switch to test mode during training?

    During training process, I encountered the following error message. It seems that param is not in the input variable.

    switching to testing mode Traceback (most recent call last): File "/home/ipprlab/Downloads/exposure-fusion-shadow-removal/./OE_train.py", line 123, in <module> model.set_input(data) File "/home/ipprlab/Downloads/exposure-fusion-shadow-removal/models/Fusion_model.py", line 171, in set_input self.shadow_param = input['param'].to(self.device).type(torch.float) KeyError: 'param'

    opened by xuhangc 3
  • How can I inference the model against a single image?

    How can I inference the model against a single image?

    After seeing this issue https://github.com/tsingqguo/exposure-fusion-shadow-removal/issues/14, Now I am wondering is it possible to inference the model against a single image? Or do we need to give a paired image always? Shadow image and shadow mask for test. Thanks in advance.

    opened by yakhyo 1
  • Why divide here by 2 and add 0.5?

    Why divide here by 2 and add 0.5?

    Great work. And I have a question : Why divide here by 2 and add 0.5? https://github.com/tsingqguo/exposure-fusion-shadow-removal/blob/main/models/Refine_model.py#L206

    opened by sicong-li 1
  • Detail of the training process

    Detail of the training process

    "In the paper's Implementation Details section it is stated that the RefineNet is trained with exposure estimation and FusionNet together but freezing the latter two. I already trained the FusionNet. But I didn't see in the code that RefineNet training process used my pre-trained FusionNet, The RefineNet just defined new netG and netM models.

    I'm a bit confused about this training process. If the trained FusionNet is never used, then what's the point of training a FusionNet?"

    Besides, which part of the code freezes the NetG and netM?

    opened by Season-Chan 0
  • 请问matlab代码计算rmse,指标达不到论文给的数

    请问matlab代码计算rmse,指标达不到论文给的数

    作者您好: 我用您提供的去阴影结果,和matlab代码,计算rmse,发现无阴影区的数值,比论文中要大,比较迷惑,请问是什么原因?我是按照matlab代码中的要求,更改了无阴影,mask,和下载的去阴影结果数据路径,但是计算出来的数值较大,不知道是不是还要设置其他东西,我自己跑出来的结果去算rmse也是数值较大,很疑惑。

    opened by yuanyufang 6
  • 关于曝光插值的问题

    关于曝光插值的问题

    感谢您的开源分享!在阅读代码的时候,发现您这里的代码https://github.com/tsingqguo/exposure-fusion-shadow-removal/blob/main/models/Refine_model.py#L198 似乎有点问题,这里插值得到五张图片作为后续Fusion的一部分输入,根据代码的意思,这里会有两张同样的图片(base_shadow_output 和 i=0,scale=1时的图片)。不知这里是否有误?还有请问这个插值的方法涉及的超参数(i)是如何调节的?

    opened by Season-Chan 0
  • Issue about image size

    Issue about image size

    Thanks for your great work! I am wandering which part of the code should be modified if image size of my dataset is 200x200 and I want the final output image size of the network also 200x200?

    opened by Season-Chan 1
  • @fl82hope Hi, thanks for your prompt reply. To be more clear, did you mean that the variables addgt and mulgt are the same as input['param'] which will not be used during testing mode?

    @fl82hope Hi, thanks for your prompt reply. To be more clear, did you mean that the variables addgt and mulgt are the same as input['param'] which will not be used during testing mode?

    @fl82hope Hi, thanks for your prompt reply. To be more clear, did you mean that the variables addgt and mulgt are the same as input['param'] which will not be used during testing mode?

    Thanks!

    I also encountered the same problem as you, how do you modify Fusion_model.py to make it run normally?

    Originally posted by @yx-chan131 in https://github.com/tsingqguo/exposure-fusion-shadow-removal/issues/29#issuecomment-954331037

    opened by dante1024 1
Owner
Qing Guo
Presidential Postdoctoral Fellow with the Nanyang Technological University. Research interests are computer vision, image processing, deep learning.
Qing Guo
Learning from Synthetic Shadows for Shadow Detection and Removal [Inoue+, IEEE TCSVT 2020].

Learning from Synthetic Shadows for Shadow Detection and Removal (IEEE TCSVT 2020) Overview This repo is for the paper "Learning from Synthetic Shadow

Naoto Inoue 67 Dec 28, 2022
Propose a principled and practically effective framework for unsupervised accuracy estimation and error detection tasks with theoretical analysis and state-of-the-art performance.

Detecting Errors and Estimating Accuracy on Unlabeled Data with Self-training Ensembles This project is for the paper: Detecting Errors and Estimating

Jiefeng Chen 13 Nov 21, 2022
MPRNet-Cloud-removal: Progressive cloud removal

MPRNet-Cloud-removal Progressive cloud removal Requirements 1.Pytorch >= 1.0 2.Python 3 3.NVIDIA GPU + CUDA 9.0 4.Tensorboard Installation 1.Clone the

Semi 95 Dec 18, 2022
Fusion-DHL: WiFi, IMU, and Floorplan Fusion for Dense History of Locations in Indoor Environments

Fusion-DHL: WiFi, IMU, and Floorplan Fusion for Dense History of Locations in Indoor Environments Paper: arXiv (ICRA 2021) Video : https://youtu.be/CC

Sachini Herath 68 Jan 3, 2023
Video Instance Segmentation with a Propose-Reduce Paradigm (ICCV 2021)

Propose-Reduce VIS This repo contains the official implementation for the paper: Video Instance Segmentation with a Propose-Reduce Paradigm Huaijia Li

DV Lab 39 Nov 23, 2022
To propose and implement a multi-class classification approach to disaster assessment from the given data set of post-earthquake satellite imagery.

To propose and implement a multi-class classification approach to disaster assessment from the given data set of post-earthquake satellite imagery.

Kunal Wadhwa 2 Jan 5, 2022
Code for the CVPR 2021 paper "Triple-cooperative Video Shadow Detection"

Triple-cooperative Video Shadow Detection Code and dataset for the CVPR 2021 paper "Triple-cooperative Video Shadow Detection"[arXiv link] [official l

Zhihao Chen 24 Oct 4, 2022
The first dataset on shadow generation for the foreground object in real-world scenes.

Object-Shadow-Generation-Dataset-DESOBA Object Shadow Generation is to deal with the shadow inconsistency between the foreground object and the backgr

BCMI 105 Dec 30, 2022
Problem-943.-ACMP - Problem 943. ACMP

Problem-943.-ACMP В "main.py" расположен вариант моего решения задачи 943 с серв

Konstantin Dyomshin 2 Aug 19, 2022
null 5 Jan 5, 2023
Official code of ICCV2021 paper "Residual Attention: A Simple but Effective Method for Multi-Label Recognition"

CSRA This is the official code of ICCV 2021 paper: Residual Attention: A Simple But Effective Method for Multi-Label Recoginition Demo, Train and Vali

null 163 Dec 22, 2022
Outlier Exposure with Confidence Control for Out-of-Distribution Detection

OOD-detection-using-OECC This repository contains the essential code for the paper Outlier Exposure with Confidence Control for Out-of-Distribution De

Nazim Shaikh 64 Nov 2, 2022
Deep Anomaly Detection with Outlier Exposure (ICLR 2019)

Outlier Exposure This repository contains the essential code for the paper Deep Anomaly Detection with Outlier Exposure (ICLR 2019). Requires Python 3

Dan Hendrycks 464 Dec 27, 2022
Exposure Time Calculator (ETC) and radial velocity precision estimator for the Near InfraRed Planet Searcher (NIRPS) spectrograph

NIRPS-ETC Exposure Time Calculator (ETC) and radial velocity precision estimator for the Near InfraRed Planet Searcher (NIRPS) spectrograph February 2

Nolan Grieves 2 Sep 15, 2022
A list of papers regarding generalization in (deep) reinforcement learning

A list of papers regarding generalization in (deep) reinforcement learning

Kaixin WANG 13 Apr 26, 2021
Code for the paper "Relation of the Relations: A New Formalization of the Relation Extraction Problem"

This repo contains the code for the EMNLP 2020 paper "Relation of the Relations: A New Paradigm of the Relation Extraction Problem" (Jin et al., 2020)

YYY 27 Oct 26, 2022
Code for CVPR2021 paper "Robust Reflection Removal with Reflection-free Flash-only Cues"

Robust Reflection Removal with Reflection-free Flash-only Cues (RFC) Paper | To be released: Project Page | Video | Data Tensorflow implementation for

Chenyang LEI 162 Jan 5, 2023