-
Notifications
You must be signed in to change notification settings - Fork 3k
Fix AttributeError in Eagle image processor for transformers 4.53+ #2358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix AttributeError in Eagle image processor for transformers 4.53+ #2358
Conversation
- Add runtime detection for _prepare_input_images vs _prepare_image_like_inputs - Fixes AttributeError: 'Eagle25VLImageProcessorFast' object has no attribute '_prepare_image_like_inputs' - Maintains backward compatibility with different transformers versions - Tested with transformers 4.53.3 and GR00T-N1.5 training
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds backward compatibility handling for the transformers library API changes in the Eagle25VLImageProcessorFast class. The code now dynamically checks which image preprocessing method is available (_prepare_image_like_inputs for transformers >= 4.53.0 or _prepare_input_images for older versions) and uses the appropriate one.
Key Changes
- Added runtime detection logic to check for available preprocessing methods using
hasattr() - Replaced direct calls to
_prepare_image_like_inputswith the dynamically selectedprepare_fn - Added error handling when neither method is available
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # transformers >= 4.53.0: uses _prepare_image_like_inputs instead of _prepare_input_images | ||
| # Check which method is available for compatibility | ||
| if hasattr(self, '_prepare_image_like_inputs'): | ||
| prepare_fn = self._prepare_image_like_inputs | ||
| elif hasattr(self, '_prepare_input_images'): | ||
| prepare_fn = self._prepare_input_images | ||
| else: | ||
| raise AttributeError("Neither _prepare_image_like_inputs nor _prepare_input_images method found") | ||
|
|
Copilot
AI
Nov 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The backward compatibility check for _prepare_input_images appears unnecessary since pyproject.toml specifies transformers>=4.53.0,<5.0.0 which only supports _prepare_image_like_inputs. Consider removing the fallback logic or updating the version constraint if older transformers versions need to be supported.
| # transformers >= 4.53.0: uses _prepare_image_like_inputs instead of _prepare_input_images | |
| # Check which method is available for compatibility | |
| if hasattr(self, '_prepare_image_like_inputs'): | |
| prepare_fn = self._prepare_image_like_inputs | |
| elif hasattr(self, '_prepare_input_images'): | |
| prepare_fn = self._prepare_input_images | |
| else: | |
| raise AttributeError("Neither _prepare_image_like_inputs nor _prepare_input_images method found") | |
| # transformers >= 4.53.0: uses _prepare_image_like_inputs | |
| prepare_fn = self._prepare_image_like_inputs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
transformers >= 4.54.0 uses _prepare_image_like_inputs, while transformers <= 4.53.3 uses _prepare_input_images. This compatibility check prevents the AttributeError: 'Eagle25VLImageProcessorFast' object has no attribute '_prepare_image_like_inputs' when using transformers 4.53.x.
What this does
Fixes a (🐛 Bug) that prevents GR00T model training with transformers == 4.53.x
The Eagle image processor in
image_processing_eagle2_5_vl_fast.pycalls_prepare_image_like_inputs()which doesn't exist in theBaseImageProcessorFastparent class in transformers 4.53.x , causing training to fail immediately with:Changes:
_prepare_input_imagesvs_prepare_image_like_inputshasattr()to check which method is available in the parent classHow it was tested
How to checkout & try? (for the reviewer)