Beispiel #1
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)
Beispiel #2
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)
Beispiel #3
0
 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)
Beispiel #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)
Beispiel #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")
        if not os.path.exists(args.out_dir):
            os.makedirs(args.out_dir)
        elif not args.replace and os.path.exists(os.path.join(args.out_dir, f"finished.marker")):
            print(f"[{i}/{len(lines)-1}] Already processed video -> '{args.out_dir}'")
            continue

        print(f"[{i}/{len(lines)-1}] Processing video '{args.input_path}' -> '{args.out_dir}'")
        run_hand_mocap(args, bbox_detector)
        print(f"[FINISHED] Time: {time.time() - t0} s")

   
if __name__ == '__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"

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

    if args.list:
        run_from_list(args, bbox_detector)
    else:
        root = "/data/sessions_processed/final_dataset/"
        args.out_dir = os.path.join(args.out_dir, args.input_path.replace(root, "").split(".")[0], f"hand_bboxes_{args.th_hands}")
        if not os.path.exists(args.out_dir):
            os.makedirs(args.out_dir)
        run_hand_mocap(args, bbox_detector)