예제 #1
0
    def create_prior_from_cmu(self):
        """Load the gmm from the CMU motion database."""
        from os.path import dirname
        # import cPickle as pickle
        import pickle
        with open(
                os.path.join(dirname(dirname(__file__)), 'models',
                             'gmm_%02d.pkl' % self.n_gaussians), 'rb') as f:
            gmm = pickle.load(f, encoding="latin1")

        precs = ch.asarray([np.linalg.inv(cov) for cov in gmm['covars']])
        chols = ch.asarray([np.linalg.cholesky(prec) for prec in precs])

        # The constant term:
        sqrdets = np.array([(np.sqrt(np.linalg.det(c)))
                            for c in gmm['covars']])
        const = (2 * np.pi)**(69 / 2.)

        self.weights = ch.asarray(gmm['weights'] / (const *
                                                    (sqrdets / sqrdets.min())))

        return (MaxMixtureCompleteWrapper(means=gmm['means'],
                                          precs=chols,
                                          weights=self.weights,
                                          prefix=self.prefix))
예제 #2
0
    def create_prior_from_cmu(self):
        """Load the gmm from the CMU motion database."""
        from os.path import dirname
        import cPickle as pickle
        with open(
                os.path.join(
                    dirname(dirname(__file__)), 'models', 'gmm_%02d.pkl' %
                    self.n_gaussians)) as f:
            gmm = pickle.load(f)

        precs = ch.asarray([np.linalg.inv(cov) for cov in gmm['covars']])
        chols = ch.asarray([np.linalg.cholesky(prec) for prec in precs])

        # The constant term:
        sqrdets = np.array([(np.sqrt(np.linalg.det(c)))
                            for c in gmm['covars']])
        const = (2 * np.pi)**(69 / 2.)

        self.weights = ch.asarray(gmm['weights'] / (const *
                                                    (sqrdets / sqrdets.min())))

        return (MaxMixtureCompleteWrapper(
            means=gmm['means'],
            precs=chols,
            weights=self.weights,
            prefix=self.prefix))
예제 #3
0
    def create_prior_from_cmu(self):
        """Get the prior from the CMU motion database."""
        from os.path import realpath
        import cPickle as pickle
        with open(os.path.join(os.path.dirname(__file__),
                               '..', 'models', '3D',
                               'gmm_best_%02d.pkl' % self.n_gaussians)) as f:
            gmm = pickle.load(f)

        precs = ch.asarray([np.linalg.inv(cov) for cov in gmm.covars_])
        chols = ch.asarray([np.linalg.cholesky(prec) for prec in precs])

        # The constant term:
        sqrdets = np.array([(np.sqrt(np.linalg.det(c))) for c in gmm.covars_])
        const = (2*np.pi)**(69/2.)

        self.weights = ch.asarray(gmm.weights_ / (const * (sqrdets/sqrdets.min())))

        return(MaxMixtureCompleteWrapper(means=gmm.means_, precs=chols,
                                         weights=self.weights, prefix=self.prefix))
예제 #4
0
import chumpy as ch
import scipy.sparse as sp

from capsule_ch import Capsule

joint2name = ['pelvis', 'leftThigh', 'rightThigh', 'spine', 'leftCalf',
              'rightCalf', 'spine1', 'leftFoot', 'rightFoot', 'spine2', 'neck',
              'leftShoulder', 'rightShoulder', 'head', 'leftUpperArm',
              'rightUpperArm', 'leftForeArm', 'rightForeArm', 'leftHand',
              'rightHand']

# the orientation of each capsule
rots0 = ch.asarray(
    [[0, 0, np.pi / 2], [0, 0, np.pi], [0, 0, np.pi], [0, 0, np.pi / 2],
     [0, 0, np.pi], [0, 0, np.pi], [0, 0, np.pi / 2], [np.pi / 2, 0, 0],
     [np.pi / 2, 0, 0], [0, 0, np.pi / 2], [0, 0, 0], [0, 0, -np.pi / 2],
     [0, 0, np.pi / 2], [0, 0, 0], [0, 0, -np.pi / 2], [0, 0, np.pi / 2],
     [0, 0, -np.pi / 2], [0, 0, np.pi / 2], [0, 0, -np.pi / 2],
     [0, 0, np.pi / 2]])

# groups hands and fingers, feet and toes
# each comment line provides the body part corresonding to the capsule
# and the corresponding id
mujoco2segm = [[0],  # hip 0
               [1],  # leftThigh 1
               [2],  # rightThigh 2
               [3],  # spine 3
               [4],  # leftCalf 4
               [5],  # rightCalf 5
               [6],  # spine1 6
               [7, 10],  # leftFoot + leftToes 7
예제 #5
0
import scipy.sparse as sp

from capsule_ch import Capsule

joint2name = [
    'pelvis', 'leftThigh', 'rightThigh', 'spine', 'leftCalf', 'rightCalf',
    'spine1', 'leftFoot', 'rightFoot', 'spine2', 'neck', 'leftShoulder',
    'rightShoulder', 'head', 'leftUpperArm', 'rightUpperArm', 'leftForeArm',
    'rightForeArm', 'leftHand', 'rightHand'
]

# the orientation of each capsule
rots0 = ch.asarray([[0, 0, np.pi / 2], [0, 0, np.pi], [0, 0, np.pi],
                    [0, 0, np.pi / 2], [0, 0, np.pi], [0, 0, np.pi],
                    [0, 0, np.pi / 2], [np.pi / 2, 0, 0], [np.pi / 2, 0, 0],
                    [0, 0, np.pi / 2], [0, 0, 0], [0, 0, -np.pi / 2],
                    [0, 0, np.pi / 2], [0, 0, 0], [0, 0, -np.pi / 2],
                    [0, 0, np.pi / 2], [0, 0, -np.pi / 2], [0, 0, np.pi / 2],
                    [0, 0, -np.pi / 2], [0, 0, np.pi / 2]])

# groups hands and fingers, feet and toes
# each comment line provides the body part corresonding to the capsule
# and the corresponding id
mujoco2segm = [
    [0],  # hip 0
    [1],  # leftThigh 1
    [2],  # rightThigh 2
    [3],  # spine 3
    [4],  # leftCalf 4
    [5],  # rightCalf 5
    [6],  # spine1 6