Error loading model

#2
by Kenhuangsy - opened

Can someone help me please? I am running into an error when I run this coded:

from transformers import AutoImageProcessor, Dinov2ForImageClassification
image_processor = AutoImageProcessor.from_pretrained("facebook/dinov2-base-patch16-224")
model = Dinov2ForImageClassification.from_pretrained("facebook/dinov2-base-patch16-224", id2label=id2label, num_labels=len(id2label))

The error says:

ImportError Traceback (most recent call last)
Cell In[22], line 1
----> 1 from transformers import AutoImageProcessor, Dinov2ForImageClassification
2 image_processor = AutoImageProcessor.from_pretrained("facebook/dinov2-base-patch16-224")
3 model = Dinov2ForImageClassification.from_pretrained("facebook/dinov2-base-patch16-224", id2label=id2label, num_labels=len(id2label))

ImportError: cannot import name 'Dinov2ForImageClassification' from 'transformers' (/opt/conda/lib/python3.10/site-packages/transformers/init.py)

Hey @nielsr , I have tried that the first time, but it didn't work.

Sign up or log in to comment