Fix missing generate method by inheriting from GenerationMixin

#2
No description provided.
Sematre changed pull request title from inherit-generation-mixin to Fix missing generate method by inheriting from GenerationMixin
Sematre changed pull request title from Fix missing generate method by inheriting from GenerationMixin to Fix missing `generate` method by inheriting from GenerationMixin
Sematre changed pull request title from Fix missing `generate` method by inheriting from GenerationMixin to Fix missing generate method by inheriting from GenerationMixin

This PR resolves the AttributeError: 'Florence2LanguageForConditionalGeneration' object has no attribute 'generate' error by adding GenerationMixin to the class inheritance.

Changes:

  • Added from transformers.generation.utils import GenerationMixin import
  • Updated Florence2LanguageForConditionalGeneration to inherit from both Florence2LanguagePreTrainedModel and GenerationMixin

This change addresses the deprecation warning in transformers v4.50+ where PreTrainedModel no longer inherits from GenerationMixin by default.

Source: Cherry-picked from Microsoft's official Florence-2-base repository: microsoft/Florence-2-base@2a2d45e

Sematre changed pull request status to open

Hi, were you able to get this running properly? I've been unable to get OCR working on macOS (Apple Silicon). Thank you for any advice

I was able to get it running in a Colab notebook. Feel free to take a look: https://colab.research.google.com/drive/1qJWddZQwktmFgTZHi9SrVzCT0EWCgEan?usp=sharing

Ready to merge
This branch is ready to get merged automatically.

Sign up or log in to comment