Spaces:
Runtime error
Runtime error
File size: 711 Bytes
013216e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# ```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(<your_video>)
# # add new prompts and instantly get the output on the same frame
# frame_idx, object_ids, masks = predictor.add_new_points_or_box(state, <your_prompts>):
# # propagate the prompts to get masklets throughout the video
# for frame_idx, object_ids, masks in predictor.propagate_in_video(state):
# ...
# ```
|