def forward(self, img1, img2, objectPrevious): Flow = None Features = None if objectPrevious is None: Cost_Volume = F.leaky_relu( input=correlation.FunctionCorrelation( tensorFirst=img1, tensorSecond=img2), negative_slope=.1) Features = Cost_Volume else: Flow = self.Upflow(objectPrevious['flow']) Features = self.Upfeature(objectPrevious['feature']) Cost_Volume = F.leaky_relu( input=correlation.FunctionCorrelation( tensorFirst=img1, tensorSecond=Warp(img2, Flow * self.scales)), negative_slope=.1) Features = torch.cat([Cost_Volume, img1, Flow, Features], dim=1) # end Features = torch.cat([self.conv1(Features), Features], dim=1) Features = torch.cat([self.conv2(Features), Features], dim=1) Features = torch.cat([self.conv3(Features), Features], dim=1) Features = torch.cat([self.conv4(Features), Features], dim=1) Features = torch.cat([self.conv5(Features), Features], dim=1) Flow = self.conv6(Features) return {'flow': Flow, 'feature': Features}
def forward(self, tensorFirst, tensorSecond, objectPrevious): tensorFlow = None tensorFeat = None if objectPrevious is None: tensorFlow = None tensorFeat = None tensorVolume = torch.nn.functional.leaky_relu(input=correlation.FunctionCorrelation(tensorFirst=tensorFirst, tensorSecond=tensorSecond), negative_slope=0.1, inplace=False) tensorFeat = torch.cat([ tensorVolume ], 1) elif objectPrevious is not None: tensorFlow = self.moduleUpflow(objectPrevious['tensorFlow']) tensorFeat = self.moduleUpfeat(objectPrevious['tensorFeat']) tensorVolume = torch.nn.functional.leaky_relu(input=correlation.FunctionCorrelation(tensorFirst=tensorFirst, tensorSecond=Backward(tensorInput=tensorSecond, tensorFlow=tensorFlow * self.dblBackward)), negative_slope=0.1, inplace=False) tensorFeat = torch.cat([ tensorVolume, tensorFirst, tensorFlow, tensorFeat], 1) # end tensorFeat = torch.cat([ self.moduleOne(tensorFeat), tensorFeat], 1) tensorFeat = torch.cat([ self.moduleTwo(tensorFeat), tensorFeat], 1) tensorFeat = torch.cat([ self.moduleThr(tensorFeat), tensorFeat], 1) tensorFeat = torch.cat([ self.moduleFou(tensorFeat), tensorFeat], 1) tensorFeat = torch.cat([ self.moduleFiv(tensorFeat), tensorFeat], 1) tensorFlow = self.moduleSix(tensorFeat) return { 'tensorFlow': tensorFlow, 'tensorFeat': tensorFeat }
def forward(self, tensorFirst, tensorSecond, tensorFeaturesFirst, tensorFeaturesSecond, tensorFlow): tensorFeaturesFirst = self.moduleFeat(tensorFeaturesFirst) tensorFeaturesSecond = self.moduleFeat(tensorFeaturesSecond) if tensorFlow is not None: tensorFlow = self.moduleUpflow(tensorFlow) if tensorFlow is not None: tensorFeaturesSecond = warp( tensorInput=tensorFeaturesSecond, tensorFlow=tensorFlow * self.dblBackward) if self.moduleUpcorr is None: tensorCorrelation = torch.nn.functional.leaky_relu( input=correlation.FunctionCorrelation( tensorFirst=tensorFeaturesFirst, tensorSecond=tensorFeaturesSecond, intStride=1), negative_slope=0.1, inplace=False) elif self.moduleUpcorr is not None: tensorCorrelation = self.moduleUpcorr( torch.nn.functional.leaky_relu( input=correlation.FunctionCorrelation( tensorFirst=tensorFeaturesFirst, tensorSecond=tensorFeaturesSecond, intStride=2), negative_slope=0.1, inplace=False)) return (tensorFlow if tensorFlow is not None else 0.0) + self.moduleMain(tensorCorrelation)
def forward(self, tensorFirst, tensorSecond, objectPrevious): try: from correlation import correlation # the custom cost volume layer except: sys.path.insert(0, './correlation') import correlation # you should consider upgrading python tensorFlow = None tensorFeat = None if objectPrevious is None: tensorFlow = None tensorFeat = None tensorVolume = torch.nn.functional.leaky_relu( input=correlation.FunctionCorrelation( tensorFirst=tensorFirst, tensorSecond=tensorSecond), negative_slope=0.1, inplace=False) tensorFeat = torch.cat([tensorVolume], 1) elif objectPrevious is not None: tensorFlow = self.moduleUpflow( objectPrevious['tensorFlow']) tensorFeat = self.moduleUpfeat( objectPrevious['tensorFeat']) tensorVolume = torch.nn.functional.leaky_relu( input=correlation.FunctionCorrelation( tensorFirst=tensorFirst, tensorSecond=Backward(tensorInput=tensorSecond, tensorFlow=tensorFlow * self.dblBackward)), negative_slope=0.1, inplace=False) tensorFeat = torch.cat( [tensorVolume, tensorFirst, tensorFlow, tensorFeat], 1) # end tensorFeat = torch.cat( [self.moduleOne(tensorFeat), tensorFeat], 1) tensorFeat = torch.cat( [self.moduleTwo(tensorFeat), tensorFeat], 1) tensorFeat = torch.cat( [self.moduleThr(tensorFeat), tensorFeat], 1) tensorFeat = torch.cat( [self.moduleFou(tensorFeat), tensorFeat], 1) tensorFeat = torch.cat( [self.moduleFiv(tensorFeat), tensorFeat], 1) tensorFlow = self.moduleSix(tensorFeat) return {'tensorFlow': tensorFlow, 'tensorFeat': tensorFeat}
def forward(self, tenFirst, tenSecond, tenFeaturesFirst, tenFeaturesSecond, tenFlow): tenFeaturesFirst = self.netFeat(tenFeaturesFirst) tenFeaturesSecond = self.netFeat(tenFeaturesSecond) if tenFlow is not None: tenFlow = self.netUpflow(tenFlow) # end if tenFlow is not None: tenFeaturesSecond = backwarp(tenInput=tenFeaturesSecond, tenFlow=tenFlow * self.fltBackwarp) # end if self.netUpcorr is None: tenCorrelation = torch.nn.functional.leaky_relu(input=correlation.FunctionCorrelation(tenFirst=tenFeaturesFirst, tenSecond=tenFeaturesSecond, intStride=1), negative_slope=0.1, inplace=False) elif self.netUpcorr is not None: tenCorrelation = self.netUpcorr(torch.nn.functional.leaky_relu(input=correlation.FunctionCorrelation(tenFirst=tenFeaturesFirst, tenSecond=tenFeaturesSecond, intStride=2), negative_slope=0.1, inplace=False)) # end return (tenFlow if tenFlow is not None else 0.0) + self.netMain(tenCorrelation)