def __getitem__(self, index): path = self.paths[index] mesh = Mesh(file=path, opt=self.opt, hold_history=True, export_folder=self.opt.export_folder) meta = {} meta['mesh'] = mesh if self.opt.edge_split: path_index = os.path.join( os.path.dirname(self.seg_paths[index]), 'cache\\' + os.path.basename(self.seg_paths[index])) label = read_seg(path_index) - self.offset else: label = read_seg(self.seg_paths[index]) - self.offset label = pad(label, self.opt.ninput_edges, val=-1, dim=0) meta['label'] = label if self.opt.edge_split: path_index = os.path.join( os.path.dirname(self.sseg_paths[index]), 'cache\\' + os.path.basename(self.sseg_paths[index])) soft_label = read_sseg(path_index) else: soft_label = read_sseg(self.sseg_paths[index]) meta['soft_label'] = pad(soft_label, self.opt.ninput_edges, val=-1, dim=0) # get edge features edge_features = mesh.extract_features() edge_features = pad(edge_features, self.opt.ninput_edges) meta['edge_features'] = (edge_features - self.mean) / self.std return meta
def __getitem__(self, index): path = self.paths[index] mesh = Mesh(file=path, opt=self.opt, hold_history=True, export_folder=self.opt.export_folder) meta = {} meta['mesh'] = mesh label = read_seg(self.seg_paths[index]) - self.offset label = pad(label, self.opt.ninput_edges, val=-1, dim=0) meta['label'] = label soft_label = read_sseg(self.sseg_paths[index]) meta['soft_label'] = pad(soft_label, self.opt.ninput_edges, val=-1, dim=0) # get edge features edge_features = mesh.extract_features() edge_features = pad(edge_features, self.opt.ninput_edges) meta['edge_features'] = (edge_features - self.mean) / self.std return meta
def __getitem__(self, index): path = self.paths[index][0] label = self.paths[index][1] mesh = Mesh(file=path, opt=self.opt, hold_history=False, export_folder=self.opt.export_folder) meta = {'mesh': mesh, 'label': label} # get edge features face_features = mesh.extract_features() face_features = pad(face_features, self.opt.ninput_faces) meta['face_features'] = (face_features - self.mean) / self.std return meta
def __getitem__(self, index): path = self.paths[index] mesh = Mesh(file=path, opt=self.opt, hold_history=True, export_folder=self.opt.export_folder) meta = {} meta['mesh'] = mesh # get edge features face_features = mesh.extract_features() meta['num_triangle'] = mesh.faces_count face_features = pad(face_features, self.opt.ninput_faces) meta['face_features'] = (face_features - self.mean) / self.std return meta
def __getitem__(self, index): path = self.paths[index] mesh = Mesh(file=path, opt=self.opt, hold_history=True, export_folder=self.opt.export_folder) # get edge features edge_features = mesh.extract_features() edge_features = pad(edge_features, self.opt.ninput_edges) meta = {'mesh': mesh, 'label': edge_features} meta['edge_features'] = (edge_features - self.mean) / self.std return meta
def __getitem__(self, index): path = self.paths[index] # print("opt: {}, export_folder: {}, phase: {}".format(self.opt, self.opt.export_folder, self.opt.phase)) mesh = Mesh(file=path, opt=self.opt, hold_history=True, export_folder=self.opt.export_folder, phase=self.opt.phase) meta = {} meta["filename"] = mesh.filename meta['mesh'] = mesh if self.opt.phase != "test": label = read_seg(self.seg_paths[index]) - self.offset # print("label: ", label.shape, type(label), label) # if len(label) > self.opt.ninput_edges: # label = label[mesh.e_masks] if len(label) <= self.opt.ninput_edges: label = pad(label, self.opt.ninput_edges, val=-1, dim=0) meta['label'] = label soft_label = read_sseg(self.sseg_paths[index]) # if len(soft_label) > self.opt.ninput_edges: # soft_label = soft_label[mesh.e_masks] if len(soft_label) <= self.opt.ninput_edges: soft_label = pad(soft_label, self.opt.ninput_edges, val=-1, dim=0) meta['soft_label'] = soft_label # get edge features edge_features = mesh.extract_features() if edge_features.shape[1] <= self.opt.ninput_edges: edge_features = pad(edge_features, self.opt.ninput_edges) meta['edge_features'] = (edge_features - self.mean) / self.std else: meta["edge_features"] = np.array([]) # print("edge_features: ", type(meta["edge_features"]), meta["edge_features"].shape) return meta
def __getitem__(self, index): path = self.paths[index][0] #print(path) mesh = Mesh(file=path, opt=self.opt, hold_history=True, export_folder=self.opt.export_folder) meta = {} mesh.vs = (mesh.vs - np.mean(mesh.vs, 0)) / np.std(mesh.vs, 0) meta['mesh'] = mesh meta['export_folder'] = mesh.export_folder meta['filename'] = mesh.filename # get edge features edge_features = mesh.extract_features() edge_features = pad(edge_features, self.opt.ninput_edges) vs, pad_iter = pad_vertices(mesh.vs, 1402) meta['edge_features'] = (edge_features - self.mean) / self.std meta['label'] = vs.astype(np.float) meta['init_faces'] = mesh.init_faces meta['pad_iter'] = pad_iter return meta
def get_random_profile_lines(self): profile_lines = util.tokenize_sentences(self.profile) random.seed(keys.RANDOM_SEED + datetime.today().toordinal()) random_profile_lines = random.sample(util.pad(profile_lines, '', 3), 3) random_profile_lines = [util.shorten_if_long(l) for l in random_profile_lines] return random_profile_lines
def __extract(meshes, nv, device): vs = [pad(mesh.vs, nv, dim=0) for mesh in meshes] vs = np.array(vs) vs = torch.from_numpy(vs).float().to(device) vs.requires_grad_() return vs