thqiu0419 / MLWNet

Other
34 stars 2 forks source link

'Fusion' object has no attribute 'd1' #5

Open zoujing925 opened 2 months ago

zoujing925 commented 2 months ago

Hi, thanks for your nice work.

I encounter problem when calculation wavelet loss:

def get_wavelet_loss(self): waveletloss = 0. for index, in enumerate(self.num_blocks): for block in getattr(self, f'd{index+1}'): wavelet_loss += block.get_wavelet_loss() return wavelet_loss

AttributeError: 'Fusion' object has no attribute 'd1'

Could you please help me?

chironbang commented 2 months ago

Hi @zoujing925, I have come across the same issue. It occurs because the Fusion block does not have a 'd1' attribute but only has d2 and d3. Basically, in the for loop, you should skip index 0 since d{index+1} will result in 'd1' in this case. Since self.num_blocks is a list of 4 elements (see line 319 of MLWNet_arch.py located in MLWNet/basicsr/models/arch), you will also need to skip index 3.

In fact, based on how the Fusion block is initialized in lines 318-320 of MLWNet_arch.py located in the "MLWNet/basicsr/models/arch/" folder, self.num_blocks = [None, 2, 2, None] which means you can ignore index 0 and 3 in the for loop by replacing the original code by this one:

        for index, num_block in enumerate(self.num_blocks):
            if num_block:
                for block in getattr(self, f'd{index+1}'):
                    wavelet_loss += block.get_wavelet_loss()

I hope this helps.