Skip to content
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

Fix AutoProcessor import order issue with custom classes #35798

Closed
wants to merge 1 commit into from

Conversation

Rocketknight1
Copy link
Member

Fixes #34307

When initializing via AutoImageProcessor before AutoProcessor is imported, an AttributeError could occur if the model used custom processor classes. This happened because the code tried to import the processor class from the root transformers module, which failed for custom classes.

This PR modifies the _get_arguments_from_pretrained method to look for custom classes in the config object if they are not found in the root module. This allows models to define their own processor classes without having to modify the transformers module itself.

Added a test case to verify the fix works as expected.

When initializing via AutoImageProcessor before AutoProcessor is imported,
an AttributeError could occur if the model used custom processor classes.
This fix allows custom classes to be loaded from the config object.
@Rocketknight1
Copy link
Member Author

This is another test of using OpenHands to resolve issues, this time on a more complex one where the solution wasn't clearly laid out in the issue. The PR and comment above were written by the bot. I haven't reviewed it yet!

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.

Initializing via AutoImageProcessor before AutoProcessor is imported causes AttributeError
2 participants