(args)
| 40 | |
| 41 | |
| 42 | def demo(args): |
| 43 | model = torch.nn.DataParallel(RAFT(args)) |
| 44 | model.load_state_dict(torch.load(args.model)) |
| 45 | |
| 46 | model = model.module |
| 47 | model.to(DEVICE) |
| 48 | model.eval() |
| 49 | |
| 50 | with torch.no_grad(): |
| 51 | images = glob.glob(os.path.join(args.path, '*.png')) + \ |
| 52 | glob.glob(os.path.join(args.path, '*.jpg')) |
| 53 | |
| 54 | images = sorted(images) |
| 55 | for imfile1, imfile2 in zip(images[:-1], images[1:]): |
| 56 | image1 = load_image(imfile1) |
| 57 | image2 = load_image(imfile2) |
| 58 | |
| 59 | padder = InputPadder(image1.shape) |
| 60 | image1, image2 = padder.pad(image1, image2) |
| 61 | |
| 62 | flow_low, flow_up = model(image1, image2, iters=20, test_mode=True) |
| 63 | viz(image1, flow_up) |
| 64 | |
| 65 | |
| 66 | if __name__ == '__main__': |
no test coverage detected