Esempio n. 1
0
    def load_template(self):
        if not os.path.exists("./data/template/template.ply"):
            os.system("chmod +x ./data/download_template.sh")
            os.system("./data/download_template.sh")

        mesh = trimesh.load("./data/template/template.ply", process=False)
        self.mesh = mesh
        point_set = mesh.vertices
        point_set, _, _ = pointcloud_processor.center_bounding_box(point_set)

        mesh_HR = trimesh.load("./data/template/template_dense.ply", process=False)
        self.mesh_HR = mesh_HR
        point_set_HR = mesh_HR.vertices
        point_set_HR, _, _ = pointcloud_processor.center_bounding_box(point_set_HR)

        self.vertex = torch.from_numpy(point_set).cuda().float()
        self.vertex_HR = torch.from_numpy(point_set_HR).cuda().float()
        self.num_vertex = self.vertex.size(0)
        self.num_vertex_HR = self.vertex_HR.size(0)
        self.prop = pointcloud_processor.get_vertex_normalised_area(mesh)
        assert (np.abs(np.sum(self.prop) - 1) < 0.001), "Propabilities do not sum to 1!)"
        self.prop = torch.from_numpy(self.prop).cuda().unsqueeze(0).float()
        red = self.red_LR
        green = self.green_LR
        blue = self.blue_LR
        mesh_ref = self.mesh_ref_LR
        self.save(mesh,mesh_ref,path=self.save_path,red=red,green=green,blue=blue)
Esempio n. 2
0
    def __init__(self, train, npoints=2500, regular_sampling=False, normal=False, data_augmentation_Z_rotation=False,
                 data_augmentation_Z_rotation_range=360, data_augmentation_3D_rotation=False):

        self.data_augmentation_Z_rotation = data_augmentation_Z_rotation
        self.data_augmentation_Z_rotation_range = data_augmentation_Z_rotation_range
        self.data_augmentation_3D_rotation = data_augmentation_3D_rotation
        self.normal = normal
        self.train = train
        self.regular_sampling = regular_sampling  # sample points uniformly or proportionaly to their adjacent area
        self.npoints = npoints

        self.datas = []
        start = time.time()
        if not os.path.exists("./data/datas_surreal_train.pth"):
            os.system("chmod +x ./data/download_dataset.sh")
            os.system("./data/download_dataset.sh")
            os.system("mv *.pth data/")

        if self.train:
            self.datas = torch.load("./data/datas_surreal_train.pth")
        else:
            self.datas = torch.load("./data/datas_surreal_test.pth")

        end = time.time()
        print("Ellapsed time to load dataset: ", end - start)
        # template
        if not os.path.exists("./data/template/template.ply"):
            os.system("chmod +x ./data/download_template.sh")
            os.system("./data/download_template.sh")

        self.mesh = trimesh.load("./data/template/template.ply", process=False)
        self.prop = pointcloud_processor.get_vertex_normalised_area(self.mesh)
        assert (np.abs(np.sum(self.prop) - 1) < 0.001), "Propabilities do not sum to 1!)"
