fpramunno / InDI-implementation

Unofficial Pytorch implementation of the Inversion by Direct Iteration: An Alternative to Denoising Diffusion for Image Restoration (InDI)) by Delbracio et al 2023
MIT License
10 stars 2 forks source link

reversed variables in official Indi formula #2

Open ksasso1028 opened 7 months ago

ksasso1028 commented 7 months ago

https://github.com/fpramunno/InDI-implementation/blob/10aff26ab267c17ecd9ade7cca5fad2f15fcb1f2/training.py#L221

From the paper

" 4 InDI: Our Proposed Formulation Given (x, y) ∼ p(x, y), we define a continuous forward degradation process by xt = (1 − t)x + ty, with t ∈ [0, 1]. (1)

The idea of this forward process is that it starts from a clean sharp image at time t = 0, and then degrades it to the blurry/noisy observation at time t = 1. Here, xt indexed by t, represents an intermediate degraded image between the low-quality input y (i.e., t = 1) and the high-quality sharp target x (i.e., t = 0). Following the common notation in diffusion models, we will refer to the index t as the time-step."

Your code uses x as the dirty, and y as the target. This means when sampling starting from 1, you assume the input is already clean. transformed_image = (1-fct)*dirty + fct*clean At 0 you will cancel out the clean image and only return the dirty image, at 1 it cancels the dirty and returns the clean. This is the opposite of what is outlined in INDI, where t = 1 corresponds to the dirty image and we step down until t = 0 to get the clean image.

I find it interesting you were able to achieve competitive results with these terms reversed. Intuitively, this would mean that when you are sampling from t = 1 to t = 0 using this implementation, the net assumes the input is actually more degraded then the previous step, as opposed to closer to the clean sample. This could have the effect of forcing the network to increase the level of restoration over time, as opposed to incrementally doing less over time. Great work.

fpramunno commented 7 months ago

Hi, thanks! I corrected the typo, actually the results that I got were using the correct formula, I made the typo while uploading the code to github!

ksasso1028 commented 7 months ago

awesome, also wanted to point out it might be helpful to include the noise and the extra terms while training. essentially adding this to the input (training step epsilon for t noise) image_2024-02-07_114910315

Although in my experience with INDI seems to work without it, could be problem dependent.