NVIDIA / flownet2-pytorch

Pytorch implementation of FlowNet 2.0: Evolution of Optical Flow Estimation with Deep Networks
Other
3.12k stars 739 forks source link

How to understand the "training for multiple flow" and the "div_flow" #28

Closed PkuRainBow closed 6 years ago

PkuRainBow commented 6 years ago

issue 1

As in the FlowNetC, FlowNetS, we will return a list of flow during training:

        if self.training:
            return flow2,flow3,flow4,flow5,flow6

So do we need to compute EPE loss for all the five flow predictions? If needed, could you help me point out where we do such operations for the five predicted flow maps and where have we scale the groud truth flow to match the different scales corresponding to the five predicted flow maps?

As I find that in the main.py, we only have a class like below:

        class ModelAndLoss(nn.Module):
            def __init__(self, args):
                super(ModelAndLoss, self).__init__()
                kwargs = tools.kwargs_from_args(args, 'model')
                self.model = args.model_class(args, **kwargs)
                kwargs = tools.kwargs_from_args(args, 'loss')
                self.loss = args.loss_class(args, **kwargs)

            def forward(self, data, target, inference=False ):
                output = self.model(data)

                loss_values = self.loss(output, target)

                if not inference :
                    return loss_values
                else :
                    return loss_values, output

        model_and_loss = ModelAndLoss(args)

issue 2

I find that there exist a factor "div_flow" set as 20, could you share me how to understand this value and why choose 20?

Thanks for your kind help!

PkuRainBow commented 6 years ago

I guess that the "div_flow" is in fact to controll the previously learned flow as the main component and keep the later flow as the residual. So the "div_flow" must be larger than 1, how to choose the value of "div_flow" is a hyperparamter choice. Do I get it right?

JiamingSuen commented 6 years ago

Just provide some information here, for issue1 MultiScale loss is accepting a tuple of flow predictions which should be the returned flows you mentioned. The ground truth scaling is proceeded here with AvgPool2d. For issue2 it's still not clear to me but I found this explanation in @ClementPinard 's original implementation. Maybe one of the authors would explain.

Hope this will help.

ClementPinard commented 6 years ago

div_flow is used for 2 reasons :

fitsumreda commented 6 years ago

I will close this, as sufficient explanation was given by @ClementPinard.