I wrote very small code :
from transformers import pipeline
model_id = âcardiffnlp/twitter-roberta-base-sentiment-latestâ
sentiment_pipe = pipeline(âsentiment-analysisâ, model=model_id)
print(sentiment_pipe(âWe hope you dont hate itâ)) ERROR - RuntimeError: Failed to import transformers.models.roberta.modeling_tf_roberta because of the following error (look up to see its traceback):
No module named âkeras.engineâ
I tried to install tensorflow == 2.10 but its not present
Issue here:
File ~\AppData\Local\anaconda3\Lib\site-packages\transformers\modeling_tf_utils.py:69
68 from keras import backend as K
â> 69 from keras.engine import data_adapter
70 from keras.engine.keras_tensor import KerasTensor
ModuleNotFoundError: No module named âkeras.engineâ
Solutions: change the line 69 and 70 to âfrom tensorflow.python.keras.engine import data_adapterâ and âfrom tensorflow.python.keras.engine.keras_tensor import KerasTensorâ
I think you have a problem importing the keras.engine module. Try installing tensorflow version 2.10 if you canât find it. Also make sure that you have all the dependencies and environment configured correctly to work with the transformers library.
Thanks, I solve it modifying an internal transformer library file that was importing de tensorflow/keras model in a different Way.
Still I continue with the doubt because as you can see there is a parameter for the framework filled with pytorch and also All the Notebook whatâs working with pytorch even the other Transformers models from hugging face are working also in pytorch so why is this One trying to import or using this module in tensorflow?