OCR-SAM icon indicating copy to clipboard operation
OCR-SAM copied to clipboard

cannot reshape tensor of 0 elements into shape [0, -1, 256, 256] because the unspecified dimension size

Open Boom199801 opened this issue 1 year ago • 1 comments

File "mmocr_sam_erase.py", line 269, in masks, _, _ = sam_predictor.predict_torch( File "/opt/conda/envs/ocr-sam/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context return func(*args, **kwargs) File "/opt/conda/envs/ocr-sam/lib/python3.8/site-packages/segment_anything/predictor.py", line 229, in predict_torch low_res_masks, iou_predictions = self.model.mask_decoder( File "/opt/conda/envs/ocr-sam/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl return forward_call(*input, **kwargs) File "/opt/conda/envs/ocr-sam/lib/python3.8/site-packages/segment_anything/modeling/mask_decoder.py", line 94, in forward masks, iou_pred = self.predict_masks( File "/opt/conda/envs/ocr-sam/lib/python3.8/site-packages/segment_anything/modeling/mask_decoder.py", line 144, 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

Boom199801 avatar Nov 29 '24 01:11 Boom199801

I also encountered this problem, have you solved it?

GrayChan813 avatar Dec 16 '24 04:12 GrayChan813