# ```python # import torch # from sam2.build_sam import build_sam2_video_predictor # checkpoint = "./checkpoints/sam2.1_hiera_large.pt" # model_cfg = "configs/sam2.1/sam2.1_hiera_l.yaml" # predictor = build_sam2_video_predictor(model_cfg, checkpoint) # with torch.inference_mode(), torch.autocast("cuda", dtype=torch.bfloat16): # state = predictor.init_state() # # add new prompts and instantly get the output on the same frame # frame_idx, object_ids, masks = predictor.add_new_points_or_box(state, ): # # propagate the prompts to get masklets throughout the video # for frame_idx, object_ids, masks in predictor.propagate_in_video(state): # ... # ```