MCPcopy Create free account
hub / github.com/d62lu/3DCTN / __getitem__

Method __getitem__

data_utils/ShapeNetDataLoader.py:89–112  ·  view source on GitHub ↗
(self, index)

Source from the content-addressed store, hash-verified

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)

Callers

nothing calls this directly

Calls 1

pc_normalizeFunction · 0.70

Tested by

no test coverage detected