Title: TensorFlow/Keras Version Conflict While Fine-Tuning TrOCR Model

Hello, I am working on fine-tuning a TrOCR model using the Hugging Face transformers library and I encountered a version conflict issue after installing tf-keras to solve a Keras incompatibility problem.
I’m trying to fine-tune a TrOCR model with the following code:
However, I am getting the following error:

RuntimeError: Failed to import transformers.trainer_seq2seq because of the following error (look up to see its traceback):
Failed to import transformers.integrations.integration_utils because of the following error (look up to see its traceback):
Failed to import transformers.modeling_tf_utils because of the following error (look up to see its traceback):
Your currently installed version of Keras is Keras 3, but this is not yet supported in Transformers. Please install the backwards-compatible tf-keras package with `pip install tf-keras`.

After installing tf-keras, I ran into further conflicts with TensorFlow and Keras versions. Here are some of the errors I encountered while resolving the dependencies:

tensorflow-intel 2.18.0 requires ml-dtypes<0.5.0,>=0.4.0, but you have ml-dtypes 0.5.1 which is incompatible.

tensorflow-intel 2.18.0 requires tensorboard<2.19,>=2.18, but you have tensorboard 2.19.0 which is incompatible.

tensorflow 2.19.0 requires ml-dtypes<1.0.0,>=0.5.1, but you have ml-dtypes 0.4.0 which is incompatible.

current Environment:
python 3.12.7

TensorFlow: 2.19.0

Transformers: 4.48.3

numpy: 1.26.4

Hello,

That’s sometimes the point with Python package version handling…

The package builder of tensorflow-intel had limited the foreign packages version. Maybe it was not yet tested it with those packages new version. Maybe the maintainer has left the cause.

However, I remember falling into the same situations. The trick I did is to change the package manifest to allow those new versions and tried to reapply the install process.

Unfortunatly, I did not remember how I did but a look up on the Internet might provide you with a how-to.