lizhengwei1992 / Semantic_Human_Matting

Semantic Human Matting
532 stars 146 forks source link

about bg, fg, and unsure classes #8

Closed pourfard closed 5 years ago

pourfard commented 5 years ago

Hi, thanks for sharing the code. I've got confused with these lines. In dataset.py we have:

# trimap should be 3 classes : fg, bg. unsure
trimap[trimap==0] = 0 (bg)
trimap[trimap==128] = 1 (unsure)
trimap[trimap==255] = 2  (fg)

but when we split TNET output we have:

# paper: bs, fs, us
bg, fg, unsure = torch.split(trimap_softmax, 1, dim=1)

and in loss function it seems we are comparing wrong classes:

criterion = nn.CrossEntropyLoss()
L_t = criterion(trimap_pre, trimap_gt[:,0,:,:].long())

I think this line:

bg, fg, unsure = torch.split(trimap_softmax, 1, dim=1)

should be:

bg, unsure, fg = torch.split(trimap_softmax, 1, dim=1)

I asked this question because results are not as well as the paper reported, so I think something is wrong.

lizhengwei1992 commented 5 years ago

@pourfard it don't matter about the location of bg\fg\unsure, the of convolution well get parameter to match the channel splited from trimap_softmax automatically.

gdjmck commented 5 years ago

I think it does when pre-train t-net, if the alpha was designed as background = 0, unsure = 128, foreground = 255