KeyError:'dinov2

#1
by FrancescoDL - opened

Hi everyone,

i am trying to run the code in the file README but i get the following error:

KeyError Traceback (most recent call last)
c: *** Cell 1 in ()
7 image = Image.open(requests.get(url, stream=True).raw)
9 processor = AutoImageProcessor.from_pretrained('facebook/dinov2-base')
---> 10 model = AutoModel.from_pretrained('facebook/dinov2-base')
12 inputs = processor(images=image, return_tensors="pt")
13 outputs = model(**inputs)

File ***AppData\Local\Programs\Python\Python39\lib\site-packages\transformers\models\auto\auto_factory.py:461, in _BaseAutoModelClass.from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
458 if kwargs.get("torch_dtype", None) == "auto":
459 _ = kwargs.pop("torch_dtype")
--> 461 config, kwargs = AutoConfig.from_pretrained(
462 pretrained_model_name_or_path,
463 return_unused_kwargs=True,
464 trust_remote_code=trust_remote_code,
465 **hub_kwargs,
466 **kwargs,
467 )
469 # if torch_dtype=auto was passed here, ensure to pass it on
470 if kwargs_orig.get("torch_dtype", None) == "auto":

File***\AppData\Local\Programs\Python\Python39\lib\site-packages\transformers\models\auto\configuration_auto.py:998, in AutoConfig.from_pretrained(cls, pretrained_model_name_or_path, **kwargs)
996 return config_class.from_pretrained(pretrained_model_name_or_path, **kwargs)
997 elif "model_type" in config_dict:
...
--> 710 raise KeyError(key)
711 value = self._mapping[key]
712 module_name = model_type_to_module_name(key)

KeyError: 'dinov2'

I can't figure out whats wrong.

Can anyone help me?

Hi,

You'll need to install Transformers from the main branch for now:

pip install -q git+https://github.com/huggingface/transformers.git

the model will be included in the next PyPi release.

I also met this problem. I think this may be due to a version problem.

Sign up or log in to comment