facebookresearch / facebookresearch/sam2

only get the background by predictor

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

Description

In my image, there's a mobile, but when I use 'predictor.predict_torch', I only get a mask with background but no mobile.
below is the codes:
`

> sam = sam_model_registry["vit_l"](checkpoint="../../models/segment-anything/sam_vit_l_0b3195.pth")
> device="cpu"
> sam.to(device=device)
> predictor = SamPredictor(sam)
> predictor.set_image(image)
> boxes_filt=torch.Tensor([[7.5935, 14.0314, 589.9314, 372.0146]])
> transformed_boxes = predictor.transform.apply_boxes_torch(boxes_filt, image.shape[:2]).to(device)
> masks, _, _ = predictor.predict_torch(
> point_coords = None,
> point_labels = None,
> boxes = transformed_boxes.to(device),
> multimask_output = False,
> )

`
but I get the blow mask:

> Original Image
![10078](https://github.com/user-attachments/assets/e9834df9-f6da-4d59-8a25-dcbcf1f3f697)

> Image with Mask(**_only the background is masked_**)
![grounded_sam_output_2](https://github.com/user-attachments/assets/efced21c-6458-467e-bcdb-5e2997c5d067)

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.