示例#1
0
 def __init__(self, data_path):
     Dataset.__init__(self)
     bvh = BVH()
     bvh.load(data_path)
     self.bvh = bvh
     self.phases = np.loadtxt(data_path.replace('bvh', 'phase'))
     self.root_motions = bvh.motions[:, :num_of_root_infos]
     self.phase_deltas = self.phases[1:] - self.phases[:-1]
     self.phase_deltas *= phase_scale
     print(self.phase_deltas[200:300])
示例#2
0
    def __init__(self,
                 data_root,
                 transform=None):
        """TODO: to be defined.

        :data_root: TODO
        :transform: TODO

        """
        Dataset.__init__(self)

        assert isinstance(data_root, str)
        assert Path(data_root).resolve().exists()
        self._data_root = Path(data_root).resolve()
        assert transform is not None
        self._transform = transform
示例#3
0
    def __init__(self, data_path):
        Dataset.__init__(self)
        bvh = BVH()
        bvh.load(data_path)
        self.bvh = bvh
        self.phases = np.loadtxt(data_path.replace('bvh',
                                                   'phase'))[start_index:]
        self.phase_deltas = (self.phases[1:] - self.phases[:-1])
        self.phase_deltas[self.phase_deltas < 0] += 1
        self.phase_deltas_mean = np.mean(self.phase_deltas, axis=0)
        self.phase_deltas_std = np.std(self.phase_deltas, axis=0)
        self.phase_deltas = (self.phase_deltas -
                             self.phase_deltas_mean) / self.phase_deltas_std
        self.phase_deltas *= phase_scale

        self.root_motions = bvh.motions[start_index:, :num_of_root_infos]
        self.trajectories = self.root_motions[:, [0, 2, 4]]
        self.trajectories = self.trajectories[1:] - self.trajectories[:-1]

        print(self.root_motions[:-1, [4]].shape)
        self.trajectories = np.concatenate(
            [self.trajectories, self.root_motions[:-1, [4]]], axis=1)
        self.trajectory_mean = np.mean(self.trajectories, axis=0)
        self.trajectory_std = np.std(self.trajectories, axis=0)
        self.trajectories = (self.trajectories -
                             self.trajectory_mean) / self.trajectory_std
        self.trajectories *= trajectory_scale

        self.angles = self.bvh.motion_angles[start_index:]
        self.angles_mean = np.mean(self.angles, axis=0)
        self.angles_std = np.std(self.angles, axis=0)
        # print(self.angles_mean.shape)
        # print(self.angles_std)
        # print(self.angles)
        print(self.angles.shape)
        self.angles_delta = self.angles[1:] - self.angles[:-1]
        self.angles_delta_mean = np.mean(self.angles_delta, axis=0)
        self.angles_delta_std = np.std(self.angles_delta, axis=0)

        self.angles = (self.angles-self.angles_mean) / \
            (self.angles_std+(self.angles_std == 0))
        self.angles_delta = (self.angles_delta-self.angles_delta_mean) / \
            (self.angles_delta_std+(self.angles_delta_std == 0))

        self.angles *= angles_scale
        self.angles_delta *= angles_scale
示例#4
0
 def __init__(self, data_path):
     Dataset.__init__(self)
     bvh = BVH()
     bvh.load(data_path)
     self.bvh = bvh
     self.phases = np.loadtxt(data_path.replace('bvh', 'phase'))
     print(self.phases.shape)
     root_motions = bvh.motions[:, :num_of_root_infos]
     self.root_deltas = root_motions[1:] - root_motions[:-1]
     print(self.root_deltas.shape)
     self.root_deltas[:, 0] *= delta_scale
     self.root_deltas[:, 2] *= delta_scale
     for i in range(6):
         items = self.root_deltas[:, i]
         print(np.max(items), np.min(items), np.mean(items))
     self.phase_deltas = self.phases[1:] - self.phases[:-1]
     self.phase_deltas *= phase_scale
     items = self.phase_deltas
     print(np.max(items), np.min(items), np.mean(items))
示例#5
0
    def __init__(self, files_source, transforms=None):
        Dataset.__init__(self)
        self.transforms = transforms

        # get number of classes
        self.classes = sorted(os.listdir(files_source))
        self.name_to_id = {
            self.classes[i]: i
            for i in range(len(self.classes))
        }
        if len(self.classes) != 1000:
            raise ValueError(
                "There should be 1000 classes, only {} exist".format(
                    len(self.classes)))

        # get files list
        if isinstance(files_source, str) and os.path.isdir(files_source):
            self.files = glob.glob(os.path.join(files_source, "*/*.npz"))
        else:
            raise ValueError(
                "You should provide either dir_path or paths_list!")
示例#6
0
 def __init__(self, bvh, num_of_frames):
     Dataset.__init__(self)
     self.bvh = bvh
     self.motions = bvh.motions
     self.num_of_frames = num_of_frames