ddlee-cn / MuLUT

[ECCV 2022 & T-PAMI 2024] Multiple Look-Up Tables for Efficient Image Restoration
https://mulut.pages.dev
MIT License
90 stars 9 forks source link

About method "mulut_predict" #3

Closed wzl281158150 closed 1 year ago

wzl281158150 commented 1 year ago

Hello, thanks for your work. The project is nicely organized and the code is easily readable. However, i'm confused about the code in method "mulut_predict" in "1_train_model.py"

if s + 1 == stages:
    avg_factor, bias, norm = len(modes), 0, 1
    x = round_func((pred / avg_factor) + bias)
    if phase == "train":
        x = x / 255.0
else:
    avg_factor, bias, norm = len(modes) * 4, 127, 255.0
    x = round_func(torch.clamp((pred / avg_factor) + bias, 0, 255)) / norm

I know that "pred" is the sum of all modes ("sdy" for example) with 4 direction (0, 90, 180, 270). But, why does "avg_factor" equal 3 (len(modes) == 3) instead of 12 (3 modes * 4 direction == 12) in the final stage?

ddlee-cn commented 1 year ago

Thanks for your interest.

This is an empirical find, that averaging over four rotational predictions results in performance drop. Thus, we follow SR-LUT (line here).

Nevertheless, I have a theory that averaging over four rotational predictions reduce the dynamic range of each prediction (from 127 to 127/4). Hope it helps.

wzl281158150 commented 1 year ago

Thanks for your explanation! It helps a lot.