-
Notifications
You must be signed in to change notification settings - Fork 145
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
add VitSam #743
base: main
Are you sure you want to change the base?
add VitSam #743
Conversation
e144a2e
to
76a9170
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
把pyproject.toml
的13行注释掉,重新对这个文件跑一下pre-commit
self.num_prefix_tokens = num_prefix_tokens # exclude CLS token (or other prefix tokens) | ||
self.ordered = ordered | ||
self.return_indices = return_indices | ||
self.sort = ops.Sort() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
直接在前向里用函数式接口
self.return_indices = return_indices | ||
self.sort = ops.Sort() | ||
|
||
def forward(self, x): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
construct
mindcv/models/layers/patch_embed.py
Outdated
x = ops.Reshape()(x, (B, self.embed_dim, -1)) # B Ph*Pw C | ||
x = ops.Transpose()(x, (0, 2, 1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
用函数式接口
mindcv/models/vit_sam.py
Outdated
self.mul = ops.Mul() | ||
self.reshape = ops.Reshape() | ||
self.transpose = ops.Transpose() | ||
self.unstack = ops.Unstack(axis=0) | ||
self.attn_matmul_v = ops.BatchMatMul() | ||
self.q_matmul_k = ops.BatchMatMul(transpose_b=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
尽量替换为函数式接口
mindcv/models/vit_sam.py
Outdated
"""Multi-head Attention block with relative position embeddings.""" | ||
|
||
def __init__( | ||
self, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
减少一级缩进
mindcv/models/vit_sam.py
Outdated
|
||
|
||
def get_decomposed_rel_pos( | ||
q: ms.Tensor, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
减少一级缩进
1279c2d
to
10cd680
Compare
Thank you for your contribution to the MindCV repo.
Before submitting this PR, please make sure: