Idein / chainer-pose-proposal-net

Chainer implementation of Pose Proposal Networks
Other
117 stars 31 forks source link

max_delta_ij implementation #13

Closed noirmist closed 5 years ago

noirmist commented 5 years ago

Hi, I have question about your code. I looking the implementation of max_delta_ij and it looks weird. In the paper, max_data_ji is a maximum value of d1 and d2 which indicate responsibility for the person. Here I found the implementation in your code. the source code From Line 196 to LIne 210

    # define max(delta^i_k1, delta^j_k2) which is used for loss_limb
    max_delta_ij = np.ones((len(self.edges),
                            outH, outW,
                            self.local_grid_size[1], self.local_grid_size[0]), dtype=np.float32)
    or_delta = np.zeros((len(self.edges), outH, outW), dtype=np.float32)
    for ei, (s, t) in enumerate(self.edges):
        or_delta[ei] = np.minimum(delta[s] + delta[t], 1)
    mask = F.max_pooling_2d(np.expand_dims(or_delta, axis=0),
                            ksize=(self.local_grid_size[1], self.local_grid_size[0]),
                            stride=1,
                            pad=(self.local_grid_size[1] // 2, self.local_grid_size[0] // 2))
    mask = np.squeeze(mask.array, axis=0)
    for index, _ in np.ndenumerate(mask):
        max_delta_ij[index] *= mask[index]
    max_delta_ij = max_delta_ij.transpose(0, 3, 4, 1, 2)

In my opinion, the max_pooling_2d is not directly compare each component of delta^i_k1 and delta&j_k2 which consist of the edges. Does anyone tell me, the reason why this implementaion works fine or is this right implementation?

Thanks.

terasakisatoshi commented 5 years ago

Hi, sorry for delay in response. I concentrated another task and expect someone suggest better solution. (nobody? anyone else?)

max_delta_ij determines which term (delta^i_k1*delta^j_k2-p) includes as loss for limb.

Assume index of grid i=(p_i,q_i) is responsible for k1, all elements in max_delta_ij[ei][i] (which consists of 'local grid') should be 1. So, I (about 4 month ago) used max_pooling_2d as maximum filter.

terasakisatoshi commented 5 years ago

On the other hand, It seems, my implementation does not care the case i=(p_i,q_i) is NOT responsible for k1. I made jupyter notebook to study the case.

consider_max_delta_ij.ipynb.zip

This shows that, strictly speaking, my implementation is not correct because it includes many terms as loss for limb (but does not lack. So it works fine for now). This notebook (maybe) contains better suggestion.

noirmist commented 5 years ago

Thank you for your kindness notebook!!