-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
[Feature] Support auto import modules from registry. #2481
Conversation
Codecov ReportBase: 83.25% // Head: 83.37% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## dev-1.x #2481 +/- ##
===========================================
+ Coverage 83.25% 83.37% +0.11%
===========================================
Files 145 146 +1
Lines 8505 8522 +17
Branches 1273 1275 +2
===========================================
+ Hits 7081 7105 +24
+ Misses 1213 1202 -11
- Partials 211 215 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
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.
please modify minimum version of mmengine v0.4.0
mmseg/registry/registry.py
Outdated
@@ -32,52 +32,90 @@ | |||
from mmengine.registry import Registry | |||
|
|||
# manage all kinds of runners like `EpochBasedRunner` and `IterBasedRunner` | |||
RUNNERS = Registry('runner', parent=MMENGINE_RUNNERS) | |||
RUNNERS = Registry( | |||
'runner', parent=MMENGINE_RUNNERS, locations=['mmseg.engine.runner']) |
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.
there is no mmseg.engine.runner in mmseg?
from mmseg.utils import register_all_modules | ||
|
||
config_path = 'configs/pspnet/pspnet_r50-d8_4xb2-40k_cityscapes-512x1024.py' | ||
checkpoint_path = 'checkpoints/pspnet_r50-d8_512x1024_40k_cityscapes_20200605_003338-2966598c.pth' | ||
|
||
# register all modules in mmseg into the registries | ||
register_all_modules() |
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.
I think without register_all_modules
it needs to add init_default_scope
mmseg/registry/registry.py
Outdated
RUNNERS = Registry('runner', parent=MMENGINE_RUNNERS) | ||
# manage runner constructors that define how to initialize runners | ||
RUNNER_CONSTRUCTORS = Registry( | ||
'runner constructor', parent=MMENGINE_RUNNER_CONSTRUCTORS) | ||
# manage all kinds of loops like `EpochBasedTrainLoop` | ||
LOOPS = Registry('loop', parent=MMENGINE_LOOPS) |
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 should keep these registries in mmseg
demo/image_demo.py
Outdated
@@ -24,7 +24,7 @@ def main(): | |||
'--title', default='result', help='The image identifier.') | |||
args = parser.parse_args() | |||
|
|||
register_all_modules() | |||
init_default_scope('mmseg') |
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.
init_model have add init_default_scope('mmseg')
, so there is no need to add it
demo/inference_demo.ipynb
Outdated
"from mmseg.utils import register_all_modules\n", | ||
"register_all_modules()" | ||
"\n", | ||
"init_default_scope('mmseg')" |
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.
same problem as above
docs/en/user_guides/3_inference.md
Outdated
from mmseg.apis import init_model | ||
from mmseg.utils import register_all_modules | ||
|
||
init_default_scope('mmseg') |
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.
I think init_default_scope
can be removed
* Fix tensorboard tracking with `accelerate` @ `main` * Fix `train_unconditional.py` with accelerate from main.
## Motivation The registry now supports auto-import modules from the given location. register_all_modules before running is no longer needed. The modules will be lazy-imported during building. - [x] This PR can be merged after open-mmlab/mmengine#643. The MMEngine version should be updated. Ref: open-mmlab/mmdetection#9143
Motivation
The registry now supports auto-import modules from the given location.
register_all_modules before running is no longer needed. The modules will be lazy-imported during building.
Ref: open-mmlab/mmdetection#9143