Matching Anything by Segmenting Anything
Paper โข 2406.04221 โข Published
How to use omkar334/masa-r50 with Transformers:
# pip install -U transformers accelerate
# Load model directly
from transformers import MasaForObjectTracking
model = MasaForObjectTracking.from_pretrained("omkar334/masa-r50", device_map="auto")transformers port)
Port of MASA: Matching Anything by Segmenting Anything (CVPR 2024, arXiv:2406.04221),
the masa_r50 "plug-and-play" checkpoint that embeds given boxes (no detector inside), converted from
dereksiyuanli/masa. Original code: https://github.com/siyuanliii/masa (Apache-2.0).
The model code is in an open work-in-progress branch of transformers (issue #32164):
pip install git+https://github.com/omkar-334/transformers@add-masa
from transformers import MasaForObjectTracking, MasaImageProcessor, MasaTracker
processor = MasaImageProcessor()
model = MasaForObjectTracking.from_pretrained("omkar334/masa-r50").eval()
tracker = MasaTracker() # same settings as the official tracker config
# per frame: boxes (N, 4) in the *processed* image coordinates, scores (N,) from any detector
pixel_values = processor(images=frame_rgb, return_tensors="pt")["pixel_values"]
embeddings = model(pixel_values, boxes=[boxes]).embeddings[0]
tracks = tracker.update(boxes, scores, embeddings, frame_id=0) # dict: track_ids, boxes, scores
Parity with the official mmcv 2.1.0 / mmdet 3.3.0 model: embeddings within 4e-6, cosine >= 0.9999998.
Demo notebook (original vs. port, identical tracks on 150/150 frames): see the masa-demo branch of the repo above.
Base model
dereksiyuanli/masa