pharmapsychotic / clip-interrogator

Image to prompt with BLIP and CLIP
MIT License
2.71k stars 431 forks source link

OverflowError: out of range integral type conversion attempted #72

Open leonllzhang opened 1 year ago

leonllzhang commented 1 year ago

Hi, It is definitely a great tool! but when i run the demo script: "from PIL import Image from clip_interrogator import Config, Interrogator image = Image.open(image_path).convert('RGB') ci = Interrogator(Config(clip_model_name="ViT-L-14/openai")) print(ci.interrogate(image))"

the error appears: Loaded CLIP model and data in 11.34 seconds. /Users/leon/machinelearning/clipdemo/venv/lib/python3.9/site-packages/transformers/generation/utils.py:2256: UserWarning: MPS: no support for int64 min/max ops, casting it to int32 (Triggered internally at /Users/runner/work/pytorch/pytorch/pytorch/aten/src/ATen/native/mps/operations/ReduceOps.mm:1271.) if unfinished_sequences.max() == 0 or stopping_criteria(input_ids, scores): Traceback (most recent call last): File "/Users/leon/machinelearning/clipdemo/main.py", line 20, in imageAnnotation('images/dog389.jpg') File "/Users/leon/machinelearning/clipdemo/main.py", line 15, in imageAnnotation print(ci.interrogate(image)) File "/Users/leon/machinelearning/clipdemo/venv/lib/python3.9/site-packages/clip_interrogator/clip_interrogator.py", line 244, in interrogate caption = caption or self.generate_caption(image) File "/Users/leon/machinelearning/clipdemo/venv/lib/python3.9/site-packages/clip_interrogator/clip_interrogator.py", line 195, in generate_caption return self.caption_processor.batch_decode(tokens, skip_special_tokens=True)[0].strip() File "/Users/leon/machinelearning/clipdemo/venv/lib/python3.9/site-packages/transformers/models/blip/processing_blip.py", line 135, in batch_decode return self.tokenizer.batch_decode(*args, **kwargs) File "/Users/leon/machinelearning/clipdemo/venv/lib/python3.9/site-packages/transformers/tokenization_utils_base.py", line 3437, in batch_decode return [ File "/Users/leon/machinelearning/clipdemo/venv/lib/python3.9/site-packages/transformers/tokenization_utils_base.py", line 3438, in self.decode( File "/Users/leon/machinelearning/clipdemo/venv/lib/python3.9/site-packages/transformers/tokenization_utils_base.py", line 3476, in decode return self._decode( File "/Users/leon/machinelearning/clipdemo/venv/lib/python3.9/site-packages/transformers/tokenization_utils_fast.py", line 549, in _decode text = self._tokenizer.decode(token_ids, skip_special_tokens=skip_special_tokens) OverflowError: out of range integral type conversion attempted

environment is python 3.9. Mac OS 13.2.1 (22D68). with PyCharm 2022.3.3 (Community Edition)

It is very appreciate if anyone can help. thx a lot!