| 93 | self.transform = ToTensor() |
| 94 | |
| 95 | def __getitem__(self, idx): |
| 96 | image_path = self.image_files[idx] |
| 97 | depth_path = self.depth_files[idx] |
| 98 | depth_mask_path = self.depth_mask_files[idx] |
| 99 | |
| 100 | image = np.asarray(Image.open(image_path), dtype=np.float32) / 255.0 |
| 101 | depth = np.load(depth_path) # in meters |
| 102 | valid = np.load(depth_mask_path) # binary |
| 103 | |
| 104 | # depth[depth > 8] = -1 |
| 105 | # depth = depth[..., None] |
| 106 | |
| 107 | sample = dict(image=image, depth=depth, valid=valid) |
| 108 | |
| 109 | # return sample |
| 110 | sample = self.transform(sample) |
| 111 | |
| 112 | if idx == 0: |
| 113 | print(sample["image"].shape) |
| 114 | |
| 115 | return sample |
| 116 | |
| 117 | def __len__(self): |
| 118 | return len(self.image_files) |