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

[Feature] Support auto import modules from registry. #2481

Merged
merged 16 commits into from Feb 23, 2023

Conversation

xiexinch
Copy link
Collaborator

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

@codecov
Copy link

codecov bot commented Jan 30, 2023

Codecov Report

Base: 83.25% // Head: 83.37% // Increases project coverage by +0.11% 🎉

Coverage data is based on head (d1e682b) compared to base (7ac0888).
Patch coverage: 95.65% of modified lines in pull request are covered.

❗ Current head d1e682b differs from pull request most recent head f95494d. Consider uploading reports for the commit f95494d to get more accurate results

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     
Flag Coverage Δ
unittests 83.37% <95.65%> (+0.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
mmseg/apis/inference.py 0.00% <0.00%> (ø)
mmseg/__init__.py 92.10% <100.00%> (ø)
mmseg/datasets/__init__.py 100.00% <100.00%> (ø)
mmseg/datasets/basesegdataset.py 100.00% <100.00%> (ø)
mmseg/datasets/refuge.py 100.00% <100.00%> (ø)
mmseg/datasets/transforms/formatting.py 89.74% <100.00%> (+0.85%) ⬆️
mmseg/datasets/transforms/loading.py 85.15% <100.00%> (+3.90%) ⬆️
mmseg/engine/hooks/visualization_hook.py 97.05% <100.00%> (ø)
mmseg/registry/__init__.py 100.00% <100.00%> (ø)
mmseg/registry/registry.py 100.00% <100.00%> (ø)
... and 3 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.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Collaborator

@MeowZheng MeowZheng left a 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

@@ -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'])
Copy link
Collaborator

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?

Comment on lines -34 to -40
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()
Copy link
Collaborator

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

Comment on lines 35 to 40
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)
Copy link
Collaborator

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

@@ -24,7 +24,7 @@ def main():
'--title', default='result', help='The image identifier.')
args = parser.parse_args()

register_all_modules()
init_default_scope('mmseg')
Copy link
Collaborator

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

"from mmseg.utils import register_all_modules\n",
"register_all_modules()"
"\n",
"init_default_scope('mmseg')"
Copy link
Collaborator

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/zh_cn/advanced_guides/datasets.md Show resolved Hide resolved
from mmseg.apis import init_model
from mmseg.utils import register_all_modules

init_default_scope('mmseg')
Copy link
Collaborator

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

@MeowZheng MeowZheng merged commit 039ba5d into open-mmlab:dev-1.x Feb 23, 2023
aravind-h-v pushed a commit to aravind-h-v/mmsegmentation that referenced this pull request Mar 27, 2023
* Fix tensorboard tracking with `accelerate` @ `main`

* Fix `train_unconditional.py` with accelerate from main.
nahidnazifi87 pushed a commit to nahidnazifi87/mmsegmentation_playground that referenced this pull request Apr 5, 2024
## 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
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.

None yet

3 participants