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