sniklaus / pytorch-unflow

a reimplementation of UnFlow in PyTorch that matches the official TensorFlow version
GNU General Public License v3.0
144 stars 24 forks source link

What's the aim of "* 20.0" after two upscale operation in the class "Upconv"? #14

Closed EmiliaCarbon closed 1 year ago

EmiliaCarbon commented 1 year ago
class Upconv(torch.nn.Module):
    def forward(self, tenOne, tenTwo, objInput):
        objOutput = {}

        tenInput = objInput['conv6']
        objOutput['flow6'] = self.netSixOut(tenInput)
        tenInput = torch.cat([objInput['conv5'], self.netFivNext(tenInput), self.netSixUp(objOutput['flow6'])],
                             1)
        objOutput['flow5'] = self.netFivOut(tenInput)
        tenInput = torch.cat([objInput['conv4'], self.netFouNext(tenInput), self.netFivUp(objOutput['flow5'])],
                             1)
        objOutput['flow4'] = self.netFouOut(tenInput)
        tenInput = torch.cat([objInput['conv3'], self.netThrNext(tenInput), self.netFouUp(objOutput['flow4'])],
                             1)
        objOutput['flow3'] = self.netThrOut(tenInput)
        tenInput = torch.cat([objInput['conv2'], self.netTwoNext(tenInput), self.netThrUp(objOutput['flow3'])],
                             1)
        objOutput['flow2'] = self.netTwoOut(tenInput)

        return self.netUpscale(self.netUpscale(objOutput['flow2'])) * 20.0         # * 20.0 here

What is the aim of this multiplication? My guess is to enlarge the output of the network, because the network should output the absolute size of the offset. Is my guess right?

sniklaus commented 1 year ago

I ported the official TensorFlow model, which multiplies by 20 as follows.

https://github.com/simonmeister/UnFlow/blob/bf0c09972dca0bc139c5ed39f25cc25c86f79037/src/e2eflow/core/flownet.py#L48

For additional questions, you might want to direct your question at the authors of UnFlow.