facebookresearch / facebookresearch/sam2

Batched predictor inference returns inconsistently shaped masks

Open
#101 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
19.9k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

When performing batch inference using `SAM2ImagePredictor`, if you pass a singleton batch of points/labels, you get masks of shape (3, H,W):
```python
>>> 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).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.