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

Dummy forward #953

Merged
merged 1 commit into from
Aug 8, 2022
Merged

Dummy forward #953

merged 1 commit into from
Aug 8, 2022

Conversation

twmht
Copy link
Contributor

@twmht twmht commented Aug 4, 2022

We should add forward_dummy to query flops by mmcv (https://github.com/open-mmlab/mmcv/blob/master/mmcv/cnn/utils/flops_counter.py#L38). Althugh we already have extract_feat, but it's not sync with mmdetection(https://github.com/open-mmlab/mmdetection/blob/master/mmdet/models/detectors/single_stage.py#L48).

we should sync both projects since many people may want to put both together into a single project.

@codecov
Copy link

codecov bot commented Aug 4, 2022

Codecov Report

Merging #953 (d0850b0) into master (71ef7ba) will increase coverage by 0.86%.
The diff coverage is 100.00%.

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

@@            Coverage Diff             @@
##           master     #953      +/-   ##
==========================================
+ Coverage   84.57%   85.43%   +0.86%     
==========================================
  Files         134      134              
  Lines        8772     8777       +5     
  Branches     1516     1516              
==========================================
+ Hits         7419     7499      +80     
+ Misses       1117     1056      -61     
+ Partials      236      222      -14     
Flag Coverage Δ
unittests 85.35% <100.00%> (+0.78%) ⬆️

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

Impacted Files Coverage Δ
mmcls/models/classifiers/image.py 92.00% <100.00%> (+0.69%) ⬆️
mmcls/core/visualization/image.py 87.17% <0.00%> (+0.97%) ⬆️
mmcls/datasets/builder.py 87.83% <0.00%> (+9.45%) ⬆️
mmcls/models/backbones/convmixer.py 98.36% <0.00%> (+9.83%) ⬆️
mmcls/datasets/custom.py 100.00% <0.00%> (+11.47%) ⬆️
mmcls/models/utils/helpers.py 100.00% <0.00%> (+20.83%) ⬆️
mmcls/utils/device.py 100.00% <0.00%> (+27.27%) ⬆️
mmcls/utils/setup_env.py 100.00% <0.00%> (+27.27%) ⬆️
mmcls/models/backbones/convnext.py 94.78% <0.00%> (+34.78%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@mzr1996 mzr1996 self-requested a review August 5, 2022 07:28
@twmht
Copy link
Contributor Author

twmht commented Aug 5, 2022

@mzr1996

can you help me to check CI jobs?

See `mmclassificaiton/tools/analysis_tools/get_flops.py`
"""
x = self.extract_feat(img)
outs = self.head.simple_test(x, post_process=False)
Copy link
Member

Choose a reason for hiding this comment

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

Should the forward_dummy includes head.simple_test?
For the classification tasks, we may use different datasets to do pre-training. If the forward_dummy includes head.simple_test, the flops value of the same model trained on ImageNet-1k and ImageNet-21k will be different. It's a little confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good.

@mzr1996
Copy link
Member

mzr1996 commented Aug 8, 2022

The unit tests need to be fixed.

@twmht
Copy link
Contributor Author

twmht commented Aug 8, 2022

The unit tests need to be fixed.

sure.

@mzr1996 mzr1996 merged commit 90254a8 into open-mmlab:master Aug 8, 2022
mzr1996 pushed a commit that referenced this pull request Aug 22, 2022
* [Improve] Use `forward_dummy` to calculate FLOPS. (#953)

* fixed

Co-authored-by: Ming-Hsuan-Tu <alec.tu@acer.com>
Ezra-Yu pushed a commit to Ezra-Yu/mmclassification that referenced this pull request Sep 6, 2022
Ezra-Yu pushed a commit to Ezra-Yu/mmclassification that referenced this pull request Sep 6, 2022
* [Improve] Use `forward_dummy` to calculate FLOPS. (open-mmlab#953)

* fixed

Co-authored-by: Ming-Hsuan-Tu <alec.tu@acer.com>
mzr1996 added a commit that referenced this pull request Dec 30, 2022
* unit test for multi_task_head

* [Feature] MultiTaskHead (#628, #481)

* [Fix] lint for multi_task_head

* [Feature] Add `MultiTaskDataset` to support multi-task training.

* Update MultiTaskClsHead

* Update docs

* [CI] Add test mim CI. (#879)

* [Fix] Remove duplicated wide-resnet metafile.

* [Feature] Support MPS device. (#894)

* [Feature] Support MPS device.

* Add `auto_select_device`

* Add unit tests

* [Fix] Fix Albu crash bug. (#918)

* Fix albu BUG: using albu will cause the label from array(x) to array([x]) and crash the trainning

* Fix common

* Using copy incase potential bug in multi-label tasks

* Improve coding

* Improve code logic

* Add unit test

* Fix typo

* Fix yapf

* Bump version to 0.23.2. (#937)

* [Improve] Use `forward_dummy` to calculate FLOPS. (#953)

* Update README

* [Docs] Fix typo for wrong reference. (#1036)

* [Doc] Fix typo in tutorial 2 (#1043)

* [Docs] Fix a typo in ImageClassifier (#1050)

* add mask to loss

* add another pipeline

* adpat the pipeline if there is no mask

* switch mask and task

* first version of multi data smaple

* fix problem with attribut by getattr

* rm img_label suffix, fix 'LabelData' object has no attribute 'gt_label'

* training  without evaluation

* first version work

* add others metrics

* delete evaluation from dataset

* fix linter

* fix linter

* multi metrics

* first version of test

* change evaluate metric

* Update tests/test_models/test_heads.py

Co-authored-by: Colle <piercus@users.noreply.github.com>

* Update tests/test_models/test_heads.py

Co-authored-by: Colle <piercus@users.noreply.github.com>

* add tests

* add test for multidatasample

* create a generic test

* create a generic test

* create a generic test

* change multi data sample

* correct test

* test

* add new test

* add test for dataset

* correct test

* correct test

* correct test

* correct test

* fix : #5

* run yapf

* fix linter

* fix linter

* fix linter

* fix isort

* fix isort

* fix docformmater

* fix docformmater

* fix linter

* fix linter

* fix data sample

* Update mmcls/structures/multi_task_data_sample.py

Co-authored-by: Colle <piercus@users.noreply.github.com>

* Update mmcls/structures/multi_task_data_sample.py

Co-authored-by: Colle <piercus@users.noreply.github.com>

* Update mmcls/structures/multi_task_data_sample.py

Co-authored-by: Colle <piercus@users.noreply.github.com>

* Update mmcls/structures/multi_task_data_sample.py

Co-authored-by: Colle <piercus@users.noreply.github.com>

* Update mmcls/structures/multi_task_data_sample.py

Co-authored-by: Colle <piercus@users.noreply.github.com>

* Update mmcls/structures/multi_task_data_sample.py

Co-authored-by: Colle <piercus@users.noreply.github.com>

* Update tests/test_structures/test_datasample.py

Co-authored-by: Colle <piercus@users.noreply.github.com>

* Update mmcls/structures/multi_task_data_sample.py

Co-authored-by: Colle <piercus@users.noreply.github.com>

* Update tests/test_structures/test_datasample.py

Co-authored-by: Colle <piercus@users.noreply.github.com>

* Update tests/test_structures/test_datasample.py

Co-authored-by: Colle <piercus@users.noreply.github.com>

* update data sample

* update head

* update head

* update multi data sample

* fix linter

* fix linter

* fix linter

* fix linter

* fix linter

* fix linter

* update head

* fix problem we don't  set pred or  gt

* fix problem we don't  set pred or  gt

* fix problem we don't  set pred or  gt

* fix linter

* fix : #2

* fix : linter

* update multi head

* fix linter

* fix linter

* update data sample

* update data sample

* fix ; linter

* update test

* test pipeline

* update pipeline

* update test

* update dataset

* update dataset

* fix linter

* fix linter

* update formatting

* add test for multi-task-eval

* update formatting

* fix linter

* update test

* update

* add test

* update metrics

* update metrics

* add doc for functions

* fix linter

* training for multitask 1.x

* fix linter

* run flake8

* run linter

* update test

* add mask in evaluation

* update metric doc

* update metric doc

* Update mmcls/evaluation/metrics/multi_task.py

Co-authored-by: Colle <piercus@users.noreply.github.com>

* Update mmcls/evaluation/metrics/multi_task.py

Co-authored-by: Colle <piercus@users.noreply.github.com>

* Update mmcls/evaluation/metrics/multi_task.py

Co-authored-by: Colle <piercus@users.noreply.github.com>

* Update mmcls/evaluation/metrics/multi_task.py

Co-authored-by: Colle <piercus@users.noreply.github.com>

* Update mmcls/evaluation/metrics/multi_task.py

Co-authored-by: Colle <piercus@users.noreply.github.com>

* Update mmcls/evaluation/metrics/multi_task.py

Co-authored-by: Colle <piercus@users.noreply.github.com>

* update metric doc

* update metric doc

* Fix cannot import name MultiTaskDataSample

* fix test_datasets

* fix test_datasets

* fix linter

* add an example of multitask

* change name of configs dataset

* Refactor the multi-task support

* correct test and metric

* add test to multidatasample

* add test to multidatasample

* correct test

* correct metrics and clshead

* Update mmcls/models/heads/cls_head.py

Co-authored-by: Colle <piercus@users.noreply.github.com>

* update cls_head.py documentation

* lint

* lint

* fix: lint

* fix linter

* add eval mask

* fix documentation

* fix: single_label.py back to 1.x

* Update mmcls/models/heads/multi_task_head.py

Co-authored-by: Ma Zerun <mzr1996@163.com>

* Remove multi-task configs.

Co-authored-by: mzr1996 <mzr1996@163.com>
Co-authored-by: HinGwenWoong <peterhuang0323@qq.com>
Co-authored-by: Ming-Hsuan-Tu <alec.tu@acer.com>
Co-authored-by: Lei Lei <18294546+Crescent-Saturn@users.noreply.github.com>
Co-authored-by: WRH <12756472+wangruohui@users.noreply.github.com>
Co-authored-by: marouaneamz <maroineamil99@gmail.com>
Co-authored-by: marouane amzil <53240092+marouaneamz@users.noreply.github.com>
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.

2 participants