コード例 #1
0
def main(args):
    args.use_smplx = True

    device = torch.device(
        'cuda') if torch.cuda.is_available() else torch.device('cpu')
    assert torch.cuda.is_available(), "Current version only supports GPU"

    #Set Bbox detector
    bbox_detector = HandBboxDetector(args.view_type, device)

    # Set Mocap regressor
    hand_mocap = HandMocap(args.checkpoint_hand, args.smpl_dir, device=device)

    # Set Visualizer
    if args.renderer_type in ['pytorch3d', 'opendr']:
        from renderer.screen_free_visualizer import Visualizer
    else:
        from renderer.visualizer import Visualizer
    visualizer = Visualizer(args.renderer_type)

    args.out_dir = os.path.join(
        "/output/annotations/",
        args.input_path.replace("/data/sessions_processed/final_dataset/",
                                "").split(".")[0], f"hand_bboxes_0.2")
    print(args.out_dir)
    assert os.path.exists(args.out_dir)

    # run
    run_hand_mocap(args, bbox_detector, hand_mocap, visualizer)
コード例 #2
0
def main():
    args = DemoOptions().parse()
    args.use_smplx = True

    device = torch.device(
        'cuda') if torch.cuda.is_available() else torch.device('cpu')
    assert torch.cuda.is_available(), "Current version only supports GPU"

    hand_bbox_detector = HandBboxDetector('third_view', device)

    #Set Mocap regressor
    body_mocap = BodyMocap(args.checkpoint_body_smplx,
                           args.smpl_dir,
                           device=device,
                           use_smplx=True)
    hand_mocap = HandMocap(args.checkpoint_hand, args.smpl_dir, device=device)

    # Set Visualizer
    if args.renderer_type in ['pytorch3d', 'opendr']:
        from renderer.screen_free_visualizer import Visualizer
    else:
        from renderer.visualizer import Visualizer
    visualizer = Visualizer(args.renderer_type)

    run_frank_mocap(args, hand_bbox_detector, body_mocap, hand_mocap,
                    visualizer)
コード例 #3
0
ファイル: client_ros.py プロジェクト: jumipark98/frankmocap_
 def __init__(self):
     self.args = DemoOptions().parse()
     self.args.use_smplx = True
     self.args.save_pred_pkl = True
     self.device = torch.device(
         'cuda') if torch.cuda.is_available() else torch.device('cpu')
     self.bbox_detector = HandBboxDetector(self.args.view_type, self.device)
     self.hand_mocap = HandMocap(self.args.checkpoint_hand,
                                 self.args.smpl_dir,
                                 device=self.device)
     self.visualizer = Visualizer(self.args.renderer_type)
コード例 #4
0
def main():
    args = DemoOptions().parse()
    args.use_smplx = True

    device = torch.device('cuda') if torch.cuda.is_available() else torch.device('cpu')
    assert torch.cuda.is_available(), "Current version only supports GPU"

    hand_bbox_detector =  HandBboxDetector('third_view', device)
    
    #Set Mocap regressor
    body_mocap = BodyMocap(args.checkpoint_body_smplx, args.smpl_dir, device = device, use_smplx= True)
    hand_mocap = HandMocap(args.checkpoint_hand, args.smpl_dir, device = device)

    run_frank_mocap(args, hand_bbox_detector, body_mocap, hand_mocap)
コード例 #5
0
def run_from_list(args):
    assert os.path.exists(args.list)

    with open(args.list, "r") as f:
        lines = f.readlines()

    args.save_frame = False
    args.no_video_out = True
    args.use_smplx = True

    device = torch.device(
        'cuda') if torch.cuda.is_available() else torch.device('cpu')
    assert torch.cuda.is_available(), "Current version only supports GPU"

    #Set Bbox detector
    bbox_detector = HandBboxDetector(args.view_type, device)

    # Set Mocap regressor
    hand_mocap = HandMocap(args.checkpoint_hand, args.smpl_dir, device=device)

    # Set Visualizer
    if args.renderer_type in ['pytorch3d', 'opendr']:
        from renderer.screen_free_visualizer import Visualizer
    else:
        from renderer.visualizer import Visualizer
    visualizer = Visualizer(args.renderer_type)

    for i in range(1, len(lines)):
        t0 = time.time()
        path = lines[i].replace("\n", "")
        session, task = (path.split(".")[0]).split("/")[-2:]
        args.input_path = path
        args.out_dir = f"/output/annotations/{session}/{task}/hand_bboxes_0.2/"

        if not args.replace and os.path.exists(
                os.path.join(args.out_dir, MARKER)):
            print(
                f"[{i}/{len(lines)-1}] Landmarks already extracted for this video -> '{args.out_dir}'"
            )
            continue

        print(
            f"[{i}/{len(lines)-1}] Extracting hand landmarks of '{session} - {task}'"
        )
        # run
        run_hand_mocap(args, bbox_detector, hand_mocap, visualizer)
        print(f"[FINISHED] Time: {time.time() - t0} s")
コード例 #6
0
ファイル: handposes.py プロジェクト: hassony2/epicviz
class HandExtractor:
    def __init__(self, hand_checkpoint, smpl_folder):
        self.hand_extractor = HandMocap(hand_checkpoint, smpl_folder)

    def hands_from_df(self, img, hoa_df, resize_factor=1):
        hand_df = hoa_df[hoa_df.det_type == "hand"]
        hand_boxes = {}

        # Keep first right and left hand found in data frame
        for hand_idx, row in hand_df.iterrows():
            box_ltrb = boxutils.dfbox_to_norm(row, resize_factor=resize_factor)
            box_ltwh = [
                box_ltrb[0],
                box_ltrb[1],
                box_ltrb[2] - box_ltrb[0],
                box_ltrb[3] - box_ltrb[1],
            ]
            box_side = row.side
            hand_key = f"{box_side}_hand"
            if hand_key not in hand_boxes:
                hand_boxes[hand_key] = np.array(box_ltwh)
        for side in ["right", "left"]:
            hand_key = f"{side}_hand"
            if hand_key not in hand_boxes:
                hand_boxes[hand_key] = None

        _, pred_hands = self.hand_extractor.regress(img, [hand_boxes],
                                                    add_margin=True)
        # Retrieve first results
        ego_hands = pred_hands[0]

        pred_hands = {}
        for side in ["right", "left"]:
            hand_key = f"{side}_hand"
            if hand_key in ego_hands and (ego_hands[hand_key] is not None):
                pred_hand = ego_hands[hand_key]
                pred_hands[side] = {
                    "verts": pred_hand["pred_vertices_img"],
                    "faces": pred_hand["faces"],
                    "hand_pose": pred_hand["pred_hand_pose"],
                }
        return pred_hands
コード例 #7
0
ファイル: handposes.py プロジェクト: hassony2/epicviz
 def __init__(self, hand_checkpoint, smpl_folder):
     self.hand_extractor = HandMocap(hand_checkpoint, smpl_folder)