Пример #1
0
 def __call__(self, img_path):
     kps = get_people(img_path)
     input_img, proc_param, img = preprocess_image(img_path, kps)
     # Add batch dimension: 1 x D x D x 3
     input_img = np.expand_dims(input_img, 0)
     joints, verts, cams, joints3d, theta = self._model.predict(
         input_img, get_theta=True)
     # theta SMPL angles
     return self.kinematicTree(theta[0])
Пример #2
0
def main(img_path):
    sess = tf.Session()
    model = RunModel(config, sess=sess)
    kps = get_people(img_path)

    input_img, proc_param, img = preprocess_image(img_path, kps)
    # Add batch dimension: 1 x D x D x 3
    input_img = np.expand_dims(input_img, 0)

    joints, verts, cams, joints3d, theta = model.predict(input_img,
                                                         get_theta=True)
    print(joints3d.shape)

    p3d(joints3d, cams[0], proc_param)
Пример #3
0
    def locate_person_and_crop(self, img_path):
        kps = get_people(img_path)
        img = io.imread(img_path)
        if img.shape[2] == 4:
            img = img[:, :, :3]

        scale, center = op_util.get_bbox_dict(kps)
        crop, proc_param = img_util.scale_and_crop(img, scale, center,
                                                   224)
        # Normalize image to [-1, 1]
        crop = 2 * ((crop / 255.) - 0.5)
        # Add batch dimension: 1 x D x D x 3
        crop = np.expand_dims(crop, 0)

        return crop, proc_param, img
Пример #4
0
def main(img_path):
    sess = tf.Session()
    model = RunModel(config, sess=sess)
    kps = get_people(img_path)

    input_img, proc_param, img = preprocess_image(img_path, kps)
    # Add batch dimension: 1 x D x D x 3
    input_img = np.expand_dims(input_img, 0)

    joints, verts, cams, joints3d, theta = model.predict(input_img,
                                                         get_theta=True)

    theta = theta[0, 3:75]
    q = quaternion.from_rotation_vector(theta[3:6])
    print(q)
    q = quaternion.from_rotation_vector(theta[6:9])
    print(q)
    get_angles(joints3d, cams[0], proc_param)
Пример #5
0
def main(img_dir):
    sess = tf.Session()
    model = RunModel(config, sess=sess)

    print(img_dir)
    onlyfiles = [
        f for f in os.listdir(img_dir)
        if os.path.isfile(os.path.join(img_dir, f))
    ]
    for file in onlyfiles:
        img_path = os.path.join(img_dir, file)
        kps = get_people(img_path)

        input_img, proc_param, img = preprocess_image(img_path, kps)
        # Add batch dimension: 1 x D x D x 3
        input_img = np.expand_dims(input_img, 0)

        joints, verts, cams, joints3d, theta = model.predict(input_img,
                                                             get_theta=True)

        p3d(img, joints3d, joints[0], verts[0], cams[0], proc_param, file)