Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batched predictor inference returns inconsistently shaped masks #101

Open
geodavic opened this issue Aug 1, 2024 · 0 comments
Open

Batched predictor inference returns inconsistently shaped masks #101

geodavic opened this issue Aug 1, 2024 · 0 comments

Comments

@geodavic
Copy link

geodavic commented Aug 1, 2024

When performing batch inference using SAM2ImagePredictor, if you pass a singleton batch of points/labels, you get masks of shape (3, H,W):

>>> predictor.set_image(image)
>>> point_coords.shape # Singleton batch
(1, 2, 2)
>>> masks, _ , _ = predictor.predict(point_coords=point_coords, point_label=point_labels)
>>> masks.shape
(3, 1200,1800)

However, when your batch size is N>1 your masks become shape (N, 3, H, W). This makes it difficult to use the predictor interface where the batch size is arbitrary (and user-specified).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant