open_clip icon indicating copy to clipboard operation
open_clip copied to clipboard

RuntimeError: Boolean value of Tensor with more than one value is ambiguous

Open wujohns opened this issue 3 months ago • 8 comments

The coca model demo not work and the wrong code is here:

# open_clip/coca_model.py 
...
if beam_scorer.is_done or stopping_criteria(input_ids, None):
  break
...

the beam_scorer.is_done is like: ensor(False, device='cuda:0') the stopping_criteria(input_ids, None) is like: tensor([False, False, False, False, False, False], device='cuda:0')

the beam_scorer.is_done or stopping_criteria(input_ids, None) is like tensor([False, False, False, False, False, False], device='cuda:0') but when you run if tensor([False, False, False, False, False, False], device='cuda:0') it will case RuntimeError: Boolean value of Tensor with more than one value is ambiguous

wujohns avatar Mar 27 '24 04:03 wujohns

I had the same issue and I tried a different generation_type to be able to generate captions for now

Aristotelis1 avatar Mar 28 '24 18:03 Aristotelis1

@Aristotelis1 suggestion's works generation_type=

ialhashim avatar Apr 03 '24 14:04 ialhashim

Hi, has there been a fix that includes beam_search? having the same issue but as mentioned, changing generation_type does work.

colton138 avatar Apr 08 '24 23:04 colton138

I had the same issue and I tried a different generation_type to be able to generate captions for now

bro,what exactly is your operational process?

OrderJade avatar Apr 09 '24 10:04 OrderJade

I had the same issue and I tried a different generation_type to be able to generate captions for now

bro,what exactly is your operational process?

The Coca model demo in the repo that's in a colab

colton138 avatar Apr 09 '24 17:04 colton138

There is a solution in #860, hope it helps. : )

MengqingCao avatar Apr 12 '24 07:04 MengqingCao

There is a resolution in #860, hope it helps. : )

Thank you!

colton138 avatar Apr 12 '24 16:04 colton138

If you can't wait for #860 to be merged, you can roll back to the transformers==4.38.2 which is the last version before the change.

This is the commit that broke this, and it was introduced in 4.39.0

eware-godaddy avatar Apr 18 '24 09:04 eware-godaddy