tsing90 / pytorch_semantic_human_matting

This is an unofficial implementation of the paper "Semantic human matting":
https://arxiv.org/pdf/1809.01354.pdf
83 stars 18 forks source link

question about `network.py` #24

Closed liminn closed 5 years ago

liminn commented 5 years ago

For the code in network.py :

class net_T(nn.Module):
    # Train T_net
    def __init__(self):

        super(net_T, self).__init__()

        self.t_net = PSPNet()

    def forward(self, input):

        # trimap
        trimap= self.t_net(input)
        return trimap

the value of trimap is not constrained between 0/1/2, should I apply torch.argmax() to it?

If apply torch.argmax() to trimap, the code for net_M will be explainable:

# why bg/fg/unsure value is not constrained  between 0/1?
bg, fg, unsure = torch.split(trimap, 1, dim=1)
# why trimap value is not constrained between 0/1/2?
m_net_input = torch.cat((input, trimap), 1)
alpha_r = self.m_net(m_net_input)
alpha_p = fg + unsure * alpha_r

Is my understanding correct?

liminn commented 5 years ago

Dataset control the input for net_T, 'net_M' and 'net_F'; My previous understanding is wrong, sorry!