Esempio n. 3
0
    def load_template(self):
        if not os.path.exists("./data/template/template.ply"):
            os.system("chmod +x ./data/download_template.sh")
            os.system("./data/download_template.sh")

        mesh = trimesh.load("./data/template/template.ply", process=False)
        self.mesh = mesh
        point_set = mesh.vertices
        point_set, _, _ = pointcloud_processor.center_bounding_box(point_set)

        mesh_HR = trimesh.load("./data/template/template_dense.ply",
                               process=False)
        self.mesh_HR = mesh_HR
        point_set_HR = mesh_HR.vertices
        point_set_HR, _, _ = pointcloud_processor.center_bounding_box(
            point_set_HR)

        self.vertex = torch.from_numpy(point_set).cuda().float()
        self.vertex_HR = torch.from_numpy(point_set_HR).cuda().float()
        self.num_vertex = self.vertex.size(0)
        self.num_vertex_HR = self.vertex_HR.size(0)
        self.prop = pointcloud_processor.get_vertex_normalised_area(mesh)
        assert (np.abs(np.sum(self.prop) - 1) <
                0.001), "Propabilities do not sum to 1!)"
        self.prop = torch.from_numpy(self.prop).cuda().unsqueeze(0).float()
        self.Rig_list = []
        head = np.load("./data/output/head_indices.npy")
        self.Rig_list.append(head)
        left_arm_down = np.load("./data/output/left_arm_down_indices.npy")
        self.Rig_list.append(left_arm_down)
        left_arm = np.load("./data/output/left_arm_indices.npy")
        self.Rig_list.append(left_arm)
        left_foot = np.load("./data/output/left_foot_indices.npy")
        self.Rig_list.append(left_foot)
        left_hand = np.load("./data/output/left_hand_indices.npy")
        self.Rig_list.append(left_hand)
        left_leg_down = np.load("./data/output/left_leg_down_indices.npy")
        self.Rig_list.append(left_leg_down)
        left_leg = np.load("./data/output/left_leg_indices.npy")
        self.Rig_list.append(left_leg)
        right_arm_down = np.load("./data/output/right_arm_down_indices.npy")
        self.Rig_list.append(right_arm_down)
        right_arm = np.load("./data/output/right_arm_indices.npy")
        self.Rig_list.append(right_arm)
        right_foot = np.load("./data/output/right_foot_indices.npy")
        self.Rig_list.append(right_foot)
        right_hand = np.load("./data/output/right_hand_indices.npy")
        self.Rig_list.append(right_hand)
        right_leg_down = np.load("./data/output/right_leg_down_indices.npy")
        self.Rig_list.append(right_leg_down)
        right_leg = np.load("./data/output/right_leg_indices.npy")
        self.Rig_list.append(right_leg)
        torso = np.load("./data/output/torso_indices.npy")
        self.Rig_list.append(torso)

        self.Rig_HD_list = []
        '''
Esempio n. 4
0
    def init_template(self):
        if not os.path.exists("./data/template/template.ply"):
            os.system("chmod +x ./data/download_template.sh")
            os.system("./data/download_template.sh")

        mesh = trimesh.load("./data/template/template.ply", process=False)
        self.mesh = mesh
        point_set = mesh.vertices
        point_set, _, _ = pointcloud_processor.center_bounding_box(point_set)

        mesh_HR = trimesh.load("./data/template/template_dense.ply", process=False)
        self.mesh_HR = mesh_HR
        point_set_HR = mesh_HR.vertices
        point_set_HR, _, _ = pointcloud_processor.center_bounding_box(point_set_HR)

        self.vertex = torch.from_numpy(point_set).cuda().float()
        self.vertex_HR = torch.from_numpy(point_set_HR).cuda().float()
        self.num_vertex = self.vertex.size(0)
        self.num_vertex_HR = self.vertex_HR.size(0)
        self.prop = pointcloud_processor.get_vertex_normalised_area(mesh)
        assert (np.abs(np.sum(self.prop) - 1) < 0.001), "Propabilities do not sum to 1!)"
        self.prop = torch.from_numpy(self.prop).cuda().unsqueeze(0).float()
        print(f"Using template to initialize template")
Esempio n. 5
0
    def init_template(self, dataset_train, device):

        self.mesh = trimesh.load(dataset_train, process=False)
        point_set = self.mesh.vertices
        point_set, _, _ = pointcloud_processor.center_bounding_box(point_set)

        self.mesh_HR = trimesh.load(dataset_train, process=False)
        point_set_HR = self.mesh_HR.vertices
        point_set_HR, _, _ = pointcloud_processor.center_bounding_box(
            point_set_HR)

        vertex = torch.from_numpy(point_set).float()
        self.vertex = vertex.to(device)
        vertex_HR = torch.from_numpy(point_set_HR).float()
        self.vertex_HR = vertex_HR.to(device)

        self.num_vertex = self.vertex.size(0)
        self.num_vertex_HR = self.vertex_HR.size(0)
        self.prop = pointcloud_processor.get_vertex_normalised_area(self.mesh)
        assert (np.abs(np.sum(self.prop) - 1) <
                0.001), "Propabilities do not sum to 1!)"
        self.prop = torch.from_numpy(self.prop).unsqueeze(0).float()
        self.prop = self.prop.to(device)
        print(f"Using template to initialize template")