Skip to content

Conversation

@Rayen023
Copy link
Contributor

@Rayen023 Rayen023 commented Nov 2, 2025

What this does

Fixes a (🐛 Bug) that prevents GR00T model training with transformers >= 4.53.0

The Eagle image processor in image_processing_eagle2_5_vl_fast.py calls _prepare_image_like_inputs() which doesn't exist in the BaseImageProcessorFast parent class in transformers 4.53+, causing training to fail immediately with:

AttributeError: 'Eagle25VLImageProcessorFast' object has no attribute '_prepare_image_like_inputs'

Changes:

  • Add runtime detection for _prepare_input_images vs _prepare_image_like_inputs
  • Use hasattr() to check which method is available in the parent class
  • Maintains backward/forward compatibility with different transformers versions

How it was tested

  • ✅ Tested with transformers 4.53.3
  • ✅ GR00T-N1.5-3B training completes training successfully (previously failed immediately)

How to checkout & try? (for the reviewer)

lerobot-train \
  --policy.type="groot" \
  --policy.base_model_path="nvidia/GR00T-N1.5-3B" \
  --dataset.repo_id="repo_id" \

- 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
Copilot AI review requested due to automatic review settings November 2, 2025 03:06
Copy link
Contributor

Copilot AI left a 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_inputs with the dynamically selected prepare_fn
  • Added error handling when neither method is available

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 444 to +452
# 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")

Copy link

Copilot AI Nov 2, 2025

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.

Suggested change
# 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

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant