def _load_mesh(desc): path = desc['objs_dir'] objs = desc['objs'] mesh_list = [] for obj in eval(objs): obj_path = os.path.join(path, obj + '.obj') mesh_tmp = load_pc(obj_path) mesh_tmp, info = pymesh.remove_isolated_vertices(mesh_tmp) mesh_list.append(mesh_tmp) mesh = pymesh.merge_meshes(mesh_list) return mesh
def _getitem_instance(self, index): if index in self.cache: # print("!!!CACHED") mesh = self.cache[index] else: path = self.meta_in_action.iloc[index]['model_path'] mesh = load_pc(path) if len(self.cache) == self.cache_maxsize: pop_key = random.choice(list(self.cache.keys())) self.cache.pop(pop_key) # print("pop", pop_key) self.cache[index] = mesh # print("ins", index) if self.return_mode == "vertex": res = get_pc(mesh) else: res = mesh return res
def _getitem_leaf(self, index): if index in self.cache: mesh = self.cache[index] else: path = self.leafs_in_action.iloc[index]['objs_dir'] objs = self.leafs_in_action.iloc[index]['objs'] mesh_list = [] for obj in eval(objs): obj_path = os.path.join(path, obj + '.obj') mesh_tmp = load_pc(obj_path) mesh_tmp, info = pymesh.remove_isolated_vertices(mesh_tmp) mesh_list.append(mesh_tmp) mesh = pymesh.merge_meshes(mesh_list) if len(self.cache) == self.cache_maxsize: pop_key = random.choice(list(self.cache.keys())) self.cache.pop(pop_key) self.cache[index] = mesh if self.return_mode == "vertex": res = get_pc(mesh) else: res = mesh return res