OSError: Can't load tokenizer for 'CompVis/stable-diffusion-safety-checker'

#43
by Wok - opened
from transformers import AutoProcessor

processor = AutoProcessor.from_pretrained("CompVis/stable-diffusion-safety-checker")
OSError                                   Traceback (most recent call last)

<ipython-input-21-ef63f91e2754> in <cell line: 3>()
      1 from transformers import AutoProcessor
      2 
----> 3 processor = AutoProcessor.from_pretrained("CompVis/stable-diffusion-safety-checker")

/usr/local/lib/python3.10/dist-packages/transformers/models/auto/processing_auto.py in from_pretrained(cls, pretrained_model_name_or_path, **kwargs)
    295         # Last try: we use the PROCESSOR_MAPPING.
    296         elif type(config) in PROCESSOR_MAPPING:
--> 297             return PROCESSOR_MAPPING[type(config)].from_pretrained(pretrained_model_name_or_path, **kwargs)
    298 
    299         # At this stage, there doesn't seem to be a `Processor` class available for this model, so let's try a

/usr/local/lib/python3.10/dist-packages/transformers/processing_utils.py in from_pretrained(cls, pretrained_model_name_or_path, cache_dir, force_download, local_files_only, token, revision, **kwargs)
    226             kwargs["token"] = token
    227 
--> 228         args = cls._get_arguments_from_pretrained(pretrained_model_name_or_path, **kwargs)
    229         return cls(*args)
    230 

/usr/local/lib/python3.10/dist-packages/transformers/processing_utils.py in _get_arguments_from_pretrained(cls, pretrained_model_name_or_path, **kwargs)
    270                 attribute_class = getattr(transformers_module, class_name)
    271 
--> 272             args.append(attribute_class.from_pretrained(pretrained_model_name_or_path, **kwargs))
    273         return args
    274 

/usr/local/lib/python3.10/dist-packages/transformers/tokenization_utils_base.py in from_pretrained(cls, pretrained_model_name_or_path, cache_dir, force_download, local_files_only, token, revision, *init_inputs, **kwargs)
   2006 
   2007         if all(full_file_name is None for full_file_name in resolved_vocab_files.values()):
-> 2008             raise EnvironmentError(
   2009                 f"Can't load tokenizer for '{pretrained_model_name_or_path}'. If you were trying to load it from "
   2010                 "'https://huggingface.co/models', make sure you don't have a local directory with the same name. "

OSError: Can't load tokenizer for 'CompVis/stable-diffusion-safety-checker'. If you were trying to load it from 'https://huggingface.co/models', make sure you don't have a local directory with the same name. Otherwise, make sure 'CompVis/stable-diffusion-safety-checker' is the correct path to a directory containing all relevant files for a CLIPTokenizerFast tokenizer.

I have used a workaround with another import. See https://huggingface.co/CompVis/stable-diffusion-safety-checker/discussions/44

Fixed with the following piece of code.

from transformers import AutoFeatureExtractor

processor = AutoFeatureExtractor.from_pretrained("CompVis/stable-diffusion-safety-checker")

Sign up or log in to comment