(model, model_path, sintel_path)
| 86 | |
| 87 | |
| 88 | def inference(model, model_path, sintel_path): |
| 89 | ds = SintelData(sintel_path) |
| 90 | |
| 91 | def nhwc2nchw(dp): |
| 92 | return [dp[0].transpose(2, 0, 1), |
| 93 | dp[1].transpose(2, 0, 1), |
| 94 | dp[2].transpose(2, 0, 1)] |
| 95 | |
| 96 | ds = MapData(ds, nhwc2nchw) |
| 97 | ds = BatchData(ds, 1) |
| 98 | ds.reset_state() |
| 99 | |
| 100 | # look at shape information (all images in Sintel has the same shape) |
| 101 | h, w = next(ds.__iter__())[0].shape[2:] |
| 102 | |
| 103 | pred = PredictConfig( |
| 104 | model=model(height=h, width=w), |
| 105 | session_init=SmartInit(model_path), |
| 106 | input_names=['left', 'right', 'gt_flow'], |
| 107 | output_names=['epe', 'prediction']) |
| 108 | pred = SimpleDatasetPredictor(pred, ds) |
| 109 | |
| 110 | avg_epe, count_epe = 0, 0 |
| 111 | |
| 112 | for o in pred.get_result(): |
| 113 | avg_epe += o[0] |
| 114 | count_epe += 1 |
| 115 | |
| 116 | print('average endpoint error (AEE): %f' % (float(avg_epe) / float(count_epe))) |
| 117 | |
| 118 | |
| 119 | if __name__ == '__main__': |
no test coverage detected
searching dependent graphs…