princeton-vl / pytorch_stacked_hourglass

Pytorch implementation of the ECCV 2016 paper "Stacked Hourglass Networks for Human Pose Estimation"
BSD 3-Clause "New" or "Revised" License
469 stars 94 forks source link

Principle of heatmap processing #17

Closed holyYodu closed 4 years ago

holyYodu commented 4 years ago

Thanks for your excellent work! When I read the code of generating heatmap in /data/dp.py, I am a little confused with the setting of sigma and size, and I looked up some papers and couldn't find the original heatmap generating procedure, would you please tell me where I can find the principle of generating heatmap?

class GenerateHeatmap():
    def __init__(self, output_res, num_parts):
        self.output_res = output_res
        self.num_parts = num_parts
        sigma = self.output_res/64
        self.sigma = sigma
        size = 6*sigma + 3
        x = np.arange(0, size, 1, float)
        y = x[:, np.newaxis]
        x0, y0 = 3*sigma + 1, 3*sigma + 1
        self.g = np.exp(- ((x - x0) ** 2 + (y - y0) ** 2) / (2 * sigma ** 2))
crockwell commented 4 years ago

Thanks! Sigma is set to be a consistent size with respect to resolution; but in terms of the value itself I'd refer to Joint training of a convolutional network and a graphical model for human pose estimation, which used similar loss.

Basically we're just using a gaussian around the ground truth annotations for our loss. (For what it's worth, I'm guessing it's somewhat robust to different sigmas)