Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Feature] Support TSM-MobileNetV2 #415

Merged
merged 26 commits into from
Feb 3, 2021

Conversation

irvingzhang0512
Copy link
Contributor

@irvingzhang0512 irvingzhang0512 commented Dec 3, 2020

TODO list

  • mobilenetv2 backbone & unittest.
  • tsm-mobilenetv2 backbone & unittest.
  • covnert checkpoint from origin repo.
    • original repo: 30 test crops, 19520 samples, top1/5 accuracy is 69.54%/88.66%
    • mmaction2 convertion: 10 test crops, 18219 samples, top1/5 accuracy is 69.04%/88.23%.
  • Refactor mobilenet with mmcls
  • changelog
  • training with mmaction2 & update model zoo.
    • I don't have enough gpus to train on kinetics400, maybe next week i can have a try...
    • 贫穷的泪水

training results of mobilenet-tsm with DenseSampleFrames1x1x8. (origin ckpt get 69.54%/88.66% top1/5 accuracy).

lr epochs gpus weight decay top1/5 acuracy
0.00875 50 7 0.0001 63.75%/85.52%
0.0025 50 4 0.0001 65.11%/85.99%
0.0025 100 4 0.0001 66.xx%/86.xx%
0.004 100 4 0.00004 68.31%/88.00%
0.0075 100 6 0.00004 68.41%/88.07%

@dreamerlin
Copy link
Collaborator

What a contribution ! We can help to train some config settings to share your gpu pressure : )

@codecov
Copy link

codecov bot commented Dec 3, 2020

Codecov Report

Merging #415 (68b72ba) into master (02d5d9b) will increase coverage by 0.20%.
The diff coverage is 97.12%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #415      +/-   ##
==========================================
+ Coverage   84.10%   84.31%   +0.20%     
==========================================
  Files         122      124       +2     
  Lines        8633     8771     +138     
  Branches     1435     1467      +32     
==========================================
+ Hits         7261     7395     +134     
- Misses       1018     1019       +1     
- Partials      354      357       +3     
Flag Coverage Δ
unittests 84.30% <97.12%> (+0.20%) ⬆️

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

Impacted Files Coverage Δ
mmaction/models/backbones/mobilenet_v2_tsm.py 94.44% <94.44%> (ø)
mmaction/models/backbones/mobilenet_v2.py 97.45% <97.45%> (ø)
mmaction/models/__init__.py 100.00% <100.00%> (ø)
mmaction/models/backbones/__init__.py 100.00% <100.00%> (ø)

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 02d5d9b...fd05748. Read the comment docs.

@irvingzhang0512
Copy link
Contributor Author

What a contribution ! We can help to train some config settings to share your gpu pressure : )

The original repo doesn't provide training configs for tsm-mobilenetv2, so the training configs are copied from mmaction2-tsm-resnet50. Not sure if it is ok.

@irvingzhang0512 irvingzhang0512 mentioned this pull request Dec 3, 2020
15 tasks
@irvingzhang0512
Copy link
Contributor Author

irvingzhang0512 commented Dec 7, 2020

trained mobilenet-tsm with DenseSampleFrames1x1x8/0.00875lr/7 gpus/50epochs, get top1/5 acuracy 63.75%/85.52%, far bellow origin ckpt 69.54%/88.66%.
May have a try in 2 weeks, a little busy these days.

mmaction/models/backbones/mobilenetv2.py Outdated Show resolved Hide resolved
mmaction/models/backbones/mobilenetv2.py Outdated Show resolved Hide resolved
mmaction/models/backbones/mobilenetv2.py Outdated Show resolved Hide resolved
@irvingzhang0512
Copy link
Contributor Author

@kennymckormick next week I will refactor mobilenet with mmclassification

@kennymckormick
Copy link
Member

@kennymckormick next week I will refactor mobilenet with mmclassification

Great! It would be the best case if we can directly use mmcls's mobilenet.

@irvingzhang0512
Copy link
Contributor Author

trained mobilenet-tsm with DenseSampleFrames1x1x8/0.0025lr/4 gpus/50epochs, get top1/5 acuracy 65.11%/85.99%, far bellow origin ckpt 69.54%/88.66%(100 epochs). The best ckpt is from the 50th epoch, I guess more epochs would help.

