Grounded-Segment-Anything icon indicating copy to clipboard operation
Grounded-Segment-Anything copied to clipboard

SAM predictor Error

Open lxianl455 opened this issue 2 years ago • 4 comments

When I try to get a mask, I got an error: Traceback (most recent call last): File "grounded_sam_demo.py", line 206, in masks, _, _ = predictor.predict_torch( File "/data0/lxl/environment/anaconda3_22_5_11/envs/try_segment/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context return func(*args, **kwargs) File "/data1/lxl/Grounded-Segment-Anything/segment_anything/segment_anything/predictor.py", line 229, in predict_torch low_res_masks, iou_predictions = self.model.mask_decoder( File "/data0/lxl/environment/anaconda3_22_5_11/envs/try_segment/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl return forward_call(*input, **kwargs) File "/data1/lxl/Grounded-Segment-Anything/segment_anything/segment_anything/modeling/mask_decoder.py", line 94, in forward masks, iou_pred = self.predict_masks( File "/data1/lxl/Grounded-Segment-Anything/segment_anything/segment_anything/modeling/mask_decoder.py", line 147, in predict_masks masks = (hyper_in @ upscaled_embedding.view(b, c, h * w)).view(b, -1, h, w) RuntimeError: cannot reshape tensor of 0 elements into shape [0, -1, 256, 256] because the unspecified dimension size -1 can be any value and is ambiguous

lxianl455 avatar Apr 11 '23 13:04 lxianl455

same error. any solutions?

styfeng avatar May 16 '23 02:05 styfeng

boxes_filt is empty:

# run grounding dino model
boxes_filt, pred_phrases = get_grounding_output(
    model, image, text_prompt, box_threshold, text_threshold, device=device
)

wufeim avatar Jun 15 '23 23:06 wufeim

https://github.com/IDEA-Research/Grounded-Segment-Anything/issues/100#issuecomment-1506519629

piclez avatar Sep 02 '24 07:09 piclez

In my case, using --device cuda:5 always returns empty boxes_filt. I export CUDA_VISIBLE_DEVICES=5 and then use --device cuda, and issue solved.

chengyh23 avatar Mar 01 '25 03:03 chengyh23