-
Notifications
You must be signed in to change notification settings - Fork 363
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] fix infer.py _init_collate incompatibility problem #1360
base: main
Are you sure you want to change the base?
Conversation
collate_fn_cfg = cfg.test_dataloader.collate_fn | ||
if isinstance(collate_fn_cfg, dict): | ||
collate_fn_type = collate_fn_cfg.pop('type') | ||
if isinstance(collate_fn_type, str): | ||
collate_fn = registry.get(collate_fn_type) | ||
else: | ||
collate_fn = collate_fn_type | ||
from functools import partial | ||
collate_fn = partial(collate_fn, | ||
**collate_fn_cfg) # type: ignore | ||
elif callable(collate_fn_cfg): | ||
collate_fn = collate_fn_cfg | ||
else: | ||
raise TypeError( | ||
'collate_fn should be a dict or callable object, ' | ||
f'but got {collate_fn_cfg}') |
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.
We can move the changes here to build_collate_fn, and at the same time, the logic in build_dataloader can replace with this function.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1360 +/- ##
=======================================
Coverage ? 70.38%
=======================================
Files ? 153
Lines ? 14219
Branches ? 2956
=======================================
Hits ? 10008
Misses ? 3748
Partials ? 463
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Thanks for your contribution and we appreciate it a lot. The following instructions would make your pull request more healthy and more easily get feedback. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers.
Motivation
I customized a collated_fn, use cfg collated_fn = dict(type='xxx', *args) before.
but when i update mmengine, my program will raise an error about "The key argument of
Registry.get
must be a str"Modification
Please briefly describe what modification is made in this PR.
BC-breaking (Optional)
Does the modification introduce changes that break the backward-compatibility of the downstream repos?
If so, please describe how it breaks the compatibility and how the downstream projects should modify their code to keep compatibility with this PR.
Use cases (Optional)
If this PR introduces a new feature, it is better to list some use cases here, and update the documentation.
Checklist