Instructions to use Chenyi007/Matting-Anything-2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sam2
How to use Chenyi007/Matting-Anything-2 with sam2:
# Use SAM2 with images import torch from sam2.sam2_image_predictor import SAM2ImagePredictor predictor = SAM2ImagePredictor.from_pretrained("Chenyi007/Matting-Anything-2") with torch.inference_mode(), torch.autocast("cuda", dtype=torch.bfloat16): predictor.set_image(<your_image>) masks, _, _ = predictor.predict(<input_prompts>)# Use SAM2 with videos import torch from sam2.sam2_video_predictor import SAM2VideoPredictor predictor = SAM2VideoPredictor.from_pretrained("Chenyi007/Matting-Anything-2") 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(state, <your_prompts>) # propagate the prompts to get masklets throughout the video for frame_idx, object_ids, masks in predictor.propagate_in_video(state): ... - Notebooks
- Google Colab
- Kaggle
Download weights.json from Chenyi007/Matting-Anything-2: direct link, hf CLI and curl.
- Browser
- Download file 560 Bytes
-
https://huggingface.co/Chenyi007/Matting-Anything-2/resolve/main/weights.json
- Command line
-
hf download hf://Chenyi007/Matting-Anything-2/weights.json
-
curl -L -o weights.json https://huggingface.co/Chenyi007/Matting-Anything-2/resolve/main/weights.json
560 Bytes
| { | |
| "mam2_main.pt": { | |
| "filename": "mam2_main.pt", | |
| "sha256": "65e3c27060febae474af1662d3f3f038f024de17715595ca61045efb357603b2", | |
| "bytes": 1035483060, | |
| "tensors": 1136, | |
| "description": "Original experimental checkpoint_100.pt; Hiera Large, PDD, MSS and LoRA" | |
| }, | |
| "mam2_matter.pth": { | |
| "filename": "mam2_matter.pth", | |
| "sha256": "538cf871933dd0663a6bc28a4bec9b870cc2de909c7431b857b72ce427e82a09", | |
| "bytes": 116874309, | |
| "tensors": 318, | |
| "description": "MEMatte refinement checkpoint used with the original main checkpoint" | |
| } | |
| } | |