(root_dir, viz_root_dir, fn1, fn2, keep_size)
| 114 | return image_size |
| 115 | |
| 116 | def prepare_image(root_dir, viz_root_dir, fn1, fn2, keep_size): |
| 117 | print(f"preparing image...") |
| 118 | print(f"root dir = {root_dir}, fn = {fn1}") |
| 119 | |
| 120 | image1 = frame_utils.read_gen(osp.join(root_dir, fn1)) |
| 121 | image2 = frame_utils.read_gen(osp.join(root_dir, fn2)) |
| 122 | image1 = np.array(image1).astype(np.uint8)[..., :3] |
| 123 | image2 = np.array(image2).astype(np.uint8)[..., :3] |
| 124 | if not keep_size: |
| 125 | dsize = compute_adaptive_image_size(image1.shape[0:2]) |
| 126 | image1 = cv2.resize(image1, dsize=dsize, interpolation=cv2.INTER_CUBIC) |
| 127 | image2 = cv2.resize(image2, dsize=dsize, interpolation=cv2.INTER_CUBIC) |
| 128 | image1 = torch.from_numpy(image1).permute(2, 0, 1).float() |
| 129 | image2 = torch.from_numpy(image2).permute(2, 0, 1).float() |
| 130 | |
| 131 | |
| 132 | dirname = osp.dirname(fn1) |
| 133 | filename = osp.splitext(osp.basename(fn1))[0] |
| 134 | |
| 135 | viz_dir = osp.join(viz_root_dir, dirname) |
| 136 | if not osp.exists(viz_dir): |
| 137 | os.makedirs(viz_dir) |
| 138 | |
| 139 | viz_fn = osp.join(viz_dir, filename + '.png') |
| 140 | |
| 141 | return image1, image2, viz_fn |
| 142 | |
| 143 | def build_model(): |
| 144 | print(f"building model...") |
no test coverage detected