{"version":2,"relationshipURLBase":"https://codingai-lec03.pages.dev/course/notebook-blocks/afc86821efbb4021940cb56bf27497ec.html","relationshipResolution":"Resolve relative relationship URLs against relationshipURLBase; complete records and absolute URLs are in blocks.","title":"5 · NMS 的阈值不是评价的阈值 · 实现代码","url":"https://codingai-lec03.pages.dev/course/notebook-blocks/afc86821efbb4021940cb56bf27497ec.html","markdown":"https://codingai-lec03.pages.dev/course/notebook-blocks/afc86821efbb4021940cb56bf27497ec.md","pages":[{"id":"reading-opening","title":"5 · NMS 的阈值不是评价的阈值 · 实现代码","unit":"5 · NMS 的阈值不是评价的阈值 · 实现代码","unitId":"notebook-blocks/afc86821efbb4021940cb56bf27497ec","chapter":"course","number":1}],"aliases":[{"oldId":"b-6578f9fcee5c90a384d21ae1","targetId":"b-6578f9fcee5c90a384d21ae1","page":"reading-opening","operation":"move","beforeSHA256":"9027342eb8430f11699811edb871aeb2e37b28e9f874a2aa48778e6bac2818b7","afterSHA256":"9027342eb8430f11699811edb871aeb2e37b28e9f874a2aa48778e6bac2818b7","reason":"Same source body in authored semantic page"},{"oldId":"b-2e9749f59990bb222cfe8400","targetId":"b-2e9749f59990bb222cfe8400","page":"reading-opening","operation":"move","beforeSHA256":"490703cad74d6b1ba0222df21ec53592af920c79d2d23554ae95ee0de3875d4a","afterSHA256":"490703cad74d6b1ba0222df21ec53592af920c79d2d23554ae95ee0de3875d4a","reason":"Same source body in authored semantic page"},{"oldId":"b-f52641b044ed347550e565b5","targetId":"b-f52641b044ed347550e565b5","page":"reading-opening","operation":"move","beforeSHA256":"dc06c1e728a4b5740ba634b145bc9a1da6323031626734cb4555db5a744df806","afterSHA256":"dc06c1e728a4b5740ba634b145bc9a1da6323031626734cb4555db5a744df806","reason":"Same source body in authored semantic page"},{"oldId":"b-e73cf5bf8a9cf82c3051b6b0","targetId":"b-e73cf5bf8a9cf82c3051b6b0","page":"reading-opening","operation":"move","beforeSHA256":"4e0de6d032a3765c60907de32f28cd988b659299663e842d319bdb0426243d78","afterSHA256":"4e0de6d032a3765c60907de32f28cd988b659299663e842d319bdb0426243d78","reason":"Same source body in authored semantic page"},{"oldId":"b-2d0895dbcc868a200554df4d","targetId":"b-2d0895dbcc868a200554df4d","page":"reading-opening","operation":"move","beforeSHA256":"3fe7a5b21556059e41c3b20e435ee8b99fad068a74ad2b7497818abdaa31bf92","afterSHA256":"3fe7a5b21556059e41c3b20e435ee8b99fad068a74ad2b7497818abdaa31bf92","reason":"Same source body in authored semantic page"}],"blocks":[{"id":"b-6578f9fcee5c90a384d21ae1","type":"p","scope":"document","url":"https://codingai-lec03.pages.dev/course/notebook-blocks/afc86821efbb4021940cb56bf27497ec.html#b-6578f9fcee5c90a384d21ae1","content":"[LAB 09 · 检测几何：框、匹配、NMS 与 AP](/course/notebooks/90d213b4e1e04c7e889ee6fc042b2358.html)","sha256":"9027342eb8430f11699811edb871aeb2e37b28e9f874a2aa48778e6bac2818b7","chapter":{"id":"course","title":"5 · NMS 的阈值不是评价的阈值 · 实现代码"},"unit":{"id":"notebook-blocks/afc86821efbb4021940cb56bf27497ec","title":"5 · NMS 的阈值不是评价的阈值 · 实现代码"},"page":{"id":"reading-opening","title":"5 · NMS 的阈值不是评价的阈值 · 实现代码","number":1},"sectionTitle":"5 · NMS 的阈值不是评价的阈值 · 实现代码","currentQuestion":"5 · NMS 的阈值不是评价的阈值 · 实现代码","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":null,"nextBlock":"b-2e9749f59990bb222cfe8400","prerequisites":[],"relatedBlocks":[]},{"id":"b-2e9749f59990bb222cfe8400","type":"h1","scope":"document","url":"https://codingai-lec03.pages.dev/course/notebook-blocks/afc86821efbb4021940cb56bf27497ec.html#b-2e9749f59990bb222cfe8400","content":"# 5 · NMS 的阈值不是评价的阈值 · 实现代码","sha256":"490703cad74d6b1ba0222df21ec53592af920c79d2d23554ae95ee0de3875d4a","chapter":{"id":"course","title":"5 · NMS 的阈值不是评价的阈值 · 实现代码"},"unit":{"id":"notebook-blocks/afc86821efbb4021940cb56bf27497ec","title":"5 · NMS 的阈值不是评价的阈值 · 实现代码"},"page":{"id":"reading-opening","title":"5 · NMS 的阈值不是评价的阈值 · 实现代码","number":1},"sectionTitle":"5 · NMS 的阈值不是评价的阈值 · 实现代码","currentQuestion":"5 · NMS 的阈值不是评价的阈值 · 实现代码","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-6578f9fcee5c90a384d21ae1","nextBlock":"b-f52641b044ed347550e565b5","prerequisites":[{"id":"b-6578f9fcee5c90a384d21ae1","url":"#b-6578f9fcee5c90a384d21ae1","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-f52641b044ed347550e565b5","type":"p","scope":"document","url":"https://codingai-lec03.pages.dev/course/notebook-blocks/afc86821efbb4021940cb56bf27497ec.html#b-f52641b044ed347550e565b5","content":"并入相关学习路径","sha256":"dc06c1e728a4b5740ba634b145bc9a1da6323031626734cb4555db5a744df806","chapter":{"id":"course","title":"5 · NMS 的阈值不是评价的阈值 · 实现代码"},"unit":{"id":"notebook-blocks/afc86821efbb4021940cb56bf27497ec","title":"5 · NMS 的阈值不是评价的阈值 · 实现代码"},"page":{"id":"reading-opening","title":"5 · NMS 的阈值不是评价的阈值 · 实现代码","number":1},"sectionTitle":"5 · NMS 的阈值不是评价的阈值 · 实现代码","currentQuestion":"5 · NMS 的阈值不是评价的阈值 · 实现代码","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-2e9749f59990bb222cfe8400","nextBlock":"b-e73cf5bf8a9cf82c3051b6b0","prerequisites":[{"id":"b-2e9749f59990bb222cfe8400","url":"#b-2e9749f59990bb222cfe8400","role":"section-title"},{"id":"b-6578f9fcee5c90a384d21ae1","url":"#b-6578f9fcee5c90a384d21ae1","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-e73cf5bf8a9cf82c3051b6b0","type":"p","scope":"document","url":"https://codingai-lec03.pages.dev/course/notebook-blocks/afc86821efbb4021940cb56bf27497ec.html#b-e73cf5bf8a9cf82c3051b6b0","content":"固定框匹配、PR/AP、NMS误删相邻对象反例","sha256":"4e0de6d032a3765c60907de32f28cd988b659299663e842d319bdb0426243d78","chapter":{"id":"course","title":"5 · NMS 的阈值不是评价的阈值 · 实现代码"},"unit":{"id":"notebook-blocks/afc86821efbb4021940cb56bf27497ec","title":"5 · NMS 的阈值不是评价的阈值 · 实现代码"},"page":{"id":"reading-opening","title":"5 · NMS 的阈值不是评价的阈值 · 实现代码","number":1},"sectionTitle":"5 · NMS 的阈值不是评价的阈值 · 实现代码","currentQuestion":"5 · NMS 的阈值不是评价的阈值 · 实现代码","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-f52641b044ed347550e565b5","nextBlock":"b-2d0895dbcc868a200554df4d","prerequisites":[{"id":"b-2e9749f59990bb222cfe8400","url":"#b-2e9749f59990bb222cfe8400","role":"section-title"},{"id":"b-6578f9fcee5c90a384d21ae1","url":"#b-6578f9fcee5c90a384d21ae1","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-2d0895dbcc868a200554df4d","type":"pre","scope":"document","url":"https://codingai-lec03.pages.dev/course/notebook-blocks/afc86821efbb4021940cb56bf27497ec.html#b-2d0895dbcc868a200554df4d","content":"```\ndef class_aware_nms(boxes, scores, classes, iou_threshold=0.50):\n    \"\"\"Keep a box unless a higher-scored kept box of SAME class has IoU > threshold.\n\n    Equality is retained. There is no extra confidence cutoff in this lab.\n    \"\"\"\n    boxes = boxes_xyxy(boxes)\n    scores, classes = np.asarray(scores, float), np.asarray(classes)\n    if scores.shape != (len(boxes),) or classes.shape != (len(boxes),):\n        raise ValueError(\"Scores/classes must have shape (N,)\")\n    if not np.isfinite(scores).all() or not 0 <= iou_threshold <= 1:\n        raise ValueError(\"Finite scores and an IoU threshold in [0,1] required\")\n    remaining = np.argsort(-scores, kind=\"stable\")\n    kept, suppressed = [], []\n    while len(remaining):\n        current, remaining = int(remaining[0]), remaining[1:]\n        kept.append(current)\n        overlap = box_iou(boxes[current:current + 1], boxes[remaining])[0]\n        remove = (classes[remaining] == classes[current]) & (overlap > iou_threshold)\n        for victim, iou_value in zip(remaining[remove], overlap[remove]):\n            suppressed.append({\"prediction\": int(victim + 1), \"by\": current + 1,\n                               \"iou\": float(iou_value), \"class\": int(classes[current])})\n        remaining = remaining[~remove]\n    return np.asarray(kept, dtype=int), suppressed\n\nprint(\"NMS keeps 1-based predictions:\", class_aware_nms(PRED, SCORES, CLASSES, NMS_THRESHOLD)[0] + 1)\n```","sha256":"3fe7a5b21556059e41c3b20e435ee8b99fad068a74ad2b7497818abdaa31bf92","chapter":{"id":"course","title":"5 · NMS 的阈值不是评价的阈值 · 实现代码"},"unit":{"id":"notebook-blocks/afc86821efbb4021940cb56bf27497ec","title":"5 · NMS 的阈值不是评价的阈值 · 实现代码"},"page":{"id":"reading-opening","title":"5 · NMS 的阈值不是评价的阈值 · 实现代码","number":1},"sectionTitle":"5 · NMS 的阈值不是评价的阈值 · 实现代码","currentQuestion":"5 · NMS 的阈值不是评价的阈值 · 实现代码","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-e73cf5bf8a9cf82c3051b6b0","nextBlock":null,"prerequisites":[{"id":"b-2e9749f59990bb222cfe8400","url":"#b-2e9749f59990bb222cfe8400","role":"section-title"},{"id":"b-6578f9fcee5c90a384d21ae1","url":"#b-6578f9fcee5c90a384d21ae1","role":"problem-context"}],"relatedBlocks":[]}]}
