Create submission for the Sintel leaderboard
(model, output_path='sintel_submission_multi8_768', sigma=0.05)
| 87 | |
| 88 | @torch.no_grad() |
| 89 | def create_sintel_submission(model, output_path='sintel_submission_multi8_768', sigma=0.05): |
| 90 | """ Create submission for the Sintel leaderboard """ |
| 91 | print("no warm start") |
| 92 | #print(f"output path: {output_path}") |
| 93 | IMAGE_SIZE = [436, 1024] |
| 94 | |
| 95 | hws = compute_grid_indices(IMAGE_SIZE) |
| 96 | weights = compute_weight(hws, IMAGE_SIZE, TRAIN_SIZE, sigma) |
| 97 | |
| 98 | model.eval() |
| 99 | for dstype in ['final', "clean"]: |
| 100 | test_dataset = datasets.MpiSintel_submission(split='test', aug_params=None, dstype=dstype, root="./dataset/Sintel/test") |
| 101 | epe_list = [] |
| 102 | for test_id in range(len(test_dataset)): |
| 103 | if (test_id+1) % 100 == 0: |
| 104 | print(f"{test_id} / {len(test_dataset)}") |
| 105 | # break |
| 106 | image1, image2, (sequence, frame) = test_dataset[test_id] |
| 107 | image1, image2 = image1[None].cuda(), image2[None].cuda() |
| 108 | |
| 109 | flows = 0 |
| 110 | flow_count = 0 |
| 111 | |
| 112 | for idx, (h, w) in enumerate(hws): |
| 113 | image1_tile = image1[:, :, h:h+TRAIN_SIZE[0], w:w+TRAIN_SIZE[1]] |
| 114 | image2_tile = image2[:, :, h:h+TRAIN_SIZE[0], w:w+TRAIN_SIZE[1]] |
| 115 | flow_pre, flow_low = model(image1_tile, image2_tile) |
| 116 | |
| 117 | padding = (w, IMAGE_SIZE[1]-w-TRAIN_SIZE[1], h, IMAGE_SIZE[0]-h-TRAIN_SIZE[0], 0, 0) |
| 118 | flows += F.pad(flow_pre * weights[idx], padding) |
| 119 | flow_count += F.pad(weights[idx], padding) |
| 120 | |
| 121 | flow_pre = flows / flow_count |
| 122 | flow = flow_pre[0].permute(1, 2, 0).cpu().numpy() |
| 123 | |
| 124 | output_dir = os.path.join(output_path, dstype, sequence) |
| 125 | output_file = os.path.join(output_dir, 'frame%04d.flo' % (frame+1)) |
| 126 | |
| 127 | if not os.path.exists(output_dir): |
| 128 | os.makedirs(output_dir) |
| 129 | |
| 130 | frame_utils.writeFlow(output_file, flow) |
| 131 | |
| 132 | @torch.no_grad() |
| 133 | def create_kitti_submission(model, output_path='kitti_submission', sigma=0.05): |
nothing calls this directly
no test coverage detected