MCPcopy Create free account
hub / github.com/drinkingcoder/FlowFormer-Official / validate_sintel

Function validate_sintel

evaluate_FlowFormer.py:48–79  ·  view source on GitHub ↗

Peform validation using the Sintel (train) split

(model)

Source from the content-addressed store, hash-verified

46
47@torch.no_grad()
48def validate_sintel(model):
49 """ Peform validation using the Sintel (train) split """
50 model.eval()
51 results = {}
52 for dstype in ['clean', 'final']:
53 val_dataset = datasets.MpiSintel(split='training', dstype=dstype)
54 epe_list = []
55
56 for val_id in range(len(val_dataset)):
57 image1, image2, flow_gt, _ = val_dataset[val_id]
58 image1 = image1[None].cuda()
59 image2 = image2[None].cuda()
60 padder = InputPadder(image1.shape)
61 image1, image2 = padder.pad(image1, image2)
62
63 flow_pre = model(image1, image2)
64
65 flow_pre = padder.unpad(flow_pre[0]).cpu()[0]
66
67 epe = torch.sum((flow_pre - flow_gt)**2, dim=0).sqrt()
68 epe_list.append(epe.view(-1).numpy())
69
70 epe_all = np.concatenate(epe_list)
71 epe = np.mean(epe_all)
72 px1 = np.mean(epe_all<1)
73 px3 = np.mean(epe_all<3)
74 px5 = np.mean(epe_all<5)
75
76 print("Validation (%s) EPE: %f, 1px: %f, 3px: %f, 5px: %f" % (dstype, epe, px1, px3, px5))
77 results[dstype] = np.mean(epe_list)
78
79 return results
80
81@torch.no_grad()
82def create_sintel_submission(model, output_path='sintel_submission'):

Callers 1

Calls 3

padMethod · 0.95
unpadMethod · 0.95
InputPadderClass · 0.90

Tested by

no test coverage detected