{"record":{"id":"6b0fcebc573dc53b","repo":"open-mmlab/mmdetection","slug":"kwargs-value-must-both-equal","errorCode":null,"errorMessage":"kwargs value must both equal","messagePattern":"kwargs value must both equal","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mmdet/models/trackers/base_tracker.py","lineNumber":81,"sourceCode":"        for item in rm_items:\n            kwargs.pop(item)\n        if not hasattr(self, 'memo_items'):\n            self.memo_items = memo_items\n        else:\n            assert memo_items == self.memo_items\n\n        assert 'ids' in memo_items\n        num_objs = len(kwargs['ids'])\n        id_indice = memo_items.index('ids')\n        assert 'frame_ids' in memo_items\n        frame_id = int(kwargs['frame_ids'])\n        if isinstance(kwargs['frame_ids'], int):\n            kwargs['frame_ids'] = torch.tensor([kwargs['frame_ids']] *\n                                               num_objs)\n        # cur_frame_id = int(kwargs['frame_ids'][0])\n        for k, v in kwargs.items():\n            if len(v) != num_objs:\n                raise ValueError('kwargs value must both equal')\n\n        for obj in zip(*kwargs.values()):\n            id = int(obj[id_indice])\n            if id in self.tracks:\n                self.update_track(id, obj)\n            else:\n                self.init_track(id, obj)\n\n        self.pop_invalid_tracks(frame_id)\n\n    def pop_invalid_tracks(self, frame_id: int) -> None:\n        \"\"\"Pop out invalid tracks.\"\"\"\n        invalid_ids = []\n        for k, v in self.tracks.items():\n            if frame_id - v['frame_ids'][-1] >= self.num_frames_retain:\n                invalid_ids.append(k)\n        for invalid_id in invalid_ids:\n            self.tracks.pop(invalid_id)","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/open-mmlab/mmdetection/blob/cfd5d3a985b0249de009b67d04f37263e11cdf3d/mmdet/models/trackers/base_tracker.py#L63-L99","documentation":"BaseTracker.update expects every per-object kwarg (labels, scores, frame_ids, etc.) to have length equal to num_objs (the number of detected boxes). If any tensor/list passed via kwargs has a different length, it raises ValueError.","triggerScenarios":"Calling tracker.update(data, results) with a custom head whose predict returns fields of mismatched length — e.g. det_labels of length N but scores of length M != N — or passing frame_ids already as a tensor of wrong length while num_objs comes from preds.","commonSituations":"Writing a custom video detector/tracking head, or filtering predictions inconsistently (filter by score on one field but not others) before calling the tracker.","solutions":["Make all per-object fields in the track results dict the same length as preds (num_objs)","If you pre-filter detections, apply identical filtering to labels/scores/frame_ids","When calling update manually, ensure frame_ids broadcasts to num_objs (int or tensor of that length)"],"exampleFix":"# before\nresults = dict(det_labels=labels, det_scores=scores[:10])  # truncated\n# after\nresults = dict(det_labels=labels[:10], det_scores=scores[:10])","handlingStrategy":"validation","validationCode":"n = preds.shape[0]\nassert all(len(v) == n for v in kwargs.values() if hasattr(v, '__len__')), \\\n    'all per-object fields must match num_objs'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Filter all prediction fields with the same boolean mask","Write custom heads to always return equal-length fields"],"tags":["mmdetection","tracking","shape-mismatch"],"backgroundTag":"length-mismatch","analyzedSha":"cfd5d3a985b0249de009b67d04f37263e11cdf3d","analyzedAt":"2026-08-27T20:54:20.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}