Skip to content

Dedicated WandbLogger for MMDetection#7413

Closed
ayulockin wants to merge 14 commits intoopen-mmlab:masterfrom
ayulockin:wandb
Closed

Dedicated WandbLogger for MMDetection#7413
ayulockin wants to merge 14 commits intoopen-mmlab:masterfrom
ayulockin:wandb

Conversation

@ayulockin
Copy link
Copy Markdown
Contributor

As per the discussion in this issue #7391, I have opened this PR to introduce a dedicated WandbLogger for MMDetection.

Motivation

The goal and motivation for this PR are mentioned in detail in this #7391 issue.

Modification

The PR adds a new file wandblogger_hook.py where all the Weights and Biases related logic lives. The features that are introduced are explained in detail in my initial issue.

Other than this file, there is a small modification to the eval_hook.py file. It was made so that the WandbLogger can access the evaluation results.

I am really looking forward to all the feedback. I would love to answer questions if any. If you require a colab to test out the feature, I can provide that as well. However, using it is straightforward as shown in the code snippet below.

log_config = dict(
            interval=10,
            hooks=[
                dict(type='WandbLogger',
                     wandb_init_kwargs={
                         'entity': WANDB_ENTITY,
                         'project': WANDB_PROJECT_NAME
                     },
                     logging_interval=10,
                     log_checkpoint=True,
                     log_checkpoint_metadata=True,
                     num_eval_images=100)
            ])

Checklist

  • Pre-commit or other linting tools are used to fix the potential lint issues.
  • The modification is covered by complete unit tests. If not, please add more unit test to ensure the correctness.
  • If the modification has potential influence on downstream projects, this PR should be tested with downstream projects, like MMDet or MMCls.
  • The documentation has been modified accordingly, like docstring or example tutorials.

@mm-assistant mm-assistant bot added the size/XS label Mar 15, 2022
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


ayulockin seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@jbwang1997 jbwang1997 self-requested a review March 16, 2022 01:02
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 16, 2022

Codecov Report

Merging #7413 (7bbb876) into master (01b55b2) will decrease coverage by 0.33%.
The diff coverage is 15.81%.

❗ Current head 7bbb876 differs from pull request most recent head 532b860. Consider uploading reports for the commit 532b860 to get more accurate results

@@            Coverage Diff             @@
##           master    #7413      +/-   ##
==========================================
- Coverage   63.45%   63.12%   -0.34%     
==========================================
  Files         340      341       +1     
  Lines       27493    27687     +194     
  Branches     4645     4688      +43     
==========================================
+ Hits        17446    17477      +31     
- Misses       9119     9284     +165     
+ Partials      928      926       -2     
Flag Coverage Δ
unittests 63.09% <15.81%> (-0.34%) ⬇️

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

Impacted Files Coverage Δ
mmdet/core/hook/wandblogger_hook.py 14.50% <14.50%> (ø)
mmdet/core/evaluation/eval_hooks.py 81.81% <100.00%> (ø)
mmdet/core/hook/__init__.py 100.00% <100.00%> (ø)
mmdet/core/bbox/assigners/max_iou_assigner.py 73.68% <0.00%> (+1.31%) ⬆️
mmdet/utils/misc.py 100.00% <0.00%> (+4.76%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2733aa9...532b860. Read the comment docs.

@jbwang1997
Copy link
Copy Markdown
Collaborator

Hellow @ayulockin. Thank you for your contributions. I have left some comments above.

@ZwwWayne
Copy link
Copy Markdown
Collaborator

Hi @ayulockin ,
Could you sign the CLA so that we can merge this PR?
image

@ayulockin
Copy link
Copy Markdown
Contributor Author

Hi @ayulockin ,
Could you sign the CLA so that we can merge this PR?
image

Hey @ZwwWayne, even though I am signing the CLA it's not showing up here. Do you have any clue as to why this is the case?


@master_only
def after_run(self, runner):
self.wandb.finish()
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you can see I have overwritten the after_run method of mmcv.WandbLoggerHook. Do you want me to use super() instead?

The current mmcv.WandbLoggerHook logs the files with output_prefix as artifacts, however, this dedicated logger makes use of the artifacts better. If you think, it's best to not override, I will revert the change.

@ayulockin
Copy link
Copy Markdown
Contributor Author

Hey @jbwang1997 @ZwwWayne, I am not able to sign the CLA probably because, the email id that was configured with git for few of the initial commits is not linked to my GitHub account (there might be a typo).

If it's not an issue, can I make a new PR from a new branch so that I can sign the CLA. Ideally, would love to get the review process done and then we can close this PR and I can open a new PR for merger.

Apologies for inconvenience.

@jbwang1997
Copy link
Copy Markdown
Collaborator

Hey @jbwang1997 @ZwwWayne, I am not able to sign the CLA probably because, the email id that was configured with git for few of the initial commits is not linked to my GitHub account (there might be a typo).

If it's not an issue, can I make a new PR from a new branch so that I can sign the CLA. Ideally, would love to get the review process done and then we can close this PR and I can open a new PR for merger.

Apologies for inconvenience.

You are welcome to open a new pr. This is awesome work and we can continue to discuss this function in the new pr.

@hhaAndroid
Copy link
Copy Markdown
Member

@ayulockin Very meaningful work!Thank you very much for your contribution.

Comment on lines +101 to +107
super(WandbLogger, self).before_run(runner)
self.cfg = self.wandb.config
# Check if configuration is passed to wandb.
if len(dict(self.cfg)) == 0:
warnings.warn(
'To log mmdetection Config, '
'pass it to init_kwargs of WandbLogger.', UserWarning)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The config in mmdetection is too huge for users to be added by init_kwargs. Is it possible to add config from the file?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By adding config from file, do you mean log something like this - here's an example command line:

python tools/train.py configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py

Do you want to log the config from configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py? It's doable in my opinion.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought, here's another solution for logging config easily, however it will require a PR in the MMCV repo.

@jbwang1997
Copy link
Copy Markdown
Collaborator

@ayulockin Thank you so much for your awesome contributions again. I am now running some samples with this function. After running, I will give you more detailed feedback on this function. I left some small comments above. You can fix them and open a new pr.

@ayulockin
Copy link
Copy Markdown
Contributor Author

Closing this PR in favor of #7459.

@ayulockin ayulockin closed this Mar 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants