def old_forward(self, image1, image2, iters=12, flow_init=None, upsample=True, test_mode=False):
    ' Estimate optical flow between pair of frames '
    image1 = ((2 * (image1 / 255.0)) - 1.0)
    image2 = ((2 * (image2 / 255.0)) - 1.0)
    image1 = image1.contiguous()
    image2 = image2.contiguous()
    hdim = self.hidden_dim
    cdim = self.context_dim
    with autocast(enabled=self.args.mixed_precision):
        (fmap1, fmap2) = self.fnet([image1, image2])
    fmap1 = fmap1.float()
    fmap2 = fmap2.float()
    if self.args.alternate_corr:
        corr_fn = AlternateCorrBlock(fmap1, fmap2, radius=self.args.corr_radius)
    else:
        corr_fn = CorrBlock(fmap1, fmap2, radius=self.args.corr_radius)
    with autocast(enabled=self.args.mixed_precision):
        cnet = self.cnet(image1)
        (net, inp) = torch.split(cnet, [hdim, cdim], dim=1)
        net = torch.tanh(net)
        inp = torch.relu(inp)
    (coords0, coords1) = self.initialize_flow(image1)
    if (flow_init is not None):
        coords1 = (coords1 + flow_init)
    flow_predictions = []
    for itr in range(iters):
        coords1 = coords1.detach()
        corr = corr_fn(coords1)
        flow = (coords1 - coords0)
        with autocast(enabled=self.args.mixed_precision):
            (net, up_mask, delta_flow) = self.update_block(net, inp, corr, flow)
        coords1 = (coords1 + delta_flow)
        if (up_mask is None):
            flow_up = upflow8((coords1 - coords0))
        else:
            flow_up = self.upsample_flow((coords1 - coords0), up_mask)
        flow_predictions.append(flow_up)
    if test_mode:
        corr = corr_fn(coords1)
        feat = inp
        return ((coords1 - coords0), flow_up, (feat, fmap1, fmap2))
    return flow_predictions
Estimate optical flow between pair of frames
def old_forward(self, image1, image2, iters=12, flow_init=None, upsample=True, test_mode=False):
    '  '
    image1 = ((2 * (image1 / 255.0)) - 1.0)
    image2 = ((2 * (image2 / 255.0)) - 1.0)
    image1 = image1.contiguous()
    image2 = image2.contiguous()
    hdim = self.hidden_dim
    cdim = self.context_dim
    with autocast(enabled=self.args.mixed_precision):
        (fmap1, fmap2) = self.fnet([image1, image2])
    fmap1 = fmap1.float()
    fmap2 = fmap2.float()
    if self.args.alternate_corr:
        corr_fn = AlternateCorrBlock(fmap1, fmap2, radius=self.args.corr_radius)
    else:
        corr_fn = CorrBlock(fmap1, fmap2, radius=self.args.corr_radius)
    with autocast(enabled=self.args.mixed_precision):
        cnet = self.cnet(image1)
        (net, inp) = torch.split(cnet, [hdim, cdim], dim=1)
        net = torch.tanh(net)
        inp = torch.relu(inp)
    (coords0, coords1) = self.initialize_flow(image1)
    if (flow_init is not None):
        coords1 = (coords1 + flow_init)
    flow_predictions = []
    for itr in range(iters):
        coords1 = coords1.detach()
        corr = corr_fn(coords1)
        flow = (coords1 - coords0)
        with autocast(enabled=self.args.mixed_precision):
            (net, up_mask, delta_flow) = self.update_block(net, inp, corr, flow)
        coords1 = (coords1 + delta_flow)
        if (up_mask is None):
            flow_up = upflow8((coords1 - coords0))
        else:
            flow_up = self.upsample_flow((coords1 - coords0), up_mask)
        flow_predictions.append(flow_up)
    if test_mode:
        corr = corr_fn(coords1)
        feat = inp
        return ((coords1 - coords0), flow_up, (feat, fmap1, fmap2))
    return flow_predictions