(self, index)
| 48 | return len(self.image_total_files) |
| 49 | |
| 50 | def __getitem__(self, index): |
| 51 | # Get File Paths |
| 52 | test_rgb_path = self.image_total_files[index] |
| 53 | test_depth_path = test_rgb_path.replace('rgb', 'depth') |
| 54 | test_segmentation_path = test_rgb_path.replace('rgb', 'semantic_segmentation') |
| 55 | ref_rgb_path = test_rgb_path.replace('rgb', 't0/rgb') |
| 56 | ref_depth_path = test_rgb_path.replace('rgb', 't0/depth') |
| 57 | change_segmentation_path = test_rgb_path.replace('rgb', 'change_segmentation') |
| 58 | name = '_'.join(test_rgb_path.split('/')[-5:]) |
| 59 | |
| 60 | # RGB |
| 61 | test_rgb = Image.open(test_rgb_path) |
| 62 | ref_rgb = Image.open(ref_rgb_path) |
| 63 | test_rgb = test_rgb.resize(self.crop_size, Image.BICUBIC) |
| 64 | ref_rgb = ref_rgb.resize(self.crop_size, Image.BICUBIC) |
| 65 | test_rgb = ToTensor()(test_rgb) |
| 66 | ref_rgb = ToTensor()(ref_rgb) |
| 67 | |
| 68 | # Depth |
| 69 | test_depth = Image.open(test_depth_path) |
| 70 | test_depth = test_depth.resize(self.crop_size, Image.BICUBIC) |
| 71 | test_depth = np.asarray(test_depth) |
| 72 | test_depth = test_depth.astype('float32') / 255 |
| 73 | test_depth = torch.from_numpy(test_depth) |
| 74 | |
| 75 | ref_depth = Image.open(ref_depth_path) |
| 76 | ref_depth = ref_depth.resize(self.crop_size, Image.BICUBIC) |
| 77 | ref_depth = np.clip(ref_depth, 0, 50000) / 50000 * 255 # scaling, 50m = 500000mm |
| 78 | ref_depth = np.asarray(ref_depth) |
| 79 | ref_depth = ref_depth.astype('float32') / 255 |
| 80 | ref_depth = torch.from_numpy(ref_depth) |
| 81 | |
| 82 | # Semantic Segmentation |
| 83 | test_segmentation = Image.open(test_segmentation_path) |
| 84 | test_segmentation = test_segmentation.resize(self.crop_size, Image.BICUBIC) |
| 85 | test_segmentation = ToTensor()(test_segmentation) |
| 86 | |
| 87 | # Change Label |
| 88 | change_label = Image.open(change_segmentation_path) |
| 89 | label = change_label.resize(self.crop_size, Image.NEAREST) |
| 90 | label = ToTensor()(label) |
| 91 | |
| 92 | return [ref_rgb, test_rgb], [ref_depth.unsqueeze(0),test_depth.unsqueeze(0)], test_segmentation, label, test_rgb_path |
| 93 | |
| 94 | |
| 95 | if __name__ == '__main__': |
nothing calls this directly
no outgoing calls
no test coverage detected