HRNet-Facial-Landmark-Detection
HRNet-Facial-Landmark-Detection copied to clipboard
Some problems about generate_target
Hello, I'm so glad to read your paper and code. But I have some problems.
+1 in transform_pixel
-1 in
__getitem__
I'm a little confused.
I debug the code generate_targe
def generate_target(img, pt, sigma, label_type='Gaussian'):
"""
:param img: heatmap of a landmark 64 64
:param pt: a landmark (1,2)
:param sigma:
:param label_type:
:return:
"""
# Check that any part of the gaussian is in-bounds
tmp_size = sigma * 3 #辐射范围为4.5
ul = [int(pt[0] - tmp_size), int(pt[1] - tmp_size)]
br = [int(pt[0] + tmp_size + 1), int(pt[1] + tmp_size + 1)] #这里+1之后两边对称,
if (ul[0] >= img.shape[1] or ul[1] >= img.shape[0] or
br[0] < 0 or br[1] < 0): #如果超出了辐射范围
# If not, just return the image as is
return img #返回空白的heatmap
# Generate gaussian
size = 2 * tmp_size + 1 #10
x = np.arange(0, size, 1, np.float32)
y = x[:, np.newaxis]
x0 = y0 = size // 2 #5
# The gaussian is not normalized, we want the center value to equal 1
if label_type == 'Gaussian': #11x11高斯核
g = np.exp(- ((x - x0) ** 2 + (y - y0) ** 2) / (2 * sigma ** 2))
else:
g = sigma / (((x - x0) ** 2 + (y - y0) ** 2 + sigma ** 2) ** 1.5)
# Usable gaussian range
g_x = max(0, -ul[0]), min(br[0], img.shape[1]) - ul[0]
g_y = max(0, -ul[1]), min(br[1], img.shape[0]) - ul[1]
# Image range
img_x = max(0, ul[0]), min(br[0], img.shape[1])
img_y = max(0, ul[1]), min(br[1], img.shape[0])
img[img_y[0]:img_y[1], img_x[0]:img_x[1]] = g[g_y[0]:g_y[1], g_x[0]:g_x[1]]
return img
if __name__ == "__main__":
heatmap = np.zeros((64,64))
pt = (0,1)
sigma = 1.5
heatmap = generate_target(heatmap, pt, sigma)
the heatmap is like this..the max value index is (1, 1)
when I change pt = (10, 10)
and get correct heatmap
I'm not sure it's a bug or something.
Thanks for your reply.
I found the same problem,Not only that, but the key points drawn by TPTS are offset,why?
same question