After pip3 install
ing tensorflow
and the transformers
library, I'm receiving the titular error when I try loading this
from transformers import pipeline
classifier = pipeline("text-classification",model='bhadresh-savani/distilbert-base-uncased-emotion')
The error traceback looks like:
RuntimeError: Failed to import transformers.models.distilbert.modeling_tf_distilbert because of the following error (look up to see its traceback):
No module named 'keras.saving.hdf5_format'
I have ensured keras got installed with transformers, so I'm not sure why it isn't working
If you are using the latest version of TensorFlow and Keras then you have to try this code and you have got this error as shown below
RuntimeError: Failed to import transformers.models.distilbert.modeling_tf_distilbert because of the following error (look up to see its traceback):
No module named 'keras.saving.hdf5_format'
Now, expand this error traces as I have shown below
Now click on the 14 frames and select as shown below Now comment this line as shown in the picture below
Now, try this and your error will gone.
The problem is that this is in the older version of keras and you are using the latest version of keras. So, you can skip all these steps and go back to the older version and it will work eventually.