(self, index)
| 87 | |
| 88 | |
| 89 | def __getitem__(self, index): |
| 90 | if index in self.cache: |
| 91 | point_set, cls, seg = self.cache[index] |
| 92 | else: |
| 93 | fn = self.datapath[index] |
| 94 | cat = self.datapath[index][0] |
| 95 | cls = self.classes[cat] |
| 96 | cls = np.array([cls]).astype(np.int32) |
| 97 | data = np.loadtxt(fn[1]).astype(np.float32) |
| 98 | if not self.normal_channel: |
| 99 | point_set = data[:, 0:3] |
| 100 | else: |
| 101 | point_set = data[:, 0:6] |
| 102 | seg = data[:, -1].astype(np.int32) |
| 103 | if len(self.cache) < self.cache_size: |
| 104 | self.cache[index] = (point_set, cls, seg) |
| 105 | point_set[:, 0:3] = pc_normalize(point_set[:, 0:3]) |
| 106 | |
| 107 | choice = np.random.choice(len(seg), self.npoints, replace=True) |
| 108 | # resample |
| 109 | point_set = point_set[choice, :] |
| 110 | seg = seg[choice] |
| 111 | |
| 112 | return point_set, cls, seg |
| 113 | |
| 114 | def __len__(self): |
| 115 | return len(self.datapath) |
nothing calls this directly
no test coverage detected