sniklaus/softmax-splatting

Replicate your gif warp results?

noobtoob4lyfe opened this issue · 2 comments

          As stated by @laomao0, softmax splatting performs forward and not backward warping. Please see the following for a concrete example of using softmax splatting on the Sintel dataset.
tenFirst = torch.FloatTensor(numpy.ascontiguousarray(cv2.imread(filename='./frame_0001.png', flags=-1).transpose(2, 0, 1)[None, :, :, :].astype(numpy.float32) * (1.0 / 255.0))).cuda()
tenSecond = torch.FloatTensor(numpy.ascontiguousarray(cv2.imread(filename='./frame_0002.png', flags=-1).transpose(2, 0, 1)[None, :, :, :].astype(numpy.float32) * (1.0 / 255.0))).cuda()
tenFlow = torch.FloatTensor(numpy.ascontiguousarray(read_flo('./frame_0001.flo').transpose(2, 0, 1)[None, :, :, :])).cuda()

tenMetric = torch.nn.functional.l1_loss(input=tenFirst, target=backwarp(tenInput=tenSecond, tenFlow=tenFlow), reduction='none').mean(1, True)

tenOutputs = [softsplat.FunctionSoftsplat(tenInput=tenFirst, tenFlow=tenFlow * fltTime, tenMetric=-20.0 * tenMetric, strType='softmax') for fltTime in numpy.linspace(0.0, 1.0, 11).tolist()]
npyOutputs = [(tenOutput[0, :, :, :].cpu().numpy().transpose(1, 2, 0) * 255.0).clip(0.0, 255.0).astype(numpy.uint8) for tenOutput in tenOutputs + list(reversed(tenOutputs[1:-1]))]

moviepy.editor.ImageSequenceClip(sequence=[npyOutput[:, :, ::-1] for npyOutput in npyOutputs], fps=15).write_gif('./out.gif')

Which yields the following sequence where bandage_1/clean/frame_0001.png has been forward warped according to the optical flow in bandage_1/flow/frame_0001.flo.

out

Originally posted by @sniklaus in #10 (comment)

        Is the the full python script you've posted here?  I'm able to run your other scripts, however this one returns errors.  Do you have any ideas about what I'm missing based on the error below?  
        
        "tenMetric = torch.nn.functional.l1_loss(input=tenFirst, target=run.backwarp(tenInput=tenSecond, tenFlow=tenFlow), reduction='none').mean(1, True)

TypeError: backwarp() got an unexpected keyword argument 'tenInput'"

        "

Thank you for your interest in our work. I am afraid that I am unsure what this issue is about, would you mind clarifying?

If it is about the TypeError: backwarp() got an unexpected keyword argument 'tenInput'" then try using tenIn instead.

Closing due to inactivity, feel free to reopen in case you still need help.