Skip to content

[Feature] Add PoseFormer backbone - #1215

Open
QwQ2000 wants to merge 24 commits into
open-mmlab:dev-0.26from
QwQ2000:dev-0.24
Open

QwQ2000 wants to merge 24 commits into
open-mmlab:dev-0.26from
QwQ2000:dev-0.24

Conversation

@QwQ2000

@QwQ2000 QwQ2000 commented Mar 3, 2022

Copy link
Copy Markdown
Contributor

Motivation

Modification

Add backbone, head and config of the PoseFormer (ICCV 2021) into the repository.

BC-breaking (Optional)

Use cases (Optional)

Checklist

Before PR:

  • I have read and followed the workflow indicated in the CONTRIBUTING.md to create this PR.
  • Pre-commit or linting tools indicated in CONTRIBUTING.md are used to fix the potential lint issues.
  • Bug fixes are covered by unit tests, the case that causes the bug should be added in the unit tests.
  • New functionalities are covered by complete unit tests. If not, please add more unit tests to ensure correctness.
  • The documentation has been modified accordingly, including docstring or example tutorials.

After PR:

  • CLA has been signed and all committers have signed the CLA in this PR.

ly015 and others added 15 commits February 24, 2022 17:40
* update mmvc installation CI and doc

* fix lint
* add derepcation message for deploy tools

* change import warnings positions

* do yapf

* do isort
* hrformer

* modify cfg

* update url and readme for hrformer.

* add readme for hrformer papar

* modify reaadme

* fix publish year

Co-authored-by: ly015 <liyining0712@gmail.com>
* clean inference code

* LoadImageFromFile supports given img
…en-mmlab#1214)

* switch to open-mmlab/pre-commit-hooks

* deprecate .dev_scripts/github/update_copyright.py
* add windows-ci

* reduce input size to save memory

* fix codecov

* reduce input size to save memory

* skip voxelpose unittest for Windows

* remove win+cuda test
@ly015
ly015 changed the base branch from dev-0.24 to dev-0.25 March 8, 2022 03:04
@codecov

codecov Bot commented Mar 8, 2022 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.85714% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.13%. Comparing base (c09a693) to head (30fca23).
⚠️ Report is 50 commits behind head on dev-0.26.

Files with missing lines Patch % Lines
mmpose/models/backbones/poseformer.py 91.58% 7 Missing and 2 partials ⚠️
mmpose/models/heads/poseformer_head.py 75.00% 5 Missing and 2 partials ⚠️
mmpose/datasets/pipelines/pose3d_transform.py 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           dev-0.26    #1215      +/-   ##
============================================
+ Coverage     83.44%   84.13%   +0.69%     
============================================
  Files           205      217      +12     
  Lines         16625    17813    +1188     
  Branches       2976     3158     +182     
============================================
+ Hits          13872    14987    +1115     
- Misses         2001     2030      +29     
- Partials        752      796      +44     
Flag Coverage Δ
unittests 84.06% <87.85%> (+0.69%) ⬆️

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

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@QwQ2000
QwQ2000 requested a review from ly015 March 8, 2022 11:28
@ly015
ly015 requested review from jin-s13 and liqikai9 March 9, 2022 05:28
@jin-s13 jin-s13 mentioned this pull request Mar 12, 2022
from .base_backbone import BaseBackbone


class MultiheadAttention(BaseModule):

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.

mmcv also has MultiheadAttention module. Can we use that one?

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.

This MultiheadAttention module is adapted from mmcls. Compared with the MultiheadAttention in mmcv, its counterpart in mmcls is more similar to the implementation in the official PoseFormer repository.

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.

I will give mmcv Transformer blocks a try. However, if the output and the model weights of the re-implemented PoseFormer based on mmcv Transformer blocks could not fit the official version of PoseFormer, keeping the mmcls Transformer modules might be a good choice.

Comment thread mmpose/models/backbones/poseformer.py Outdated
num_joints=17,
in_chans=2,
embed_dim_ratio=32,
depth=4,

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.

Is the depth for spatial and temporal transformer always the same? If not, do we need to distinguish them?

@QwQ2000 QwQ2000 Mar 26, 2022 •

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.

In the official implementation of PoseFormer, the spatial and temporal transformer share the same depth.
However, I think it's obviously better to distinguish the two depths for clarity and I will follow this comment.

Comment thread mmpose/models/backbones/poseformer.py Outdated
if norm_cfg is None:
norm_cfg = dict(type='LN')
# Temporal embed_dim is num_joints * spatial embedding dim ratio
embed_dim = embed_dim_ratio * num_joints

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.

Does embed_dim mean the embedding dimension for each frame? How about using embed_dim_per_frame ?

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.

Now I use spatial_embed_dim and temporal_embed_dim instead of embed_dim_ratio and embed_dim.

Comment thread mmpose/models/backbones/poseformer.py Outdated
init_cfg=init_cfg) for i in range(depth)
])

self.blocks = nn.ModuleList([

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.

Does self.blocks mean the temporal transformer blocks? How about using self.temporal_blocks for clarity?

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.

self.temporal_blocks is a better choice.

return x


class TransformerEncoderLayer(BaseModule):

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.

mmcv has the similar layer BaseTransformerLayermodule under mmcv/cnn/bricks/transformer.py, which also includes MultiheadAttention. Can we use that one?

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.

This TransformerEncoderLayer module is adapted from mmcls. Compared with the BaseTransformerLayer in mmcv, its counterpart in mmcls is more similar to the implementation in the official PoseFormer repository.

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.

I will give mmcv Transformer blocks a try. However, if the output and the model weights of the re-implemented PoseFormer based on mmcv Transformer blocks could not fit the official version of PoseFormer, keeping the mmcls Transformer modules might be a good choice.

@ly015 ly015 mentioned this pull request Apr 8, 2022
7 tasks
@liqikai9
liqikai9 changed the base branch from dev-0.25 to dev-0.26 April 20, 2022 05:43
@darcula1993

Copy link
Copy Markdown

what's wrong with this branch? Is ther any update?
@QwQ2000 @ly015

@QwQ2000

QwQ2000 commented Sep 7, 2022

Copy link
Copy Markdown
Contributor Author

Sorry, I have resigned from the Shanghai AI Lab for a long time. I'm busy working on other projects so I don't have much time for this. If someone could help me finish this feature, I will be always willing to help.

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.

7 participants