kkkls / FFTformer

[CVPR 2023] Effcient Frequence Domain-based Transformer for High-Quality Image Deblurring
MIT License
255 stars 18 forks source link

About the calculation of loss #10

Open hejin9 opened 1 year ago

hejin9 commented 1 year ago

Hello, I would like to ask about the calculation of loss. The code:

for pred in preds: l_pix += self.cri_pix(pred, self.gt)

is used to calculate the pixel loss between each pair of images.

On the other hand, is it correct to say that l_fft = self.cri_fft(preds[-1], self.gt) is used to calculate the FFT loss between only the last pair of images within each batch size?

kkkls commented 1 year ago

Hello, "preds" is a list with a length of 1, so the code is taking the value at index -1 of the list using "preds[-1]".

hejin9 commented 1 year ago

Thank you for your reply, you have been a great help to me and I really appreciate it.

xjcclq commented 5 months ago

Have you used the L1 loss and FFT loss with both weights set to 1 in your model? Do I understand correctly? Thank you!

codes in image_restoration_model.py: if self.cri_pix: l_pix = 0. for pred in preds: l_pix += self.cri_pix(pred, self.gt)

        # print('l pix ... ', l_pix)
        l_total += l_pix
        loss_dict['l_pix'] = l_pix

    # fft loss
    if self.cri_fft:
        l_fft = self.cri_fft(preds[-1], self.gt)
        l_total += l_fft
        loss_dict['l_fft'] = l_fft
kkkls commented 5 months ago

The weight of FFT loss is 0.1,

Have you used the L1 loss and FFT loss with both weights set to 1 in your model? Do I understand correctly? Thank you!

codes in image_restoration_model.py: if self.cri_pix: l_pix = 0. for pred in preds: l_pix += self.cri_pix(pred, self.gt)

        # print('l pix ... ', l_pix)
        l_total += l_pix
        loss_dict['l_pix'] = l_pix

    # fft loss
    if self.cri_fft:
        l_fft = self.cri_fft(preds[-1], self.gt)
        l_total += l_fft
        loss_dict['l_fft'] = l_fft

The weight of the L1 loss is 1, and the weight of the FFT loss is 0.1. You can check more details about the losses in the file basicsr/models/losses/losses.py.