ValueError: mask must be a 3D np.ndarray with shape (1, H, W), but got shape (1, 1, 1024, 768) when using prompt "shirt" in Grounded SAM 2
Closed this issue · 3 comments
sahal-786 commented
When using Grounded SAM 2 to process an image with the prompt "shirt," I encountered a ValueError. The error indicates that the mask must be a 3D np.ndarray with shape (1, H, W), but the provided mask has shape (1, 1, 1024, 768).
ValueError: mask must be a 3D np.ndarray with shape (1, H, W), but got shape (1, 1, 1024, 768)
prompt = "shirt."
rentainhe commented
We've encountered the same issue, we will fix it as soon as possible
rentainhe commented
@sahal-786 We've already fixed this bug with the following changes:
change the following code
if masks.ndim == 3:
masks = masks[None]
scores = scores[None]
logits = logits[None]
if masks.ndim == 4:
masks = masks.squeeze(1)
to:
if masks.ndim == 4:
masks = masks.squeeze(1)
rentainhe commented
I will close this issue because the bug has already been fixed, feel free to reopen it if you need any other helps.