-
Notifications
You must be signed in to change notification settings - Fork 364
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
[CodeCamp2023-327]Control whether methods of the Visualizer are executed only in the main process through a parameter #1353
base: main
Are you sure you want to change the base?
Conversation
…ted only in the main process through a parameter
…ted only in the main process through a parameter update test_visualizer.py
Coupling the implementation of class Visualizer
def __init__(self, ..., master_only=True):
...
self.master_only = master_only
def xxx(self, ...):
if _should_do():
...
def _should_do(self):
if self.master_only and get_rank() != 0:
return False
else:
return True |
Thank you for your response. I initially thought that I could only add 'master_only' without modifying the decorator. And I'll make the necessary adjustments as soon as possible. |
mmengine/visualization/visualizer.py
Outdated
def dataset_meta(self, dataset_meta: dict) -> None: | ||
"""Set the dataset meta info to the Visualizer.""" | ||
self._dataset_meta = dataset_meta | ||
if self._should_do(): |
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 need to reconsider that if it is necessary to apply self._should_do
here. I think we could skip this check here.
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.
For this, I added the check based on the original master_only decorator for this function. For dataset_meta, it might be better to keep the original master_only decorator.
Hi, please check the modification will not break the CI |
Co-authored-by: Mashiro <[email protected]>
fix dataset_meta
f63fb45
to
7d4c046
Compare
Motivation
Control whether methods of the Visualizer are executed only in the main process through a parameter.. See more details in #1081
Modification
To implement this function, we add a parameter 'img_only_master' to
visualizer
by all kinds ofvis_backend
. During runtime, it is determined whether to retain only the images in the GPU by checking if img_only_master is passed and examining its corresponding value. The modifiedmaster_only
decorator is as following:When we build the runner, we can follow this way to pass the
img_only_master
:When we use the
add_img
method, we need pass theimg_only_master
throughimg_only_master=runner.visualizer.img_only_master
Checklist