ImportError: cannot import name 'auto_class_factory'
See original GitHub issueI installed layoutlmft from https://github.com/microsoft/unilm/tree/master/layoutlmft and it import auto_class_factory in the source code of init.py:
from transformers.models.auto.modeling_auto import auto_class_factory
.....xxx...
AutoModelForTokenClassification = auto_class_factory(
"AutoModelForTokenClassification", MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING, head_doc="token classification"
)
AutoModelForRelationExtraction = auto_class_factory(
"AutoModelForRelationExtraction", MODEL_FOR_RELATION_EXTRACTION_MAPPING, head_doc="relation extraction"
)
After I upgraded the transformers from v4.5.1 to v4.10.0.
And when I run the code as follow:
from transformers.models.auto.modeling_auto import auto_class_factory
I got the error below:
ImportError: cannot import name 'auto_class_factory' from 'transformers.models.auto.modeling_auto'
(xxxxx/envs/huggingface/lib/python3.7/site-packages/transformers/models/auto/modeling_auto.py)
I couldn’t find auto_class_factory in the source code and documents in v4.10.0. How can I fixed this problem? Thanks.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
How to Fix ImportError: Cannot Import Name in Python - Rollbar
The Python ImportError: cannot import name error occurs when an imported class is not accessible or is in a circular dependency.
Read more >What can I do about "ImportError: Cannot import name X" or ...
I'm assume the error is due to importing entity twice - once in main.py and later in physics.py - but how can I...
Read more >How to Fix : “ImportError: Cannot import name X” in Python?
You can solve the “ ImportError : Cannot import name X” Error by resolving the circular dependencies. You can do that either by...
Read more >How do I fix the ImportError: cannot import name 'delayed'?
I am using the LORAS package from pyloras for imbalanced learning, but it requires importing the delayed package. I used the pip.main() to ......
Read more >How to Fix : “ImportError: Cannot import name X” in Python
In Python "ImportError: cannot import name" error generally occurs when the imported class is not accessible, or the imported class is in a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
@sz-lcw, This code is still broken in version 4.12.5 so here is the fix that sgugger meant. You will need to change the code to be this: (Thanks to @alromb for doing most of the work and of course sgugger.)