facebookresearch / facebookresearch/sam2

Artefacts when segmenting an image using bbox xyxy

Open
#600 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

I've been stuck of figuring out the reason of why this is happening.

I'm segmenting by passing the SAM a xyxy format bbox.
bbox: [tensor(689.), tensor(29.), tensor(3728.), tensor(2915.)]

Can anyone confirm the artifacts by running the segmentation ?

What could have done wrong and is there any way to fix it ?

How I get the mask

```
mask_predictor = SAM2ImagePredictor(sam_model)
mask_predictor.set_image(im_rgb)
masks, scores, logits = mask_predictor.predict(
box=xyxy,
multimask_output=True,
)
```

Input image

![Image](https://github.com/user-attachments/assets/81bc8af8-2864-4651-96b8-9e4ea99266cf)

Segmentation mask resulting from input image of dtype uint8

![Image](https://github.com/user-attachments/assets/4289754e-c7d3-486e-88f1-bab264385bbf)

Segmentation mask resulting from input image of dtype float32

Even if it does not male much sense i tried passing the image with dtype=np.float32

![Image](https://github.com/user-attachments/assets/20767f4c-1a73-4690-9d69-80232c8ee11c)

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.