Error in the with mBLIP/Bloomz

#2
by Daromog - opened

I was using this model a couple of days ago, and then suddently gives me an error in my local computer and in colab. I've seen that something was updated maybe some bugs there?

#------------------------------------------------------------------------------------------------------------------
import requests
from PIL import Image
from transformers import BlipProcessor, Blip2ForConditionalGeneration

processor = BlipProcessor.from_pretrained("Gregor/mblip-bloomz-7b")
model = Blip2ForConditionalGeneration.from_pretrained("Gregor/mblip-bloomz-7b")

img_url = 'https://storage.googleapis.com/sfr-vision-language-research/BLIP/demo.jpg'
raw_image = Image.open(requests.get(img_url, stream=True).raw).convert('RGB')

question = "Describe the image in German."
inputs = processor(raw_image, question, return_tensors="pt")

out = model.generate(**inputs)
print(processor.decode(out[0], skip_special_tokens=True))
#------------------------------------------------------------------------------------------------------------------

Error:
#------------------------------------------------------------------------------------------------------------------
warnings.warn(
preprocessor_config.json: 100%
 432/432 [00:00<00:00, 8.52kB/s]
tokenizer_config.json: 100%
 286/286 [00:00<00:00, 5.28kB/s]
tokenizer.json: 100%
 14.5M/14.5M [00:00<00:00, 43.3MB/s]
special_tokens_map.json: 100%
 96.0/96.0 [00:00<00:00, 1.27kB/s]
The tokenizer class you load from this checkpoint is not the same type as the class this function is called from. It may result in unexpected tokenization.
The tokenizer class you load from this checkpoint is 'BloomTokenizer'.
The class this function is called from is 'BertTokenizerFast'.

AttributeError Traceback (most recent call last)
in <cell line: 5>()
3 from transformers import BlipProcessor, Blip2ForConditionalGeneration
4
----> 5 processor = BlipProcessor.from_pretrained("Gregor/mblip-bloomz-7b")
6 model = Blip2ForConditionalGeneration.from_pretrained("Gregor/mblip-bloomz-7b")
7

4 frames
/usr/local/lib/python3.10/dist-packages/transformers/models/bert/tokenization_bert_fast.py in init(self, vocab_file, tokenizer_file, do_lower_case, unk_token, sep_token, pad_token, cls_token, mask_token, tokenize_chinese_chars, strip_accents, **kwargs)
101 )
102
--> 103 normalizer_state = json.loads(self.backend_tokenizer.normalizer.getstate())
104 if (
105 normalizer_state.get("lowercase", do_lower_case) != do_lower_case

AttributeError: 'NoneType' object has no attribute 'getstate'
#------------------------------------------------------------------------------------------------------------------

Owner

Can replicate. Using Blip2Processor solves the problem. All other code examples use that one so there was a mistake in the README that I fixed.

Gregor changed discussion status to closed

Sign up or log in to comment