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

[Bug] maybe a bug in mmdeploy/codebase/mmdet/models/dense_heads/yolox_head.py #2006

Closed
3 tasks done
HeDeYu opened this issue Apr 18, 2023 · 3 comments
Closed
3 tasks done

Comments

@HeDeYu
Copy link

HeDeYu commented Apr 18, 2023

Checklist

  • I have searched related issues but cannot get the expected help.
  • 2. I have read the FAQ documentation but cannot get the expected help.
  • 3. The bug has not been fixed in the latest version.

Describe the bug

yolox转onnx后,动态batch size时,给定输入大于1张图像时会报错。我查看了一下代码发现如下

第97行
max_scores, _ = torch.max(scores, 1)
这里我猜测是需要对任意image(即batch 维度),任意位置(即anchor维度),取所有类别sigmoid后分数最大值(再进一步判断当前图像当前anchor是否有必要输出,即是否>conf threshold),但scores是尺寸为(N,Anchors,K)的tensor,max的dim恐怕是-1(即取categories维度上的max)
即修改为max_scores, _ = torch.max(scores, -1)

然后第99行
scores = scores.where(mask, scores.new_zeros(1))
mask可能需要unsqueeze and repeat一下。
即修改为scores = scores.where(torch.unsqueeze(mask, dim=-1).repeat(1,1,K), scores.new_zeros(1))
K=number of categories (不过可能不用repeat,广播应该是OK的)

另外我对照了mmdet里边对应功能的代码 v3.0.0rc6
mmdet/models/dense_heads/yolox_head.py中的predict_by_feat方法第307行,这里应该是想做同样的事情
max_scores, labels = torch.max(flatten_cls_scores[img_id], 1)
但这里max的dim取1是因为前边flatten_cls_scores[img_id]已经取了img_id,相当于N维度已经不在了,所以dim=1对应categories维度。

Reproduction

详见上节

Environment

Error traceback

No response

@RunningLeon
Copy link
Collaborator

@HeDeYu Hi, thanks for your feedback. Could you PR us to fix it?

@github-actions
Copy link

This issue is marked as stale because it has been marked as invalid or awaiting response for 7 days without any further response. It will be closed in 5 days if the stale label is not removed or if there is no further response.

@github-actions
Copy link

This issue is closed because it has been stale for 5 days. Please open a new issue if you have similar issues or you have any new updates now.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants