zhiqiangdon / CU-Net

Code for "Quantized Densely Connected U-Nets for Efficient Landmark Localization" (ECCV 2018) and "CU-Net: Coupled U-Nets" (BMVC 2018 oral)
Apache License 2.0
227 stars 40 forks source link

Issue regarding rotation and scaling of training images for Facial Landmarks #9

Open abhi1kumar opened 5 years ago

abhi1kumar commented 5 years ago

Thank you for making the code available. If we look into line 106 and 107 of the data/face_bbx.py, the code tries to get the random scale and rotation

s = s* (2 ** (sample_from_bounded_gaussian(self.scale_factor)))
r = sample_from_bounded_gaussian(self.rot_factor)

However, since the sample_from_bounded_gaussian function gives values between two standard deviations around the passed argument, the rotation seems to be essentially scaled between +/- 60 since self.rot_factor = 30.

Also, the scale s is raised two to the power a random number effectively giving new scale in the range [0.707, 1.414]s since self.rot_factor = 0.25 . I also plotted the s with the following short code snippet

import numpy as np
import matplotlib.pyplot as plt

def sample_from_bounded_gaussian(x):
    return max(-2*x, min(2*x, np.random.randn()*x))

num = 1000000
arr = np.zeros((num,))

sigma = 0.25
for i in range(num):
    arr[i] = (2 ** (sample_from_bounded_gaussian(sigma)))

plt.hist(arr, normed=True, bins=30)
plt.ylabel('Number')
plt.grid()
plt.savefig('scale_1.png')
plt.close()

The output is scale

These two ranges of +/- 60 and [0.707, 1.414]s are different from what has been mentioned in paragraph Facial Landmark Datasets, Page 8 of your ECCV paper The paper mentions rotation to be +/- 30 while the scale is [0.75, 1.25]

I definitely would be missing something while going through your code. It would be really great if you could elaborate a bit.