YanchaoYang / FDA

Fourier Domain Adaptation for Semantic Segmentation
491 stars 79 forks source link

FDA numpy implementation not in line with the paper. #36

Open themurtazanazir opened 2 years ago

themurtazanazir commented 2 years ago

Bug

The border b in FDA numpy implementation https://github.com/YanchaoYang/FDA/blob/master/utils/__init__.py#L64 is taken as min(height, width)*beta which is not in line with the paper.

To quote the paper:

As we can see from Eq. (3), $\beta = 0$ will render $x^{s→t}$ the same as the original source image $x^s$. On the other hand, when $\beta = 1.0$, the amplitude of $x^s$ will be replaced by that of $x^t$.

But while setting the beta=1, we get almost the original source image back. Also, setting beta=1 should replace all amplitude not just along the smaller axis.

To Reproduce

Steps to reproduce the behavior:

betas = [0.001, 0.1, 0.5, 0.8, 0.9, 1.0]

f, axes = plt.subplots(3, 2, figsize=(30, 20))

for beta,ax  in zip(betas, axes.ravel()):

    image = FDA_source_to_target_np(src, tar , L=beta)
    image = np.clip(image, 0, 255).astype(np.uint8)
    image = image.transpose(1,2,0)
    ax.imshow(image)
    ax.set_title(f"L: {beta}")
    ax.set_axis_off()

f.tight_layout()

Output

FDA bug in orig

Expected behavior

The "augmentation" should be maximum at beta=1 not at beta=0.5.