tsingqguo / exposure-fusion-shadow-removal

We propose a new method for effective shadow removal by regarding it as an exposure fusion problem.
184 stars 29 forks source link

Switch to test mode during training? #27

Closed xuhangc closed 2 years ago

xuhangc commented 3 years ago

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'

yuhaoliu7456 commented 3 years ago

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'

During the test, the input['param'] does not exist, you need to write two-line codes to perform the judgement of current state

fl82hope commented 3 years ago

yes, here should add some statements like if to check the key exist or not. For the dataset reading, the param doesn't exist in testing.

yx-chan131 commented 2 years ago

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