Errors with latest transformers

#2
by userx1 - opened

I have updated transformers package to the latest version and your finetuned version does not work anymore. It is still one of the best of Florence2 around at the moment in my experience.

Here's the log:

2025-06-26 21:13:28.840661: I tensorflow/core/util/port.cc:153] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable TF_ENABLE_ONEDNN_OPTS=0.
AttributeError: 'MessageFactory' object has no attribute 'GetPrototype'
AttributeError: 'MessageFactory' object has no attribute 'GetPrototype'
AttributeError: 'MessageFactory' object has no attribute 'GetPrototype'
2025-06-26 21:13:29.989981: I tensorflow/core/util/port.cc:153] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable TF_ENABLE_ONEDNN_OPTS=0.
AttributeError: 'MessageFactory' object has no attribute 'GetPrototype'
AttributeError: 'MessageFactory' object has no attribute 'GetPrototype'
...\AppData\Local\Programs\Python\Python312\Lib\site-packages\timm\models\layers_init_.py:48: FutureWarning: Importing from timm.models.layers is deprecated, please import via timm.layers
warnings.warn(f"Importing from {name} is deprecated, please import via timm.layers", FutureWarning)
Florence2LanguageForConditionalGeneration has generative capabilities, as prepare_inputs_for_generation is explicitly defined. >However, it doesn't directly inherit from GenerationMixin. From πŸ‘‰v4.50πŸ‘ˆ onwards, PreTrainedModel will NOT inherit from GenerationMixin, and this model will lose the ability to call generate and other related functions.

  • If you're using trust_remote_code=True, you can get rid of this warning by loading the model with an auto class. See https://huggingface.co/docs/transformers/en/model_doc/auto#auto-classes
  • If you are the owner of the model architecture code, please modify your model class such that it inherits from GenerationMixin (after PreTrainedModel, otherwise you'll get an exception).
  • If you are not the owner of the model architecture class, please contact the model code owner to update it.
    :515: SyntaxWarning: invalid escape sequence '\d'

When processing an image for caption generation:

Error during model processing batch: 'Florence2LanguageForConditionalGeneration' object has no attribute 'generate'
Error for ....jpg: 'Florence2LanguageForConditionalGeneration' object has no attribute 'generate'

The only option right now is to use an older Transformers package..

wow, okay ty.

I see hf staff have sent code to fix this issue to the main repo https://huggingface.co/microsoft/Florence-2-large-ft/discussions/38/files

Will implement shortly

Sign up or log in to comment