IDEA-Research / Grounded-Segment-Anything

Grounded SAM: Marrying Grounding DINO with Segment Anything & Stable Diffusion & Recognize Anything - Automatically Detect , Segment and Generate Anything
https://arxiv.org/abs/2401.14159
Apache License 2.0
15.16k stars 1.4k forks source link

网页运行显示error,不显示图片 #155

Open cjf-repo opened 1 year ago

cjf-repo commented 1 year ago

运行的gradio_app.py选择seg的时候(其他的也一样),这里到5s左右就直接显示error,但是代码是没有报错,并且运行到了最后的return [image, mask_pil]这一步,而单独运行grounded_sam_demo.py是可以出来结果的,是我哪里需要修改吗,网页上没有显示出结果 image

Nidacoke commented 1 year ago

136

gukehan2000 commented 1 year ago

我也是 而且特别吃显存 就这个图10000多MB显存 请问知道怎么改呢

gukehan2000 commented 1 year ago

我也是 而且特别吃显存 就这个图10000多MB显存 请问知道怎么改呢

home/anaconda3/envs/github-2/lib/python3.8/site-packages/transformers/modeling_utils.py:862: FutureWarning: The device argument is deprecated and will be removed in v5 of Transformers. warnings.warn( /home/anaconda3/envs/github-2/lib/python3.8/site-packages/torch/utils/checkpoint.py:25: UserWarning: None of the inputs have requires_grad=True. Gradients will be None warnings.warn("None of the inputs have requires_grad=True. Gradients will be None") Traceback (most recent call last): File "/home/naconda3/envs/github-2/lib/python3.8/site-packages/gradio/routes.py", line 401, in run_predict output = await app.get_blocks().process_api( File "/home/anaconda3/envs/github-2/lib/python3.8/site-packages/gradio/blocks.py", line 1302, in process_api result = await self.call_function( File "/home/anaconda3/envs/github-2/lib/python3.8/site-packages/gradio/blocks.py", line 1025, in call_function prediction = await anyio.to_thread.run_sync( File "/home/anaconda3/envs/github-2/lib/python3.8/site-packages/anyio/to_thread.py", line 31, in run_sync return await get_asynclib().run_sync_in_worker_thread( File "/home/anaconda3/envs/github-2/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 937, in run_sync_in_worker_thread return await future File "/home/naconda3/envs/github-2/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 867, in run result = context.run(func, args) File "/home/MyProject/Grounded-Segment-Anything-main/gradio_app.py", line 286, in run_groundedsam masks, , _ = sam_predictor.predict_torch( File "/home/anaconda3/envs/github-2/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context return func(args, *kwargs) File "/home/MyProject/Grounded-Segment-Anything-main/segment_anything/segment_anything/predictor.py", line 229, in predict_torch low_res_masks, iou_predictions = self.model.mask_decoder( File "/home/gukehan/anaconda3/envs/github-2/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl return forward_call(input, *kwargs) File "/home/MyProject/Grounded-Segment-Anything-main/segment_anything/segment_anything/modeling/mask_decoder.py", line 94, in forward masks, iou_pred = self.predict_masks( File "/home/MyProject/Grounded-Segment-Anything-main/segment_anything/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

lijain commented 1 year ago

+1

Dratlan commented 1 year ago

+1

wanghao-cst commented 1 year ago

I got the same issue: 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

chenminupup commented 1 year ago

I got the same issue: 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

I got the same issue,can you solve it now?

piclez commented 2 months ago

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