Create submission for the Sintel leaderboard
(model, output_path='sintel_submission')
| 80 | |
| 81 | @torch.no_grad() |
| 82 | def create_sintel_submission(model, output_path='sintel_submission'): |
| 83 | """ Create submission for the Sintel leaderboard """ |
| 84 | |
| 85 | model.eval() |
| 86 | for dstype in ['final', "clean"]: |
| 87 | test_dataset = datasets.MpiSintel(split='test', aug_params=None, dstype=dstype) |
| 88 | |
| 89 | for test_id in range(len(test_dataset)): |
| 90 | if (test_id+1) % 100 == 0: |
| 91 | print(f"{test_id} / {len(test_dataset)}") |
| 92 | image1, image2, (sequence, frame) = test_dataset[test_id] |
| 93 | image1, image2 = image1[None].cuda(), image2[None].cuda() |
| 94 | |
| 95 | padder = InputPadder(image1.shape) |
| 96 | image1, image2 = padder.pad(image1, image2) |
| 97 | |
| 98 | flow_pre = model(image1, image2) |
| 99 | |
| 100 | flow_pre = padder.unpad(flow_pre[0]).cpu() |
| 101 | flow = flow_pre[0].permute(1, 2, 0).cpu().numpy() |
| 102 | |
| 103 | output_dir = os.path.join(output_path, dstype, sequence) |
| 104 | output_file = os.path.join(output_dir, 'frame%04d.flo' % (frame+1)) |
| 105 | |
| 106 | if not os.path.exists(output_dir): |
| 107 | os.makedirs(output_dir) |
| 108 | |
| 109 | frame_utils.writeFlow(output_file, flow) |
| 110 | |
| 111 | |
| 112 | @torch.no_grad() |
no test coverage detected