[CodeCamp2023-327]Control whether methods of the Visualizer are executed only in the main process through a parameter #1350
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 these functions, I add a parameter
img_only_master
tovisualizer
throughvis_backend
. And I modified these files :mmengine/dist/utils.py
mmengine/visualization/vis_backend.py
mmengine/visualization/visualizer.py
During runtime, it is determined whether to retain only the images in the main GPU by checking if img_only_master is passed and examining its corresponding value. The following are modified
master_only
functions:When we build the runner, we can use this method to pass in
img_only_master
.When we use
add_image
in the training process, we also need to pass the extra parameter:img_only_master=runner.visualizer.img_only_master
Checklist