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

Some confusion about v10postprocess. #494

Open
IronMan1111 opened this issue Nov 8, 2024 · 0 comments
Open

Some confusion about v10postprocess. #494

IronMan1111 opened this issue Nov 8, 2024 · 0 comments

Comments

@IronMan1111
Copy link

Why is topk used twice in v10postprocess? In my opinion, if we modify v10postprocess to perform a single topk calculation as shown below, the result would be the same.

def v10postprocess(preds, max_det, nc=80):
    assert(4 + nc == preds.shape[-1])
    boxes, scores = preds.split([4, nc], dim=-1)
    scores, index = torch.topk(scores.flatten(1), max_det, dim=-1)
    labels = index % nc
    index = index // nc
    boxes = boxes.gather(dim=1, index=index.unsqueeze(-1).repeat(1, 1, boxes.shape[-1]))
    return boxes, scores, labels
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

No branches or pull requests

1 participant