-
Notifications
You must be signed in to change notification settings - Fork 28.2k
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
Initializing via AutoImageProcessor before AutoProcessor is imported causes AttributeError
#34307
Comments
Seems like a bug indeed, thanks for the great report! cc @Rocketknight1, can you take a look at this? |
Confirmed the bug, and thanks for the clean reproduction script! I suspect this is an issue with how we construct the autoclass mappings, I'm working on it now. |
Awesome, thank you both! 🙂 |
After investigation, the issue seems to be here. Manually setting an attribute of the |
Final diagnosis:
cc @zucchini-nlp - can you see an obvious fix to that method that would work for custom classes? I can take this if you're overloaded! |
Hey @Rocketknight1, thanks for investigating this. The quickest worrkaround I see is to change this line in Microsoft repo to be an But I agree that we need a better solution here than forcing folks on the hub to use |
Yeah, that's a really good point! Let me investigate this when I get a chance, maybe I can come up with a (semi-) clean solution. |
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread. Please note that issues that do not follow the contributing guidelines are likely to be ignored. |
Any update on this? |
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread. Please note that issues that do not follow the contributing guidelines are likely to be ignored. |
Bump |
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread. Please note that issues that do not follow the contributing guidelines are likely to be ignored. |
Adding WIP, I think this needs a fix so users who upload models to the hub can get everything working smoothly. @Rocketknight1 , am I right that this is on you? |
Yes, this does need a fix and I just haven't gotten to it yet! |
The PR at #36184 should resolve the underlying issue, but we might need to update the custom Phi code to stop applying the workaround in order to fully resolve this! |
System Info
transformers
version: 4.45.2Who can help?
Probably @zucchini-nlp @amyeroberts, and @qubvel
Information
Tasks
examples
folder (such as GLUE/SQuAD, ...)Reproduction
There seems to be an edge-case in the loading behavior that can sometimes be hit if something is initialized with
from_pretrained
throughAutoImageProcessor
beforeAutoProcessor
is imported, and thenfrom_pretrained
is used onAutoProcessor
.Repro case - this works as expected
But this breaks:
with
AttributeError: module transformers has no attribute Phi3VImageProcessor
.I've tried to reproduce this with a few other models, but haven't been able to yet. It is also probably worth noting that the
AutoProcessor
doesn't return the same class asAutoImageProcessor
for this model, which might matterExpected behavior
AutoImageProcessor
/AutoProcessor
from_pretrained
should have the same behavior if possible, regardless of import and invocation orderThe text was updated successfully, but these errors were encountered: