huochaitiantang / pytorch-deep-image-matting

Pytorch implementation of deep image matting
293 stars 71 forks source link

Doubts about the alpha_loss #6

Closed babyformula closed 4 years ago

babyformula commented 5 years ago

After read the code and implemented the training, I had some doubts about the alpha_loss calculation. According to the paper, the formulation'd relate to GT alpha and the Pred alpha, why was the trimap involved? And during the training, the alpha_loss was always staying at about 0.2, never got converged. Glad to talk with you.

babyformula commented 5 years ago

After another review, I started to understand the trimap code part. But there still some code maybe typos or something:

  1. the alpha prediction loss function: alpha_loss = torch.sqrt((pred_alpha - alpha)**2 + 1e-12), as alpha = alpha/255, but pred_alpha did not divided by 255.
  2. (alpha_loss * t_wi).sum() / (unknown_region_size + 1.), was it meant to be (unknown_region_size + epsilon)?

Thanks

huochaitiantang commented 5 years ago

1, the pred_alpha is the output of network and whose value is 0~1. 2, +1. can avoid dividing by 0.