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

[Refactor] Use post_process function to handle pred result processing. #390

Merged
merged 1 commit into from
Aug 12, 2021

Conversation

mzr1996
Copy link
Member

@mzr1996 mzr1996 commented Aug 4, 2021

Motivation

In most heads, we need to do some post-processing after getting the pred result. However, downstream tasks, like deploy, may want to override this post-processing function.

Modification

Convert the post-processing in the simple_test function to a standalone method. And all child classes can reuse the method.

BC-breaking (Optional)

No.

Checklist

Before PR:

  • Pre-commit or other linting tools are used to fix the potential lint issues.
  • Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests.
  • The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness.
  • The documentation has been modified accordingly, like docstring or example tutorials.

After PR:

  • If the modification has potential influence on downstream or other related projects, this PR should be tested with those projects, like MMDet or MMSeg.
  • CLA has been signed and all committers have signed the CLA in this PR.

@codecov
Copy link

codecov bot commented Aug 4, 2021

Codecov Report

Merging #390 (fe1441b) into master (df5cec3) will increase coverage by 0.05%.
The diff coverage is 62.50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #390      +/-   ##
==========================================
+ Coverage   76.51%   76.56%   +0.05%     
==========================================
  Files          97       97              
  Lines        5224     5206      -18     
  Branches      856      852       -4     
==========================================
- Hits         3997     3986      -11     
+ Misses       1108     1101       -7     
  Partials      119      119              
Flag Coverage Δ
unittests 76.56% <62.50%> (+0.05%) ⬆️

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

Impacted Files Coverage Δ
mmcls/models/heads/multi_label_linear_head.py 70.83% <0.00%> (+7.50%) ⬆️
mmcls/models/heads/cls_head.py 81.81% <50.00%> (+10.38%) ⬆️
mmcls/models/heads/multi_label_head.py 64.70% <50.00%> (-0.92%) ⬇️
mmcls/models/heads/linear_head.py 82.60% <100.00%> (-3.60%) ⬇️
mmcls/models/heads/stacked_head.py 96.92% <100.00%> (-0.18%) ⬇️
mmcls/models/heads/vision_transformer_head.py 91.89% <100.00%> (-1.14%) ⬇️

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 df5cec3...fe1441b. Read the comment docs.

@grimoire
Copy link
Member

grimoire commented Aug 4, 2021

Did ClsHead and MultiLabelClsHead share same post_process?
Can we put it in BaseHead?

@mzr1996
Copy link
Member Author

mzr1996 commented Aug 4, 2021

Did ClsHead and MultiLabelClsHead share same post_process?
Can we put it in BaseHead?

Yes, share the same post_process.
Considering BaseHead is an abstract class, I don't confirm if putting post_process in BaseHead is a good practice. It even doesn't have the simple_test method.

Copy link
Member

@grimoire grimoire left a comment

Choose a reason for hiding this comment

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

Sure, LGTM!

@mzr1996 mzr1996 requested a review from Ezra-Yu August 5, 2021 09:11
Copy link
Collaborator

@Ezra-Yu Ezra-Yu left a comment

Choose a reason for hiding this comment

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

LGTM

@mzr1996 mzr1996 merged commit f8f1700 into open-mmlab:master Aug 12, 2021
mzr1996 added a commit to mzr1996/mmpretrain that referenced this pull request Nov 24, 2022
open-mmlab#390)

Use post_process function to handle pred result processing in `simple_test`.
@mzr1996 mzr1996 deleted the postprocess branch December 7, 2022 02:07
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.

3 participants