@dreamerlin Maybe when I finish refactor mobilenetv2 with mmcls, you could kindly help to train this model with 8 gpus and 100 epochs, and upload the ckpt/json/log

@irvingzhang0512
Copy link
Contributor Author

@dreamerlin ready to train and review.

Successfully convert origin ckpt to mmcls_mobilenetv2_tsm, get 69.5% top 1 val accuracy.

@irvingzhang0512
Copy link
Contributor Author

irvingzhang0512 commented Dec 26, 2020

trained mobilenet-tsm with DenseSampleFrames1x1x8/0.004lr/4 gpus/100epochs/0.00004 weight decay, get top1/5 acuracy 68.31%/88.00%, much better than before, not far away from origin ckpt 69.54%/88.66%(100 epochs).

Maybe the remaining 1% gap is caused by the lack of training samples(There are only 220k videos in my kinetics-400 dataset training set)

@dreamerlin
Copy link
Collaborator

trained mobilenet-tsm with DenseSampleFrames1x1x8/0.004lr/4 gpus/100epochs/0.00004 weight decay, get top1/5 acuracy 68.31%/88.00%, much better than before, not far away from origin ckpt 69.54%/88.66%(100 epochs).

Maybe the remaining 1% gap is caused by the lack of training samples(There are only 220k videos in my kinetics-400 dataset training set)

Sorry for my late respond due to personal affair. trained mobilenet-tsm with DenseSampleFrames1x1x8/0.01lr/8 gpus/100epochs/0.00004 weight decay, get top1/5 acuracy 68.33%/88.34%. Any suggestion ? @innerlee @irvingzhang0512

docs/changelog.md Outdated Show resolved Hide resolved
@dreamerlin
Copy link
Collaborator

@dreamerlin Have you trained TSM w. MobileNetv2 with the original repo on our datasets, maybe this number can be used for reference.

Yeah, I can help to train it :P

@dreamerlin
Copy link
Collaborator

@dreamerlin Have you trained TSM w. MobileNetv2 with the original repo on our datasets, maybe this number can be used for reference.

Yeah, I can help to train it :P

top1: 68.46, using 3 crop and full size (256)

@irvingzhang0512
Copy link
Contributor Author

Don't know what to do. Maybe we should follow @kennymckormick 's suggestion, train tsm-mobilenetv2 with the original repo.

I'm a little busy these days, may have a try after spring festival..

@kennymckormick
Copy link
Member

@innerlee I think we can merge this PR once the performance is the same or better than the paper. performance alignment with the released ckpt can be postponed, what's ur opinion?

@innerlee
Copy link
Contributor

innerlee commented Feb 2, 2021

Yeah better than paper is good enough

@kennymckormick
Copy link
Member

@dreamerlin Would you please help add the ckpts you trained? Maybe it's OK to merge it first and try to improve the performance later.

@dreamerlin
Copy link
Collaborator

related config files and links are updated now

@innerlee
Copy link
Contributor

innerlee commented Feb 2, 2021

failing tests are related

@innerlee innerlee merged commit d3694c5 into open-mmlab:master Feb 3, 2021
@innerlee
Copy link
Contributor

innerlee commented Feb 3, 2021

Thanks!

@irvingzhang0512 irvingzhang0512 deleted the mobilenetv2-tsm branch February 4, 2021 02:29
congee524 pushed a commit to congee524/mmaction2 that referenced this pull request Feb 4, 2021
* [Feature] add mobilenetv2-tsm, first commit.

* 1. remove torchvision mobilentv2.
2. update unittest.
3. refactor mobilentv2 with torchvision version.

* fix unittest bug and update annotations.

* chanage default config.

* fix default configs

* fix unittest and config bug.

* improve unittest coverage

* update training configs

* refactor mobilenet_v2 with mmclassification

* add changelog

* update changelog

* fix unittest

* fix unittest

* improve Codecov

* update default training configs

* add inference config

* fix

* refactor unittest

* refactor config

* update config and model link

* update config & docs

Co-authored-by: Jintao Lin <528557675@qq.com>
@dreamerlin dreamerlin mentioned this pull request Feb 25, 2021
9 tasks
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants