salesforce / LAVIS

LAVIS - A One-stop Library for Language-Vision Intelligence
BSD 3-Clause "New" or "Revised" License
9.96k stars 975 forks source link

AttributeError: 'NoneType' object has no attribute '__getstate__' #201

Open fly-dragon211 opened 1 year ago

fly-dragon211 commented 1 year ago

I tried to run the code in huggingface (https://huggingface.co/Salesforce/blip2-opt-2.7b )

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

processor = BlipProcessor.from_pretrained("Salesforce/blip2-opt-2.7b")

However, I meet this error for BlipProcessor:

│ /usr/local/python/lib/python3.8/site-packages/transformers/tokenization_utils_base.py:1804 in    │
│ from_pretrained                                                                                  │
│                                                                                                  │
│   1801 │   │   │   else:                                                                         │
│   1802 │   │   │   │   logger.info(f"loading file {file_path} from cache at {resolved_vocab_fil  │
│   1803 │   │                                                                                     │
│ ❱ 1804 │   │   return cls._from_pretrained(                                                      │
│   1805 │   │   │   resolved_vocab_files,                                                         │
│   1806 │   │   │   pretrained_model_name_or_path,                                                │
│   1807 │   │   │   init_configuration,                                                           │
│                                                                                                  │
│ /usr/local/python/lib/python3.8/site-packages/transformers/tokenization_utils_base.py:1958 in    │
│ _from_pretrained                                                                                 │
│                                                                                                  │
│   1955 │   │                                                                                     │
│   1956 │   │   # Instantiate tokenizer.                                                          │
│   1957 │   │   try:                                                                              │
│ ❱ 1958 │   │   │   tokenizer = cls(*init_inputs, **init_kwargs)                                  │
│   1959 │   │   except OSError:                                                                   │
│   1960 │   │   │   raise OSError(                                                                │
│   1961 │   │   │   │   "Unable to load vocabulary from file. "                                   │
│                                                                                                  │
│ /usr/local/python/lib/python3.8/site-packages/transformers/models/bert/tokenization_bert_fast.py │
│ :235 in __init__                                                                                 │
│                                                                                                  │
│   232 │   │   │   **kwargs,                                                                      │
│   233 │   │   )                                                                                  │
│   234 │   │                                                                                      │
│ ❱ 235 │   │   normalizer_state = json.loads(self.backend_tokenizer.normalizer.__getstate__())    │
│   236 │   │   if (                                                                               │
│   237 │   │   │   normalizer_state.get("lowercase", do_lower_case) != do_lower_case              │
│   238 │   │   │   or normalizer_state.get("strip_accents", strip_accents) != strip_accents       │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: 'NoneType' object has no attribute '__getstate__'
dxli94 commented 1 year ago

This is not related to LAVIS. You are suggested to reach out to HF team.

My understanding is you may want to update your transformers version.

woominsong commented 1 year ago

The document has a typo. The processor should be Blip2Processor, not BlipProcessor.