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

About matcher code for top-k links (M) #4

Open
jinyoung0121 opened this issue Feb 9, 2023 · 2 comments
Open

About matcher code for top-k links (M) #4

jinyoung0121 opened this issue Feb 9, 2023 · 2 comments

Comments

@jinyoung0121
Copy link

Hi! Thank you for your wonderful work!

The code that determines the top-k links(M) seems to be 'build_matcher'.
However, it seems like that only the code for top-k=1 has been uploaded.
Is there a code uploaded for top-k≠1? (e.g., top-k=3)

Thanks.

def build_matcher(name, cost_class, cost_bbox, cost_giou, topk=1):
    if topk == 1:
        return MATCHER_REGISTRY.get(name)(cost_class=cost_class, cost_bbox=cost_bbox, cost_giou=cost_giou)
    else:
        return MATCHER_REGISTRY.get(name)(cost_class=cost_class, cost_bbox=cost_bbox, cost_giou=cost_giou, topk=topk)
@MATCHER_REGISTRY.register()
class IterativeHungarianMatcher(nn.Module):
    """This class computes an assignment between the targets and the predictions of the network
    For efficiency reasons, the targets don't include the no_object. Because of this, in general,
    there are more predictions than targets. In this case, we do a 1-to-1 matching of the best predictions,
    while the others are un-matched (and thus treated as non-objects).
    """

    def __init__(self, cost_class: float = 1, cost_bbox: float = 1, cost_giou: float = 1):
        """Creates the matcher
        Params:
            cost_class: This is the relative weight of the classification error in the matching cost
            cost_bbox: This is the relative weight of the L1 error of the bounding box coordinates in the matching cost
            cost_giou: This is the relative weight of the giou loss of the bounding box in the matching cost
        """
        super().__init__()
        self.cost_class = cost_class
        self.cost_bbox = cost_bbox
        self.cost_giou = cost_giou
        assert cost_class != 0 or cost_bbox != 0 or cost_giou != 0, "all costs cant be 0"
@Lil-Shake
Copy link

Hi! I have the same question as you. Has the question been solved?
Thanks:)

@Scarecrow0
Copy link

Scarecrow0 commented Sep 8, 2023

Same question; I'm wondering about the implementation of how the author achieves M=3.

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

3 participants