{"version":2,"relationshipURLBase":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html","relationshipResolution":"Resolve relative relationship URLs against relationshipURLBase; complete records and absolute URLs are in blocks.","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html","markdown":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.md","pages":[{"id":"reading-opening","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","unit":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","unitId":"lab09-检测几何-框匹配nms-与-ap","chapter":"course","number":1},{"id":"reading-block-f4deca9d4809465288f3a8e07e5320ab","title":"1 · 坐标先说清：连续 xyxy，不加一","unit":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","unitId":"lab09-检测几何-框匹配nms-与-ap","chapter":"course","number":2},{"id":"reading-block-311a83a867ee4c7dadefdaca58f5c533","title":"2 · 训练分配和评价匹配解决两个问题","unit":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","unitId":"lab09-检测几何-框匹配nms-与-ap","chapter":"course","number":3},{"id":"reading-block-8eced6ce67e84d02929cf23760a5eb09","title":"3 · 评价先降序，再限制同一 GT 只用一次","unit":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","unitId":"lab09-检测几何-框匹配nms-与-ap","chapter":"course","number":4},{"id":"reading-block-03a49740c8684af3bd417c1030853845","title":"4 · AP 必须说明积分协议","unit":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","unitId":"lab09-检测几何-框匹配nms-与-ap","chapter":"course","number":5},{"id":"reading-block-cf51f5d05100404d88c27df74895324d","title":"5 · NMS 的阈值不是评价的阈值","unit":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","unitId":"lab09-检测几何-框匹配nms-与-ap","chapter":"course","number":6},{"id":"reading-block-0a71ec88a039404fbc98fde29df4fe9d","title":"6 · 反例：相邻真实对象被 NMS 合并","unit":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","unitId":"lab09-检测几何-框匹配nms-与-ap","chapter":"course","number":7},{"id":"reading-block-ba39de56ef7d4d2882d9441ecd6d1424","title":"可视化与实际输出","unit":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","unitId":"lab09-检测几何-框匹配nms-与-ap","chapter":"course","number":8},{"id":"reading-block-a913f088886f4de38fb1812ed586dc33","title":"7 · 只改一个条件，并用结果回答","unit":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","unitId":"lab09-检测几何-框匹配nms-与-ap","chapter":"course","number":9},{"id":"reading-block-8f24850741144b31ac103742e94f7ecd","title":"来源与范围","unit":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","unitId":"lab09-检测几何-框匹配nms-与-ap","chapter":"course","number":10},{"id":"reading-block-e40ebaef99ea481ea734c690ce85f20d","title":"本次基准的静态图","unit":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","unitId":"lab09-检测几何-框匹配nms-与-ap","chapter":"course","number":11},{"id":"reading-block-01778787c2ab4952b60963cbffd5b7c1","title":"运行记录","unit":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","unitId":"lab09-检测几何-框匹配nms-与-ap","chapter":"course","number":12}],"aliases":[{"oldId":"b-52c9fc30c97ef14eb318f0d5","targetId":"b-52c9fc30c97ef14eb318f0d5","page":"reading-opening","operation":"move","beforeSHA256":"209faa721c10831b9a840959831aa235dd1d2460e3fe9d584c9e7ae9cd60a827","afterSHA256":"209faa721c10831b9a840959831aa235dd1d2460e3fe9d584c9e7ae9cd60a827","reason":"Same source body in authored semantic page"},{"oldId":"b-560cb3ae3fb4379dd9dc3add","targetId":"b-560cb3ae3fb4379dd9dc3add","page":"reading-opening","operation":"move","beforeSHA256":"dc06c1e728a4b5740ba634b145bc9a1da6323031626734cb4555db5a744df806","afterSHA256":"dc06c1e728a4b5740ba634b145bc9a1da6323031626734cb4555db5a744df806","reason":"Same source body in authored semantic page"},{"oldId":"b-dc9655b5cabadc3f23a3fc7e","targetId":"b-dc9655b5cabadc3f23a3fc7e","page":"reading-opening","operation":"move","beforeSHA256":"4e0de6d032a3765c60907de32f28cd988b659299663e842d319bdb0426243d78","afterSHA256":"4e0de6d032a3765c60907de32f28cd988b659299663e842d319bdb0426243d78","reason":"Same source body in authored semantic page"},{"oldId":"b-4ca13a107149721472214190","targetId":"b-4ca13a107149721472214190","page":"reading-opening","operation":"move","beforeSHA256":"f22152fd55dcdb0090b5653d37145694fd19388d31e10226549464fe8b483578","afterSHA256":"f22152fd55dcdb0090b5653d37145694fd19388d31e10226549464fe8b483578","reason":"Same source body in authored semantic page"},{"oldId":"b-ef46931cecd460ceb981d0c5","targetId":"b-ef46931cecd460ceb981d0c5","page":"reading-opening","operation":"move","beforeSHA256":"93899883c4c044ee5171cc6d4515e67b10961c3d3e67eb507245ef30c5e625ce","afterSHA256":"93899883c4c044ee5171cc6d4515e67b10961c3d3e67eb507245ef30c5e625ce","reason":"Same source body in authored semantic page"},{"oldId":"b-003ba62c958308c30c36c63d","targetId":"b-003ba62c958308c30c36c63d","page":"reading-opening","operation":"move","beforeSHA256":"f28364b1233566346e48e49d084d5f0cc291640d6e9914b099471d0bb06d7679","afterSHA256":"f28364b1233566346e48e49d084d5f0cc291640d6e9914b099471d0bb06d7679","reason":"Same source body in authored semantic page"},{"oldId":"b-931134070a50d532e044f7dc","targetId":"b-931134070a50d532e044f7dc","page":"reading-opening","operation":"move","beforeSHA256":"6c6093974ebe6135790caf23d0e8fc40206621d1f22642ea46bc60685415b026","afterSHA256":"6c6093974ebe6135790caf23d0e8fc40206621d1f22642ea46bc60685415b026","reason":"Same source body in authored semantic page"},{"oldId":"b-a42f53c0da5e8dfd0235d015","targetId":"b-a42f53c0da5e8dfd0235d015","page":"reading-opening","operation":"move","beforeSHA256":"2f80e817658c268f089a988357a6c1f428daa096b546a028a09cb40692d214a4","afterSHA256":"2f80e817658c268f089a988357a6c1f428daa096b546a028a09cb40692d214a4","reason":"Same source body in authored semantic page"},{"oldId":"b-eb31a8816fe8ba5890d1ea77","targetId":"b-eb31a8816fe8ba5890d1ea77","page":"reading-opening","operation":"move","beforeSHA256":"bad2300d993a83e0bd2f5f97d8bebdf04b9365e535f41eed4cdd34f598052b42","afterSHA256":"bad2300d993a83e0bd2f5f97d8bebdf04b9365e535f41eed4cdd34f598052b42","reason":"Same source body in authored semantic page"},{"oldId":"b-a80e5d457e6a5301a1fd7a76","targetId":"b-a80e5d457e6a5301a1fd7a76","page":"reading-opening","operation":"move","beforeSHA256":"17c087970008ebd0875576f6551258d8c6f5e701a79682f7055b68e8e0a4fa4e","afterSHA256":"17c087970008ebd0875576f6551258d8c6f5e701a79682f7055b68e8e0a4fa4e","reason":"Same source body in authored semantic page"},{"oldId":"b-4f286310079e5df55d17b588","targetId":"b-4f286310079e5df55d17b588","page":"reading-block-f4deca9d4809465288f3a8e07e5320ab","operation":"move","beforeSHA256":"21076e4abea8f5cd82f25d6a598814bfec6eaba3bb54f3eabba22659c6776ae3","afterSHA256":"21076e4abea8f5cd82f25d6a598814bfec6eaba3bb54f3eabba22659c6776ae3","reason":"Same source body in authored semantic page"},{"oldId":"b-571896439523ccbe7f147778","targetId":"b-571896439523ccbe7f147778","page":"reading-block-f4deca9d4809465288f3a8e07e5320ab","operation":"move","beforeSHA256":"73314c0b5f6c68187c132a49ce5ec92805418dcafd685a6e071a19f1a7e65f7e","afterSHA256":"73314c0b5f6c68187c132a49ce5ec92805418dcafd685a6e071a19f1a7e65f7e","reason":"Same source body in authored semantic page"},{"oldId":"b-7be6714cea43d13246761f29","targetId":"b-7be6714cea43d13246761f29","page":"reading-block-f4deca9d4809465288f3a8e07e5320ab","operation":"move","beforeSHA256":"2683a32e2a00b9ecc1ef56166562235cbd20019a57f5f8dbac8d5397a3cd5e93","afterSHA256":"2683a32e2a00b9ecc1ef56166562235cbd20019a57f5f8dbac8d5397a3cd5e93","reason":"Same source body in authored semantic page"},{"oldId":"b-13290047cae24859094ab666","targetId":"b-13290047cae24859094ab666","page":"reading-block-f4deca9d4809465288f3a8e07e5320ab","operation":"move","beforeSHA256":"8b96012fb03fc821f04d51253862ec1c5a096ed1689281fa6211b7c3e3f94e8e","afterSHA256":"8b96012fb03fc821f04d51253862ec1c5a096ed1689281fa6211b7c3e3f94e8e","reason":"Same source body in authored semantic page"},{"oldId":"b-f0700206a916142e6f76eaa1","targetId":"b-f0700206a916142e6f76eaa1","page":"reading-block-f4deca9d4809465288f3a8e07e5320ab","operation":"move","beforeSHA256":"af61996706cdb052e01330c6eda59067209ebdf75ccd8febb9390e2a7792c351","afterSHA256":"af61996706cdb052e01330c6eda59067209ebdf75ccd8febb9390e2a7792c351","reason":"Same source body in authored semantic page"},{"oldId":"b-d0881369f3f6d3d84b171838","targetId":"b-d0881369f3f6d3d84b171838","page":"reading-block-f4deca9d4809465288f3a8e07e5320ab","operation":"rewrite","beforeSHA256":"b78c07beeb9993fed5ca7a653b05abbc59bb3af0a00312d31774e1cbd307229d","afterSHA256":"35a40a3a234c22feca0b20bd3d34f8577540de706a652116d01a4649dd3828d6","reason":"Same source identity with figure semantics or reading context enriched"},{"oldId":"b-65b2c3745ca90af73dff6d8d","targetId":"b-65b2c3745ca90af73dff6d8d","page":"reading-block-f4deca9d4809465288f3a8e07e5320ab","operation":"move","beforeSHA256":"e8b5bc561f95fe7d998094b3035a96396e130dfc1284db851b8cae49b946121d","afterSHA256":"e8b5bc561f95fe7d998094b3035a96396e130dfc1284db851b8cae49b946121d","reason":"Same source body in authored semantic page"},{"oldId":"b-64db71ce67d37d52e100bfcf","targetId":"b-64db71ce67d37d52e100bfcf","page":"reading-block-f4deca9d4809465288f3a8e07e5320ab","operation":"move","beforeSHA256":"e04a8536c1317db4a8d0e06468ab965d641b49127c7cfedb01371925529420cc","afterSHA256":"e04a8536c1317db4a8d0e06468ab965d641b49127c7cfedb01371925529420cc","reason":"Same source body in authored semantic page"},{"oldId":"b-f42009d3f839f23dd4248f36","targetId":"b-f42009d3f839f23dd4248f36","page":"reading-block-f4deca9d4809465288f3a8e07e5320ab","operation":"move","beforeSHA256":"343c55023905db6d14465285570aee76e293e598d8f7c7336ce93561c05ae916","afterSHA256":"343c55023905db6d14465285570aee76e293e598d8f7c7336ce93561c05ae916","reason":"Same source body in authored semantic page"},{"oldId":"b-7b179561dfef0ec24061f5aa","targetId":"b-7b179561dfef0ec24061f5aa","page":"reading-block-311a83a867ee4c7dadefdaca58f5c533","operation":"move","beforeSHA256":"4433849b997a41e1acfa0f691767522233318857b7f413c0cbb27a86e43e4d2f","afterSHA256":"4433849b997a41e1acfa0f691767522233318857b7f413c0cbb27a86e43e4d2f","reason":"Same source body in authored semantic page"},{"oldId":"b-b4e7d8a654b8949ed0fc9ada","targetId":"b-b4e7d8a654b8949ed0fc9ada","page":"reading-block-311a83a867ee4c7dadefdaca58f5c533","operation":"move","beforeSHA256":"755a6f55f11d7f46e909c7704d72c9fffcd894cd9cff7bf5cdadb6082f074f1f","afterSHA256":"755a6f55f11d7f46e909c7704d72c9fffcd894cd9cff7bf5cdadb6082f074f1f","reason":"Same source body in authored semantic page"},{"oldId":"b-2c11cb9bd9ad5c6a777f811d","targetId":"b-2c11cb9bd9ad5c6a777f811d","page":"reading-block-311a83a867ee4c7dadefdaca58f5c533","operation":"rewrite","beforeSHA256":"4dfa73e7a0a1c5fe8b1fba22dcfccaf85f1acd737ca686ec5a716dab1633e319","afterSHA256":"eecc89f3790c3d3f5053398086d05a17847f61917aded6703a005232270b4e85","reason":"Same source identity with figure semantics or reading context enriched"},{"oldId":"b-256402efee2811b83d00227b","targetId":"b-256402efee2811b83d00227b","page":"reading-block-311a83a867ee4c7dadefdaca58f5c533","operation":"move","beforeSHA256":"6cedae1442df6dfca8fdc91a281213522c06ddf7dbda7203ecf19a1399323951","afterSHA256":"6cedae1442df6dfca8fdc91a281213522c06ddf7dbda7203ecf19a1399323951","reason":"Same source body in authored semantic page"},{"oldId":"b-07f6322030efe4d4a0a4c2e5","targetId":"b-07f6322030efe4d4a0a4c2e5","page":"reading-block-311a83a867ee4c7dadefdaca58f5c533","operation":"move","beforeSHA256":"f5a49456f54158c5f78062ed00e18cdb1908f830a246d85938dfbda2e2a1edbc","afterSHA256":"f5a49456f54158c5f78062ed00e18cdb1908f830a246d85938dfbda2e2a1edbc","reason":"Same source body in authored semantic page"},{"oldId":"b-2ced4bbd51bd7924020831dc","targetId":"b-2ced4bbd51bd7924020831dc","page":"reading-block-311a83a867ee4c7dadefdaca58f5c533","operation":"move","beforeSHA256":"2255662c7f11f30dc784b35f6dbd86c8f8eb4e4be25419eb2f70503c20798c9b","afterSHA256":"2255662c7f11f30dc784b35f6dbd86c8f8eb4e4be25419eb2f70503c20798c9b","reason":"Same source body in authored semantic page"},{"oldId":"b-9cf3d7092ae0e5441798fdea","targetId":"b-9cf3d7092ae0e5441798fdea","page":"reading-block-8eced6ce67e84d02929cf23760a5eb09","operation":"move","beforeSHA256":"1c70ccc601b66fd4935e666d10860b852e24341043463d5535a43c9ebd01fd17","afterSHA256":"1c70ccc601b66fd4935e666d10860b852e24341043463d5535a43c9ebd01fd17","reason":"Same source body in authored semantic page"},{"oldId":"b-d646afa26506d5a68d080326","targetId":"b-d646afa26506d5a68d080326","page":"reading-block-8eced6ce67e84d02929cf23760a5eb09","operation":"move","beforeSHA256":"187ff0706207a267d1a1a419d7adb53cfe2c27a351b6952d8aafa177975d1168","afterSHA256":"187ff0706207a267d1a1a419d7adb53cfe2c27a351b6952d8aafa177975d1168","reason":"Same source body in authored semantic page"},{"oldId":"b-95ffd2b5ffe5ac209447a51f","targetId":"b-95ffd2b5ffe5ac209447a51f","page":"reading-block-8eced6ce67e84d02929cf23760a5eb09","operation":"rewrite","beforeSHA256":"81df73c3f86f26e8bad4dc472b380cf1ea78136ae9fe52b1bfee62975fb3571d","afterSHA256":"bf08f9275b1e87a5e3aacdf42f1959271f41fbd1c7d717274ff8a06355e53cb9","reason":"Same source identity with figure semantics or reading context enriched"},{"oldId":"b-6358bf68f4cda41a3ef179e7","targetId":"b-6358bf68f4cda41a3ef179e7","page":"reading-block-8eced6ce67e84d02929cf23760a5eb09","operation":"move","beforeSHA256":"ec42f52f300e017f976cda1af5c4bd1d6d6c4af90617bc422902888b59ab2760","afterSHA256":"ec42f52f300e017f976cda1af5c4bd1d6d6c4af90617bc422902888b59ab2760","reason":"Same source body in authored semantic page"},{"oldId":"b-92f05fb8305517ed4666df97","targetId":"b-92f05fb8305517ed4666df97","page":"reading-block-8eced6ce67e84d02929cf23760a5eb09","operation":"move","beforeSHA256":"096818f0a207394945eb2fac232b6319100606e3c51d27539f8c5924e8418e83","afterSHA256":"096818f0a207394945eb2fac232b6319100606e3c51d27539f8c5924e8418e83","reason":"Same source body in authored semantic page"},{"oldId":"b-ee29f84042d17dbfc95a62c9","targetId":"b-ee29f84042d17dbfc95a62c9","page":"reading-block-8eced6ce67e84d02929cf23760a5eb09","operation":"rewrite","beforeSHA256":"b03dbc121a59228f6da10c44079f71ae7ca1c51a50fd9af705e68d040cec3817","afterSHA256":"e9eeb83a8390c9faa218454e7b9cba24074bc75c09400de319101d0201fdd5c3","reason":"Same source identity with figure semantics or reading context enriched"},{"oldId":"b-d25507fe61cf81db3e74ca53","targetId":"b-d25507fe61cf81db3e74ca53","page":"reading-block-8eced6ce67e84d02929cf23760a5eb09","operation":"move","beforeSHA256":"e58c4af6fbaaf04d30eaa108ba9ece3c2bbd6a7f500a267336fa1fde4a034b50","afterSHA256":"e58c4af6fbaaf04d30eaa108ba9ece3c2bbd6a7f500a267336fa1fde4a034b50","reason":"Same source body in authored semantic page"},{"oldId":"b-bc1de362eb57aa58185321d8","targetId":"b-bc1de362eb57aa58185321d8","page":"reading-block-03a49740c8684af3bd417c1030853845","operation":"move","beforeSHA256":"c145707f1bdb383bc093a32e8071c7886c9e1d9c370c86cb60c1fe35337f44d3","afterSHA256":"c145707f1bdb383bc093a32e8071c7886c9e1d9c370c86cb60c1fe35337f44d3","reason":"Same source body in authored semantic page"},{"oldId":"b-31fcbf62c06f8e50b89ce2ec","targetId":"b-31fcbf62c06f8e50b89ce2ec","page":"reading-block-03a49740c8684af3bd417c1030853845","operation":"move","beforeSHA256":"f6f435fc12d010fd15ba0b40957ddf28b87daeec77f71d538b23f790871980b1","afterSHA256":"f6f435fc12d010fd15ba0b40957ddf28b87daeec77f71d538b23f790871980b1","reason":"Same source body in authored semantic page"},{"oldId":"b-17dfadd9630e93139f81e78c","targetId":"b-17dfadd9630e93139f81e78c","page":"reading-block-03a49740c8684af3bd417c1030853845","operation":"move","beforeSHA256":"d3f0c99d3237b54e18e63608d41bd5beab5ef3818b9775162d384458afcca5c1","afterSHA256":"d3f0c99d3237b54e18e63608d41bd5beab5ef3818b9775162d384458afcca5c1","reason":"Same source body in authored semantic page"},{"oldId":"b-80614e4f0a9dbbbd41f5f4cb","targetId":"b-80614e4f0a9dbbbd41f5f4cb","page":"reading-block-03a49740c8684af3bd417c1030853845","operation":"move","beforeSHA256":"1c2acd6b45c31a4ac283596b599dfb02ca9e707978bee1014fbbc118309af70d","afterSHA256":"1c2acd6b45c31a4ac283596b599dfb02ca9e707978bee1014fbbc118309af70d","reason":"Same source body in authored semantic page"},{"oldId":"b-a38a959e980ce5c1d7a8443b","targetId":"b-a38a959e980ce5c1d7a8443b","page":"reading-block-03a49740c8684af3bd417c1030853845","operation":"move","beforeSHA256":"762c742d80949a91eaeb8ca7918d51cb4f5dab0687764f7757fa73912003c4ff","afterSHA256":"762c742d80949a91eaeb8ca7918d51cb4f5dab0687764f7757fa73912003c4ff","reason":"Same source body in authored semantic page"},{"oldId":"b-a779e783e8da40b31fa4bce4","targetId":"b-a779e783e8da40b31fa4bce4","page":"reading-block-03a49740c8684af3bd417c1030853845","operation":"move","beforeSHA256":"e3351724b316daea9225094de0deba288be32184bd0ac5315e834e369076efcf","afterSHA256":"e3351724b316daea9225094de0deba288be32184bd0ac5315e834e369076efcf","reason":"Same source body in authored semantic page"},{"oldId":"b-9dd8620ae9d15379709b11c1","targetId":"b-9dd8620ae9d15379709b11c1","page":"reading-block-03a49740c8684af3bd417c1030853845","operation":"move","beforeSHA256":"409a42fa0bffff8ec3b9cb5aa2642077b014eb5ccff1db6f96783f6262bdcda0","afterSHA256":"409a42fa0bffff8ec3b9cb5aa2642077b014eb5ccff1db6f96783f6262bdcda0","reason":"Same source body in authored semantic page"},{"oldId":"b-970ab698e1f67a172287bba0","targetId":"b-970ab698e1f67a172287bba0","page":"reading-block-03a49740c8684af3bd417c1030853845","operation":"move","beforeSHA256":"6a20e9ec12bafe365604d815861a7a739b084cf4489c5dc447dd00faca037f51","afterSHA256":"6a20e9ec12bafe365604d815861a7a739b084cf4489c5dc447dd00faca037f51","reason":"Same source body in authored semantic page"},{"oldId":"b-7d51adb14a0aaa5157649325","targetId":"b-7d51adb14a0aaa5157649325","page":"reading-block-03a49740c8684af3bd417c1030853845","operation":"move","beforeSHA256":"f19b1ef922e012efaaf2363ee58ba8f1909c2b51c67322adc04d5faac625c146","afterSHA256":"f19b1ef922e012efaaf2363ee58ba8f1909c2b51c67322adc04d5faac625c146","reason":"Same source body in authored semantic page"},{"oldId":"b-9b7264c45228653fbccbff8f","targetId":"b-9b7264c45228653fbccbff8f","page":"reading-block-03a49740c8684af3bd417c1030853845","operation":"move","beforeSHA256":"f31cf1d9a14598b7df30758514ff673215dd7e7f6b95d40db8325a0cf067437d","afterSHA256":"f31cf1d9a14598b7df30758514ff673215dd7e7f6b95d40db8325a0cf067437d","reason":"Same source body in authored semantic page"},{"oldId":"b-268ac124429a2d26908f206c","targetId":"b-268ac124429a2d26908f206c","page":"reading-block-cf51f5d05100404d88c27df74895324d","operation":"move","beforeSHA256":"99b2e6e24035851332a4887c1978f2bbacb01b592049fd2378d378923f9664a2","afterSHA256":"99b2e6e24035851332a4887c1978f2bbacb01b592049fd2378d378923f9664a2","reason":"Same source body in authored semantic page"},{"oldId":"b-0470c0f5e5caf4a3e45beecb","targetId":"b-0470c0f5e5caf4a3e45beecb","page":"reading-block-cf51f5d05100404d88c27df74895324d","operation":"move","beforeSHA256":"ff44778ca5c7eeffd58655ecd14f2f76e6c6de9e6c4a98686ed1e0c15217ef2b","afterSHA256":"ff44778ca5c7eeffd58655ecd14f2f76e6c6de9e6c4a98686ed1e0c15217ef2b","reason":"Same source body in authored semantic page"},{"oldId":"b-269b3de9a82ffd191d9a4266","targetId":"b-269b3de9a82ffd191d9a4266","page":"reading-block-cf51f5d05100404d88c27df74895324d","operation":"move","beforeSHA256":"e9598bbdffe74d165e2e2c5ccdbbf7874c6f5cd6a3cb7db83f9c8df436452870","afterSHA256":"e9598bbdffe74d165e2e2c5ccdbbf7874c6f5cd6a3cb7db83f9c8df436452870","reason":"Same source body in authored semantic page"},{"oldId":"b-22ee2aaae4cf67a42468af9f","targetId":"b-22ee2aaae4cf67a42468af9f","page":"reading-block-cf51f5d05100404d88c27df74895324d","operation":"rewrite","beforeSHA256":"75b8f0aea0f458a26c6a4bad18386ce51d6d045666cc4f14f2992675604dab4a","afterSHA256":"4dd65e80188fecd322b1ed169bd716718a7ab85d7ac95618c6543e0ec8506461","reason":"Same source identity with figure semantics or reading context enriched"},{"oldId":"b-4e82f4fdc246b9c47e2fd81e","targetId":"b-4e82f4fdc246b9c47e2fd81e","page":"reading-block-cf51f5d05100404d88c27df74895324d","operation":"move","beforeSHA256":"66f68d3235a1e4b9040cc5899b3ed4cbb50ffe431cf9d426948cb0450dbf573f","afterSHA256":"66f68d3235a1e4b9040cc5899b3ed4cbb50ffe431cf9d426948cb0450dbf573f","reason":"Same source body in authored semantic page"},{"oldId":"b-67a3487109d7991fc344d0da","targetId":"b-67a3487109d7991fc344d0da","page":"reading-block-cf51f5d05100404d88c27df74895324d","operation":"move","beforeSHA256":"3fe7a5b21556059e41c3b20e435ee8b99fad068a74ad2b7497818abdaa31bf92","afterSHA256":"3fe7a5b21556059e41c3b20e435ee8b99fad068a74ad2b7497818abdaa31bf92","reason":"Same source body in authored semantic page"},{"oldId":"b-e98f3f34077fd31350d38c1f","targetId":"b-e98f3f34077fd31350d38c1f","page":"reading-block-0a71ec88a039404fbc98fde29df4fe9d","operation":"move","beforeSHA256":"057b419e2a6f1c41cacfdca38da03ad6ba8650d0bd782da825b7dd0f23916f22","afterSHA256":"057b419e2a6f1c41cacfdca38da03ad6ba8650d0bd782da825b7dd0f23916f22","reason":"Same source body in authored semantic page"},{"oldId":"b-7aafddeade5ec24686f4dcd3","targetId":"b-7aafddeade5ec24686f4dcd3","page":"reading-block-0a71ec88a039404fbc98fde29df4fe9d","operation":"move","beforeSHA256":"a9edb5918459c5b3d18b937e2bd7182a7ef99bbfe8df3b9d1571ba6ef3f65d37","afterSHA256":"a9edb5918459c5b3d18b937e2bd7182a7ef99bbfe8df3b9d1571ba6ef3f65d37","reason":"Same source body in authored semantic page"},{"oldId":"b-b6ad3375758c8ecd430cfb88","targetId":"b-b6ad3375758c8ecd430cfb88","page":"reading-block-0a71ec88a039404fbc98fde29df4fe9d","operation":"move","beforeSHA256":"fa671c678fe0a1c60ae3e45a170194051904ba8c100efec9c1e1312559e0717a","afterSHA256":"fa671c678fe0a1c60ae3e45a170194051904ba8c100efec9c1e1312559e0717a","reason":"Same source body in authored semantic page"},{"oldId":"b-0b18a26a36e64d0e519b4cca","targetId":"b-0b18a26a36e64d0e519b4cca","page":"reading-block-0a71ec88a039404fbc98fde29df4fe9d","operation":"move","beforeSHA256":"abd49d75d7f2172ebb0b23c067ed984f4a20c61b79a7927c329effde809d940a","afterSHA256":"abd49d75d7f2172ebb0b23c067ed984f4a20c61b79a7927c329effde809d940a","reason":"Same source body in authored semantic page"},{"oldId":"b-7cbdab472dadba15927a4363","targetId":"b-7cbdab472dadba15927a4363","page":"reading-block-0a71ec88a039404fbc98fde29df4fe9d","operation":"move","beforeSHA256":"ceb02fe3d79ee675f25df17f834797146f96ba38d62332734e01c1df934950fc","afterSHA256":"ceb02fe3d79ee675f25df17f834797146f96ba38d62332734e01c1df934950fc","reason":"Same source body in authored semantic page"},{"oldId":"b-bd776c63facd8050676d0dbd","targetId":"b-bd776c63facd8050676d0dbd","page":"reading-block-0a71ec88a039404fbc98fde29df4fe9d","operation":"move","beforeSHA256":"019ed1e27e0ff2c7c0f21e08efbc88125eda7605362a3738b0d9b2c523479e80","afterSHA256":"019ed1e27e0ff2c7c0f21e08efbc88125eda7605362a3738b0d9b2c523479e80","reason":"Same source body in authored semantic page"},{"oldId":"b-c77ea7195466ecbb6a57ae76","targetId":"b-c77ea7195466ecbb6a57ae76","page":"reading-block-ba39de56ef7d4d2882d9441ecd6d1424","operation":"move","beforeSHA256":"e9cb32fe157eac264b6d74b8ff30a43e33c1ea6ea8a1a0e5eee1801aa44dab48","afterSHA256":"e9cb32fe157eac264b6d74b8ff30a43e33c1ea6ea8a1a0e5eee1801aa44dab48","reason":"Same source body in authored semantic page"},{"oldId":"b-f9ec3d0a17f12c0f92a6c9ea","targetId":"b-f9ec3d0a17f12c0f92a6c9ea","page":"reading-block-ba39de56ef7d4d2882d9441ecd6d1424","operation":"move","beforeSHA256":"34b109db7f914fa53edbcfc2cdbe86ff10eba63e922c644779362e4124b23f34","afterSHA256":"34b109db7f914fa53edbcfc2cdbe86ff10eba63e922c644779362e4124b23f34","reason":"Same source body in authored semantic page"},{"oldId":"b-2cae73a4f8542175499dc5a7","targetId":"b-2cae73a4f8542175499dc5a7","page":"reading-block-ba39de56ef7d4d2882d9441ecd6d1424","operation":"move","beforeSHA256":"c18440913a5b9ceb5beb27a2efb527a7e2ba4dc882038771e5f12bc96458119e","afterSHA256":"c18440913a5b9ceb5beb27a2efb527a7e2ba4dc882038771e5f12bc96458119e","reason":"Same source body in authored semantic page"},{"oldId":"b-b9ebdd7f83987d2976039760","targetId":"b-b9ebdd7f83987d2976039760","page":"reading-block-a913f088886f4de38fb1812ed586dc33","operation":"move","beforeSHA256":"ebb98f4b24db403eca5d1d903cdc5d24617ab8381cf88664d260e17552896a57","afterSHA256":"ebb98f4b24db403eca5d1d903cdc5d24617ab8381cf88664d260e17552896a57","reason":"Same source body in authored semantic page"},{"oldId":"b-c256da9939d0e3298ed3bb1f","targetId":"b-c256da9939d0e3298ed3bb1f","page":"reading-block-a913f088886f4de38fb1812ed586dc33","operation":"move","beforeSHA256":"bd9f02bebb512b1aac4ca28214e4d9e2f9af711b21502500271b99671765953a","afterSHA256":"bd9f02bebb512b1aac4ca28214e4d9e2f9af711b21502500271b99671765953a","reason":"Same source body in authored semantic page"},{"oldId":"b-70bc3e7057c0ba72168947ab","targetId":"b-70bc3e7057c0ba72168947ab","page":"reading-block-a913f088886f4de38fb1812ed586dc33","operation":"move","beforeSHA256":"77f4a7ed7148961ee8fe1e2027fc3b53295b9b0116ab4cfd4cbe97c508ad85e9","afterSHA256":"77f4a7ed7148961ee8fe1e2027fc3b53295b9b0116ab4cfd4cbe97c508ad85e9","reason":"Same source body in authored semantic page"},{"oldId":"b-3745242586e3caa695fa308a","targetId":"b-3745242586e3caa695fa308a","page":"reading-block-a913f088886f4de38fb1812ed586dc33","operation":"move","beforeSHA256":"dc41c5fec58b1b04f3a5a5fe8b0b61c9f5a61bc3be954bd37d1ea6a4295a2fde","afterSHA256":"dc41c5fec58b1b04f3a5a5fe8b0b61c9f5a61bc3be954bd37d1ea6a4295a2fde","reason":"Same source body in authored semantic page"},{"oldId":"b-6768021a6a9e66dd688ef3cf","targetId":"b-6768021a6a9e66dd688ef3cf","page":"reading-block-a913f088886f4de38fb1812ed586dc33","operation":"move","beforeSHA256":"e27a2d1698849889fa3cb6aaf3befb9741c7266a27dbbe57c496796886e53a38","afterSHA256":"e27a2d1698849889fa3cb6aaf3befb9741c7266a27dbbe57c496796886e53a38","reason":"Same source body in authored semantic page"},{"oldId":"b-a7839f17e85b7d80cbb2ce1f","targetId":"b-a7839f17e85b7d80cbb2ce1f","page":"reading-block-a913f088886f4de38fb1812ed586dc33","operation":"move","beforeSHA256":"6fda65bbb6f74e3e77a80496d57c79f6a7f3114e17a777b2f996a6f1874af583","afterSHA256":"6fda65bbb6f74e3e77a80496d57c79f6a7f3114e17a777b2f996a6f1874af583","reason":"Same source body in authored semantic page"},{"oldId":"b-0ae76de9fdce76c58ac76b93","targetId":"b-0ae76de9fdce76c58ac76b93","page":"reading-block-a913f088886f4de38fb1812ed586dc33","operation":"move","beforeSHA256":"8c292dce79eed500f2e77ca246f34cc348ca0fe5ef5ead4a6d1215ef9019eaae","afterSHA256":"8c292dce79eed500f2e77ca246f34cc348ca0fe5ef5ead4a6d1215ef9019eaae","reason":"Same source body in authored semantic page"},{"oldId":"b-63038113249cf18dea8bccc0","targetId":"b-63038113249cf18dea8bccc0","page":"reading-block-a913f088886f4de38fb1812ed586dc33","operation":"move","beforeSHA256":"526e7874f051e27d8639e7f2c0514a5a76bdac1b20ba8c44855862c44b788dad","afterSHA256":"526e7874f051e27d8639e7f2c0514a5a76bdac1b20ba8c44855862c44b788dad","reason":"Same source body in authored semantic page"},{"oldId":"b-f64c8f33e82a835a1ce6fb76","targetId":"b-f64c8f33e82a835a1ce6fb76","page":"reading-block-a913f088886f4de38fb1812ed586dc33","operation":"move","beforeSHA256":"50bf9d16729aff07026fc1fa39d756ef43a34e0ee654b4563b07f7f2581141a2","afterSHA256":"50bf9d16729aff07026fc1fa39d756ef43a34e0ee654b4563b07f7f2581141a2","reason":"Same source body in authored semantic page"},{"oldId":"b-10cd9d21562dae59c4a6e408","targetId":"b-10cd9d21562dae59c4a6e408","page":"reading-block-8f24850741144b31ac103742e94f7ecd","operation":"move","beforeSHA256":"05e7cc3e088ee4e59b8218982a40098c3dbdae3c8f0ca10282fe366a3bd82991","afterSHA256":"05e7cc3e088ee4e59b8218982a40098c3dbdae3c8f0ca10282fe366a3bd82991","reason":"Same source body in authored semantic page"},{"oldId":"b-2b5035afece27be078a5bcdd","targetId":"b-2b5035afece27be078a5bcdd","page":"reading-block-8f24850741144b31ac103742e94f7ecd","operation":"move","beforeSHA256":"870c939e2b073d1cbd378bda5ca800a161346c8d4796cd66133ef4e2328315a0","afterSHA256":"870c939e2b073d1cbd378bda5ca800a161346c8d4796cd66133ef4e2328315a0","reason":"Same source body in authored semantic page"},{"oldId":"b-9fe2f6c5063161e1244b764b","targetId":"b-9fe2f6c5063161e1244b764b","page":"reading-block-8f24850741144b31ac103742e94f7ecd","operation":"move","beforeSHA256":"f29b8ca82d736b7b79acf1ad9acf9124d7b36dae07d5aafd2c160eb74f7f6509","afterSHA256":"f29b8ca82d736b7b79acf1ad9acf9124d7b36dae07d5aafd2c160eb74f7f6509","reason":"Same source body in authored semantic page"},{"oldId":"b-ac571c6884ee52a1d6903408","targetId":"b-ac571c6884ee52a1d6903408","page":"reading-block-8f24850741144b31ac103742e94f7ecd","operation":"move","beforeSHA256":"2460f7aafadb5fd135823a52cfd6fcaa18b86c140e37264cb267459a6338b9b8","afterSHA256":"2460f7aafadb5fd135823a52cfd6fcaa18b86c140e37264cb267459a6338b9b8","reason":"Same source body in authored semantic page"},{"oldId":"b-55c44983e2ac2fa114771e88","targetId":"b-55c44983e2ac2fa114771e88","page":"reading-block-e40ebaef99ea481ea734c690ce85f20d","operation":"move","beforeSHA256":"fc6a0c525e9931316d757c82f13f0c09380475c17371090f5dfd3b3d22ad297e","afterSHA256":"fc6a0c525e9931316d757c82f13f0c09380475c17371090f5dfd3b3d22ad297e","reason":"Same source body in authored semantic page"},{"oldId":"b-ee9fdeb2fb9f3abdeac9316e","targetId":"b-ee9fdeb2fb9f3abdeac9316e","page":"reading-block-e40ebaef99ea481ea734c690ce85f20d","operation":"move","beforeSHA256":"8a733cf37d7a47cc493da01ba8d8fea0bd1d094a6e21f3fc205383ccc0c79049","afterSHA256":"8a733cf37d7a47cc493da01ba8d8fea0bd1d094a6e21f3fc205383ccc0c79049","reason":"Same source body in authored semantic page"},{"oldId":"b-58718bc54f5c4e0ee9fc1134","targetId":"b-58718bc54f5c4e0ee9fc1134","page":"reading-block-e40ebaef99ea481ea734c690ce85f20d","operation":"move","beforeSHA256":"078372d6f31856c31ffe61c9b2a9342763aaede2bf864c9ced63fa8080ee5156","afterSHA256":"54dfc76f35a4a399dcd1cc411d7156370a3d257d6937528aba087b3b3aaaadd3","reason":"Same source body in authored semantic page"},{"oldId":"b-7b3f3e40870cce4e09532f9b","targetId":"b-7b3f3e40870cce4e09532f9b","page":"reading-block-e40ebaef99ea481ea734c690ce85f20d","operation":"move","beforeSHA256":"fd7b1ea4e5626acb18bd365f5053b1867ea5b0b21962cb7ee1a8fc0a59211802","afterSHA256":"bbd713be3eb0316d1c91a573153ab103264b8ee6fbd92ddec04cd0b708637d0b","reason":"Same source body in authored semantic page"},{"oldId":"b-8765b7e2729993bd9a56ff0c","targetId":"b-8765b7e2729993bd9a56ff0c","page":"reading-block-e40ebaef99ea481ea734c690ce85f20d","operation":"move","beforeSHA256":"372d9cd877e39b6fb3cbd00ea79475d410d47acc18e267723be23d5995fb4ea6","afterSHA256":"d77aab495c80eb136858da9d881b37f94cdf29efe1c9ac455a23af826e814f48","reason":"Same source body in authored semantic page"},{"oldId":"b-7313dbb71185ddecd04a5340","targetId":"b-7313dbb71185ddecd04a5340","page":"reading-block-01778787c2ab4952b60963cbffd5b7c1","operation":"move","beforeSHA256":"0275f594bfdeff793c216d3ae029477ac23be2ba06aef0a1fdd00a301c326c99","afterSHA256":"0275f594bfdeff793c216d3ae029477ac23be2ba06aef0a1fdd00a301c326c99","reason":"Same source body in authored semantic page"},{"oldId":"b-343c8f3b441ccfd63f5ed7c2","targetId":"b-343c8f3b441ccfd63f5ed7c2","page":"reading-block-01778787c2ab4952b60963cbffd5b7c1","operation":"move","beforeSHA256":"6ff95e585147719b3e0f87ccfe14c93bc1747bc857cac639b8984dc6bee40715","afterSHA256":"6ff95e585147719b3e0f87ccfe14c93bc1747bc857cac639b8984dc6bee40715","reason":"Same source body in authored semantic page"},{"oldId":"b-fe4c064ad7ec41d6b99e2c39","targetId":"b-fe4c064ad7ec41d6b99e2c39","page":"reading-block-01778787c2ab4952b60963cbffd5b7c1","operation":"move","beforeSHA256":"1718e1bbf0c46a010b36c4464afbdce3baf82362119649cbefa63486b8b19683","afterSHA256":"1718e1bbf0c46a010b36c4464afbdce3baf82362119649cbefa63486b8b19683","reason":"Same source body in authored semantic page"},{"oldId":"block-f4deca9d4809465288f3a8e07e5320ab--1-坐标先说清连续-xyxy不加一","targetId":"b-4f286310079e5df55d17b588","operation":"retain-source-identity"},{"oldId":"block-311a83a867ee4c7dadefdaca58f5c533--2-训练分配和评价匹配解决两个问题","targetId":"b-7b179561dfef0ec24061f5aa","operation":"retain-source-identity"},{"oldId":"block-8eced6ce67e84d02929cf23760a5eb09--3-评价先降序再限制同一-gt-只用一次","targetId":"b-9cf3d7092ae0e5441798fdea","operation":"retain-source-identity"},{"oldId":"block-03a49740c8684af3bd417c1030853845--4-ap-必须说明积分协议","targetId":"b-bc1de362eb57aa58185321d8","operation":"retain-source-identity"},{"oldId":"block-cf51f5d05100404d88c27df74895324d--5-nms-的阈值不是评价的阈值","targetId":"b-268ac124429a2d26908f206c","operation":"retain-source-identity"},{"oldId":"block-0a71ec88a039404fbc98fde29df4fe9d--6-反例相邻真实对象被-nms-合并","targetId":"b-e98f3f34077fd31350d38c1f","operation":"retain-source-identity"},{"oldId":"block-ba39de56ef7d4d2882d9441ecd6d1424--可视化与实际输出","targetId":"b-c77ea7195466ecbb6a57ae76","operation":"retain-source-identity"},{"oldId":"block-a913f088886f4de38fb1812ed586dc33--7-只改一个条件并用结果回答","targetId":"b-b9ebdd7f83987d2976039760","operation":"retain-source-identity"},{"oldId":"block-8f24850741144b31ac103742e94f7ecd--来源与范围","targetId":"b-10cd9d21562dae59c4a6e408","operation":"retain-source-identity"},{"oldId":"block-e40ebaef99ea481ea734c690ce85f20d--本次基准的静态图","targetId":"b-55c44983e2ac2fa114771e88","operation":"retain-source-identity"},{"oldId":"block-01778787c2ab4952b60963cbffd5b7c1--运行记录","targetId":"b-7313dbb71185ddecd04a5340","operation":"retain-source-identity"}],"blocks":[{"id":"b-52c9fc30c97ef14eb318f0d5","type":"h1","scope":"document","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-52c9fc30c97ef14eb318f0d5","content":"# LAB 09 · 检测几何：框、匹配、NMS 与 AP","sha256":"209faa721c10831b9a840959831aa235dd1d2460e3fe9d584c9e7ae9cd60a827","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-opening","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","number":1},"sectionTitle":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","currentQuestion":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":null,"nextBlock":"b-560cb3ae3fb4379dd9dc3add","prerequisites":[{"id":"b-560cb3ae3fb4379dd9dc3add","url":"#b-560cb3ae3fb4379dd9dc3add","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-560cb3ae3fb4379dd9dc3add","type":"p","scope":"document","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-560cb3ae3fb4379dd9dc3add","content":"并入相关学习路径","sha256":"dc06c1e728a4b5740ba634b145bc9a1da6323031626734cb4555db5a744df806","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-opening","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","number":1},"sectionTitle":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","currentQuestion":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-52c9fc30c97ef14eb318f0d5","nextBlock":"b-dc9655b5cabadc3f23a3fc7e","prerequisites":[{"id":"b-52c9fc30c97ef14eb318f0d5","url":"#b-52c9fc30c97ef14eb318f0d5","role":"section-title"}],"relatedBlocks":[]},{"id":"b-dc9655b5cabadc3f23a3fc7e","type":"p","scope":"document","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-dc9655b5cabadc3f23a3fc7e","content":"固定框匹配、PR/AP、NMS误删相邻对象反例","sha256":"4e0de6d032a3765c60907de32f28cd988b659299663e842d319bdb0426243d78","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-opening","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","number":1},"sectionTitle":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","currentQuestion":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-560cb3ae3fb4379dd9dc3add","nextBlock":"b-4ca13a107149721472214190","prerequisites":[{"id":"b-52c9fc30c97ef14eb318f0d5","url":"#b-52c9fc30c97ef14eb318f0d5","role":"section-title"},{"id":"b-560cb3ae3fb4379dd9dc3add","url":"#b-560cb3ae3fb4379dd9dc3add","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-4ca13a107149721472214190","type":"p","scope":"document","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-4ca13a107149721472214190","content":"可先阅读已有结果，再决定是否运行。重算时请核对各节记录的数据、参数、环境与日期。","sha256":"f22152fd55dcdb0090b5653d37145694fd19388d31e10226549464fe8b483578","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-opening","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","number":1},"sectionTitle":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","currentQuestion":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-dc9655b5cabadc3f23a3fc7e","nextBlock":"b-ef46931cecd460ceb981d0c5","prerequisites":[{"id":"b-52c9fc30c97ef14eb318f0d5","url":"#b-52c9fc30c97ef14eb318f0d5","role":"section-title"},{"id":"b-560cb3ae3fb4379dd9dc3add","url":"#b-560cb3ae3fb4379dd9dc3add","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-ef46931cecd460ceb981d0c5","type":"p","scope":"block-bd1bc858091e46a9b05ab50b784fbf79","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-ef46931cecd460ceb981d0c5","content":"**学习路径：** [一张图怎样变成一组框](/course/study/image-detection.html)","sha256":"93899883c4c044ee5171cc6d4515e67b10961c3d3e67eb507245ef30c5e625ce","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-opening","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","number":1},"sectionTitle":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","currentQuestion":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-4ca13a107149721472214190","nextBlock":"b-003ba62c958308c30c36c63d","prerequisites":[{"id":"b-52c9fc30c97ef14eb318f0d5","url":"#b-52c9fc30c97ef14eb318f0d5","role":"section-title"},{"id":"b-560cb3ae3fb4379dd9dc3add","url":"#b-560cb3ae3fb4379dd9dc3add","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-003ba62c958308c30c36c63d","type":"p","scope":"block-bd1bc858091e46a9b05ab50b784fbf79","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-003ba62c958308c30c36c63d","content":"本册是 [LAB 10](https://deepnote.com/project/38755e4e-23f6-4f5f-8c68-8a2e4114b1c1/notebook/a14237bfa9dd413d959ab4e458e11f42) 的检测几何工作台：固定框和分数，分别计算训练分配、评价匹配、NMS 和 AP。它不训练图像模型，对应 [P33–35](/course/pages/l3-r2-p33.html)。","sha256":"f28364b1233566346e48e49d084d5f0cc291640d6e9914b099471d0bb06d7679","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-opening","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","number":1},"sectionTitle":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","currentQuestion":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-ef46931cecd460ceb981d0c5","nextBlock":"b-931134070a50d532e044f7dc","prerequisites":[{"id":"b-52c9fc30c97ef14eb318f0d5","url":"#b-52c9fc30c97ef14eb318f0d5","role":"section-title"},{"id":"b-560cb3ae3fb4379dd9dc3add","url":"#b-560cb3ae3fb4379dd9dc3add","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-931134070a50d532e044f7dc","type":"p","scope":"block-bd1bc858091e46a9b05ab50b784fbf79","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-931134070a50d532e044f7dc","content":"初读只选一件事：第 1 节核坐标与 IoU；第 3–4 节追踪重复框和 AP；第 5–6 节比较 NMS 去重与误删相邻对象。深入定义在 [CLS 07](https://deepnote.com/project/38755e4e-23f6-4f5f-8c68-8a2e4114b1c1/notebook/586e66e049764158a50747e69c219312)，可直接引用 [AP 排序积分](/course/blocks/ap-ranking-example.html) 和 [NMS 与匹配的区别](/course/blocks/nms-versus-matching.html)。","sha256":"6c6093974ebe6135790caf23d0e8fc40206621d1f22642ea46bc60685415b026","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-opening","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","number":1},"sectionTitle":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","currentQuestion":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-003ba62c958308c30c36c63d","nextBlock":"b-a42f53c0da5e8dfd0235d015","prerequisites":[{"id":"b-52c9fc30c97ef14eb318f0d5","url":"#b-52c9fc30c97ef14eb318f0d5","role":"section-title"},{"id":"b-560cb3ae3fb4379dd9dc3add","url":"#b-560cb3ae3fb4379dd9dc3add","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-a42f53c0da5e8dfd0235d015","type":"p","scope":"block-bd1bc858091e46a9b05ab50b784fbf79","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-a42f53c0da5e8dfd0235d015","content":"做完保留一项“只改分数”或“只改 NMS 阈值”的对照，解释 precision/recall/AP 哪个量变了以及原因。若复跑，函数有先后依赖，需从环境格按序执行；绘图和运行记录可以折叠阅读。","sha256":"2f80e817658c268f089a988357a6c1f428daa096b546a028a09cb40692d214a4","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-opening","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","number":1},"sectionTitle":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","currentQuestion":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-931134070a50d532e044f7dc","nextBlock":"b-eb31a8816fe8ba5890d1ea77","prerequisites":[{"id":"b-52c9fc30c97ef14eb318f0d5","url":"#b-52c9fc30c97ef14eb318f0d5","role":"section-title"},{"id":"b-560cb3ae3fb4379dd9dc3add","url":"#b-560cb3ae3fb4379dd9dc3add","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-eb31a8816fe8ba5890d1ea77","type":"pre","scope":"block-464a6a439b674b42bdf6e18175401eee","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-eb31a8816fe8ba5890d1ea77","content":"```\nimport os, tempfile\nfrom pathlib import Path\n# Isolated ephemeral workspace supports detached runs with readonly project storage.\nSPATIAL_RUN_DIR = Path(tempfile.mkdtemp(prefix='lecture03-'))\nos.chdir(SPATIAL_RUN_DIR)\nprint('Ephemeral experiment directory:', SPATIAL_RUN_DIR)\n```","sha256":"bad2300d993a83e0bd2f5f97d8bebdf04b9365e535f41eed4cdd34f598052b42","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-opening","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","number":1},"sectionTitle":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","currentQuestion":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-a42f53c0da5e8dfd0235d015","nextBlock":"b-a80e5d457e6a5301a1fd7a76","prerequisites":[{"id":"b-52c9fc30c97ef14eb318f0d5","url":"#b-52c9fc30c97ef14eb318f0d5","role":"section-title"},{"id":"b-560cb3ae3fb4379dd9dc3add","url":"#b-560cb3ae3fb4379dd9dc3add","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-a80e5d457e6a5301a1fd7a76","type":"pre","scope":"block-594bc8e645d4447c9c7e522cc8f9a03f","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-a80e5d457e6a5301a1fd7a76","content":"```\nfrom pathlib import Path\nfrom datetime import datetime, timezone\nimport hashlib\nimport json\nimport platform\nimport time\nfrom html import escape\nimport numpy as np\n\nSTARTED_AT = datetime.now(timezone.utc).isoformat()\nSTARTED_CLOCK = time.perf_counter()\nOUT = Path(__file__).resolve().parent if \"__file__\" in globals() else Path.cwd()\nOUT.mkdir(parents=True, exist_ok=True)\nNMS_THRESHOLD = 0.50\nEVAL_THRESHOLDS = (0.50, 0.75)\n\nGT = np.array([[0, 0, 2, 2], [3, 0, 5, 2]], dtype=float)\nPRED = np.array([[0, 0, 2, 2], [.2, 0, 2.2, 2], [3.4, 0, 5.4, 2], [7, 7, 8, 8]], float)\nSCORES = np.array([.9, .8, .7, .4])\nCLASSES = np.zeros(4, dtype=int)\n```","sha256":"17c087970008ebd0875576f6551258d8c6f5e701a79682f7055b68e8e0a4fa4e","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-opening","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","number":1},"sectionTitle":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","currentQuestion":"LAB 09 · 检测几何：框、匹配、NMS 与 AP","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-eb31a8816fe8ba5890d1ea77","nextBlock":null,"prerequisites":[{"id":"b-52c9fc30c97ef14eb318f0d5","url":"#b-52c9fc30c97ef14eb318f0d5","role":"section-title"},{"id":"b-560cb3ae3fb4379dd9dc3add","url":"#b-560cb3ae3fb4379dd9dc3add","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-4f286310079e5df55d17b588","type":"h2","scope":"block-f4deca9d4809465288f3a8e07e5320ab","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-4f286310079e5df55d17b588","content":"## 1 · 坐标先说清：连续 xyxy，不加一","sha256":"21076e4abea8f5cd82f25d6a598814bfec6eaba3bb54f3eabba22659c6776ae3","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-f4deca9d4809465288f3a8e07e5320ab","title":"1 · 坐标先说清：连续 xyxy，不加一","number":2},"sectionTitle":"1 · 坐标先说清：连续 xyxy，不加一","currentQuestion":"1 · 坐标先说清：连续 xyxy，不加一","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":null,"nextBlock":"b-571896439523ccbe7f147778","prerequisites":[{"id":"b-571896439523ccbe7f147778","url":"#b-571896439523ccbe7f147778","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-571896439523ccbe7f147778","type":"p","scope":"block-f4deca9d4809465288f3a8e07e5320ab","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-571896439523ccbe7f147778","content":"框写成 `(x1, y1, x2, y2)`，表示连续坐标边界。宽为 `max(0, x2-x1)`，高为 `max(0, y2-y1)`；面积计算不使用像素闭区间的 `+1`。本实验允许零面积框，其零并集 IoU 约定为 0；拒绝倒置坐标和非有限数。","sha256":"73314c0b5f6c68187c132a49ce5ec92805418dcafd685a6e071a19f1a7e65f7e","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-f4deca9d4809465288f3a8e07e5320ab","title":"1 · 坐标先说清：连续 xyxy，不加一","number":2},"sectionTitle":"1 · 坐标先说清：连续 xyxy，不加一","currentQuestion":"1 · 坐标先说清：连续 xyxy，不加一","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-4f286310079e5df55d17b588","nextBlock":"b-7be6714cea43d13246761f29","prerequisites":[{"id":"b-4f286310079e5df55d17b588","url":"#b-4f286310079e5df55d17b588","role":"section-title"}],"relatedBlocks":[]},{"id":"b-7be6714cea43d13246761f29","type":"p","scope":"block-f4deca9d4809465288f3a8e07e5320ab","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-7be6714cea43d13246761f29","content":"两框交集的左上角是两组左上角的逐坐标最大值，右下角是两组右下角的逐坐标最小值；先把交集宽高截断到非负，再相乘。","sha256":"2683a32e2a00b9ecc1ef56166562235cbd20019a57f5f8dbac8d5397a3cd5e93","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-f4deca9d4809465288f3a8e07e5320ab","title":"1 · 坐标先说清：连续 xyxy，不加一","number":2},"sectionTitle":"1 · 坐标先说清：连续 xyxy，不加一","currentQuestion":"1 · 坐标先说清：连续 xyxy，不加一","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-571896439523ccbe7f147778","nextBlock":"b-13290047cae24859094ab666","prerequisites":[{"id":"b-4f286310079e5df55d17b588","url":"#b-4f286310079e5df55d17b588","role":"section-title"},{"id":"b-571896439523ccbe7f147778","url":"#b-571896439523ccbe7f147778","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-13290047cae24859094ab666","type":"p","scope":"block-f4deca9d4809465288f3a8e07e5320ab","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-13290047cae24859094ab666","content":"$\n\\operatorname{IoU}(A,B)=\\frac{|A\\cap B|}{|A|+|B|-|A\\cap B|}.\n$","sha256":"8b96012fb03fc821f04d51253862ec1c5a096ed1689281fa6211b7c3e3f94e8e","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-f4deca9d4809465288f3a8e07e5320ab","title":"1 · 坐标先说清：连续 xyxy，不加一","number":2},"sectionTitle":"1 · 坐标先说清：连续 xyxy，不加一","currentQuestion":"1 · 坐标先说清：连续 xyxy，不加一","sourceSlides":[],"knowledgeBlock":null,"formulas":[{"latex":"\n\\operatorname{IoU}(A,B)=\\frac{|A\\cap B|}{|A|+|B|-|A\\cap B|}.\n","definitionContext":"1 · 坐标先说清：连续 xyxy，不加一"}],"previousBlock":"b-7be6714cea43d13246761f29","nextBlock":"b-f0700206a916142e6f76eaa1","prerequisites":[{"id":"b-4f286310079e5df55d17b588","url":"#b-4f286310079e5df55d17b588","role":"section-title"},{"id":"b-571896439523ccbe7f147778","url":"#b-571896439523ccbe7f147778","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-f0700206a916142e6f76eaa1","type":"p","scope":"block-f4deca9d4809465288f3a8e07e5320ab","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-f0700206a916142e6f76eaa1","content":"GT1=`(0,0,2,2)`，GT2=`(3,0,5,2)`，面积均为 4。所有预测属于同一类别；分数用于排名，不是本例的真实正确概率。","sha256":"af61996706cdb052e01330c6eda59067209ebdf75ccd8febb9390e2a7792c351","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-f4deca9d4809465288f3a8e07e5320ab","title":"1 · 坐标先说清：连续 xyxy，不加一","number":2},"sectionTitle":"1 · 坐标先说清：连续 xyxy，不加一","currentQuestion":"1 · 坐标先说清：连续 xyxy，不加一","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-13290047cae24859094ab666","nextBlock":"b-d0881369f3f6d3d84b171838","prerequisites":[{"id":"b-4f286310079e5df55d17b588","url":"#b-4f286310079e5df55d17b588","role":"section-title"},{"id":"b-571896439523ccbe7f147778","url":"#b-571896439523ccbe7f147778","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-d0881369f3f6d3d84b171838","type":"table","scope":"block-f4deca9d4809465288f3a8e07e5320ab","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-d0881369f3f6d3d84b171838","content":"| 预测 | 分数 | xyxy | 与 GT1 的 IoU | 与 GT2 的 IoU |\n| --- | --- | --- | --- | --- |\n| P1 | 0.90 | `(0,0,2,2)` | 1 | 0 |\n| P2 | 0.80 | `(0.2,0,2.2,2)` | 9/11 ≈ 0.818182 | 0 |\n| P3 | 0.70 | `(3.4,0,5.4,2)` | 0 | 2/3 ≈ 0.666667 |\n| P4 | 0.40 | `(7,7,8,8)` | 0 | 0 |","sha256":"35a40a3a234c22feca0b20bd3d34f8577540de706a652116d01a4649dd3828d6","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-f4deca9d4809465288f3a8e07e5320ab","title":"1 · 坐标先说清：连续 xyxy，不加一","number":2},"sectionTitle":"1 · 坐标先说清：连续 xyxy，不加一","currentQuestion":"1 · 坐标先说清：连续 xyxy，不加一","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"table":{"headers":["预测","分数","xyxy","与 GT1 的 IoU","与 GT2 的 IoU"],"rows":[["预测","分数","xyxy","与 GT1 的 IoU","与 GT2 的 IoU"],["P1","0.90","(0,0,2,2)","1","0"],["P2","0.80","(0.2,0,2.2,2)","9/11 ≈ 0.818182","0"],["P3","0.70","(3.4,0,5.4,2)","0","2/3 ≈ 0.666667"],["P4","0.40","(7,7,8,8)","0","0"]]},"previousBlock":"b-f0700206a916142e6f76eaa1","nextBlock":"b-65b2c3745ca90af73dff6d8d","prerequisites":[{"id":"b-4f286310079e5df55d17b588","url":"#b-4f286310079e5df55d17b588","role":"section-title"},{"id":"b-571896439523ccbe7f147778","url":"#b-571896439523ccbe7f147778","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-65b2c3745ca90af73dff6d8d","type":"p","scope":"block-f4deca9d4809465288f3a8e07e5320ab","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-65b2c3745ca90af73dff6d8d","content":"输入 shape 为 GT `(2,4)`、预测 `(4,4)`、分数 `(4,)`。广播计算得到 `(4,2)` IoU 矩阵：**行是预测，列是真值**。手算 P2：交集 `1.8×2=3.6`，并集 `4+4−3.6=4.4`，所以 IoU=`3.6/4.4=9/11`。P3 的交集为 `1.6×2=3.2`，并集为 `4.8`。","sha256":"e8b5bc561f95fe7d998094b3035a96396e130dfc1284db851b8cae49b946121d","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-f4deca9d4809465288f3a8e07e5320ab","title":"1 · 坐标先说清：连续 xyxy，不加一","number":2},"sectionTitle":"1 · 坐标先说清：连续 xyxy，不加一","currentQuestion":"1 · 坐标先说清：连续 xyxy，不加一","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-d0881369f3f6d3d84b171838","nextBlock":"b-64db71ce67d37d52e100bfcf","prerequisites":[{"id":"b-4f286310079e5df55d17b588","url":"#b-4f286310079e5df55d17b588","role":"section-title"},{"id":"b-571896439523ccbe7f147778","url":"#b-571896439523ccbe7f147778","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-64db71ce67d37d52e100bfcf","type":"p","scope":"block-f4deca9d4809465288f3a8e07e5320ab","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-64db71ce67d37d52e100bfcf","content":"下方代码先核对 IoU 矩阵；最后的可视化代码格会显示坐标图。","sha256":"e04a8536c1317db4a8d0e06468ab965d641b49127c7cfedb01371925529420cc","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-f4deca9d4809465288f3a8e07e5320ab","title":"1 · 坐标先说清：连续 xyxy，不加一","number":2},"sectionTitle":"1 · 坐标先说清：连续 xyxy，不加一","currentQuestion":"1 · 坐标先说清：连续 xyxy，不加一","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-65b2c3745ca90af73dff6d8d","nextBlock":"b-f42009d3f839f23dd4248f36","prerequisites":[{"id":"b-4f286310079e5df55d17b588","url":"#b-4f286310079e5df55d17b588","role":"section-title"},{"id":"b-571896439523ccbe7f147778","url":"#b-571896439523ccbe7f147778","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-f42009d3f839f23dd4248f36","type":"pre","scope":"block-6694e8372194400db0397906978305bf","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-f42009d3f839f23dd4248f36","content":"```\ndef boxes_xyxy(values):\n    \"\"\"Validate an (N,4) array of continuous-coordinate boxes.\"\"\"\n    boxes = np.asarray(values, dtype=float).reshape(-1, 4)\n    if not np.isfinite(boxes).all():\n        raise ValueError(\"Box coordinates must be finite\")\n    if np.any(boxes[:, 2:] < boxes[:, :2]):\n        raise ValueError(\"Require x2 >= x1 and y2 >= y1\")\n    return boxes\n\n\ndef box_iou(boxes_a, boxes_b):\n    \"\"\"Return (N,M) IoUs. A zero-area union is defined to have IoU 0.\"\"\"\n    a, b = boxes_xyxy(boxes_a), boxes_xyxy(boxes_b)\n    intersection_size = np.maximum(\n        0.0, np.minimum(a[:, None, 2:], b[None, :, 2:])\n        - np.maximum(a[:, None, :2], b[None, :, :2])\n    )\n    intersection = intersection_size.prod(axis=2)\n    area_a = (a[:, 2:] - a[:, :2]).prod(axis=1)\n    area_b = (b[:, 2:] - b[:, :2]).prod(axis=1)\n    union = area_a[:, None] + area_b[None, :] - intersection\n    return np.divide(intersection, union, out=np.zeros_like(union), where=union > 0)\n\nprint(\"IoU shape:\", box_iou(PRED, GT).shape)\nprint(box_iou(PRED, GT))\n```","sha256":"343c55023905db6d14465285570aee76e293e598d8f7c7336ce93561c05ae916","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-f4deca9d4809465288f3a8e07e5320ab","title":"1 · 坐标先说清：连续 xyxy，不加一","number":2},"sectionTitle":"1 · 坐标先说清：连续 xyxy，不加一","currentQuestion":"1 · 坐标先说清：连续 xyxy，不加一","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-64db71ce67d37d52e100bfcf","nextBlock":null,"prerequisites":[{"id":"b-4f286310079e5df55d17b588","url":"#b-4f286310079e5df55d17b588","role":"section-title"},{"id":"b-571896439523ccbe7f147778","url":"#b-571896439523ccbe7f147778","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-7b179561dfef0ec24061f5aa","type":"h2","scope":"block-311a83a867ee4c7dadefdaca58f5c533","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-7b179561dfef0ec24061f5aa","content":"## 2 · 训练分配和评价匹配解决两个问题","sha256":"4433849b997a41e1acfa0f691767522233318857b7f413c0cbb27a86e43e4d2f","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-311a83a867ee4c7dadefdaca58f5c533","title":"2 · 训练分配和评价匹配解决两个问题","number":3},"sectionTitle":"2 · 训练分配和评价匹配解决两个问题","currentQuestion":"2 · 训练分配和评价匹配解决两个问题","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":null,"nextBlock":"b-b4e7d8a654b8949ed0fc9ada","prerequisites":[{"id":"b-b4e7d8a654b8949ed0fc9ada","url":"#b-b4e7d8a654b8949ed0fc9ada","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-b4e7d8a654b8949ed0fc9ada","type":"p","scope":"block-311a83a867ee4c7dadefdaca58f5c533","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-b4e7d8a654b8949ed0fc9ada","content":"本例的训练分配采用 D2L anchor 教学规则：先把与某个 GT 的最大 IoU **≥0.50** 的 anchor 分配给该 GT；再逐次选择剩余 IoU 矩阵的最大项，移除对应行列，强制为每个 GT 保留一个不同的 anchor。此例假定 anchor 数不少于 GT 数，未引入真实检测器可能使用的忽略区间、采样比例或动态分配。","sha256":"755a6f55f11d7f46e909c7704d72c9fffcd894cd9cff7bf5cdadb6082f074f1f","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-311a83a867ee4c7dadefdaca58f5c533","title":"2 · 训练分配和评价匹配解决两个问题","number":3},"sectionTitle":"2 · 训练分配和评价匹配解决两个问题","currentQuestion":"2 · 训练分配和评价匹配解决两个问题","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-7b179561dfef0ec24061f5aa","nextBlock":"b-2c11cb9bd9ad5c6a777f811d","prerequisites":[{"id":"b-7b179561dfef0ec24061f5aa","url":"#b-7b179561dfef0ec24061f5aa","role":"section-title"}],"relatedBlocks":[]},{"id":"b-2c11cb9bd9ad5c6a777f811d","type":"table","scope":"block-311a83a867ee4c7dadefdaca58f5c533","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-2c11cb9bd9ad5c6a777f811d","content":"| 项目 | 训练 anchor 目标分配 | 本例的评价匹配 |\n| --- | --- | --- |\n| 要回答的问题 | 哪些候选框应学习哪个对象？ | 已输出的哪些预测算正确检测？ |\n| 主要输入 | anchor 与 GT 的几何关系 | 预测分数、预测框与 GT |\n| 一个 GT 可对应几个框 | 可以多个正样本 | 在同一图像、同一类别、同一评价阈值下最多一个 TP |\n| 是否按预测分数排序 | 本例不使用预测分数 | 按分数降序，平分保留输入顺序 |\n| 低 IoU 是否可能被选中 | 强制覆盖步骤可能选中 | 必须满足指定评价 IoU 阈值 |","sha256":"eecc89f3790c3d3f5053398086d05a17847f61917aded6703a005232270b4e85","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-311a83a867ee4c7dadefdaca58f5c533","title":"2 · 训练分配和评价匹配解决两个问题","number":3},"sectionTitle":"2 · 训练分配和评价匹配解决两个问题","currentQuestion":"2 · 训练分配和评价匹配解决两个问题","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"table":{"headers":["项目","训练 anchor 目标分配","本例的评价匹配"],"rows":[["项目","训练 anchor 目标分配","本例的评价匹配"],["要回答的问题","哪些候选框应学习哪个对象？","已输出的哪些预测算正确检测？"],["主要输入","anchor 与 GT 的几何关系","预测分数、预测框与 GT"],["一个 GT 可对应几个框","可以多个正样本","在同一图像、同一类别、同一评价阈值下最多一个 TP"],["是否按预测分数排序","本例不使用预测分数","按分数降序，平分保留输入顺序"],["低 IoU 是否可能被选中","强制覆盖步骤可能选中","必须满足指定评价 IoU 阈值"]]},"previousBlock":"b-b4e7d8a654b8949ed0fc9ada","nextBlock":"b-256402efee2811b83d00227b","prerequisites":[{"id":"b-7b179561dfef0ec24061f5aa","url":"#b-7b179561dfef0ec24061f5aa","role":"section-title"},{"id":"b-b4e7d8a654b8949ed0fc9ada","url":"#b-b4e7d8a654b8949ed0fc9ada","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-256402efee2811b83d00227b","type":"p","scope":"block-311a83a867ee4c7dadefdaca58f5c533","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-256402efee2811b83d00227b","content":"为方便对照，代码临时把四个预测的坐标用作四个 anchor 的几何输入，**并未把预测分数用于训练分配**。得到 `[GT1, GT1, GT2, 背景]`；P1/P2 两处几何位置可以共同学习 GT1。另一个低重叠例子中，两个强制正样本与相应 GT 的 IoU 分别只有 **0.1225 和 0.09**，清楚说明“训练中被分配”不等于“评价中定位合格”。","sha256":"6cedae1442df6dfca8fdc91a281213522c06ddf7dbda7203ecf19a1399323951","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-311a83a867ee4c7dadefdaca58f5c533","title":"2 · 训练分配和评价匹配解决两个问题","number":3},"sectionTitle":"2 · 训练分配和评价匹配解决两个问题","currentQuestion":"2 · 训练分配和评价匹配解决两个问题","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-2c11cb9bd9ad5c6a777f811d","nextBlock":"b-07f6322030efe4d4a0a4c2e5","prerequisites":[{"id":"b-7b179561dfef0ec24061f5aa","url":"#b-7b179561dfef0ec24061f5aa","role":"section-title"},{"id":"b-b4e7d8a654b8949ed0fc9ada","url":"#b-b4e7d8a654b8949ed0fc9ada","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-07f6322030efe4d4a0a4c2e5","type":"p","scope":"block-311a83a867ee4c7dadefdaca58f5c533","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-07f6322030efe4d4a0a4c2e5","content":"这是一种 anchor 分配规则。其他检测器可能使用一对一集合匹配、不同阈值或动态分配；不能把本例规则推广为所有检测器。","sha256":"f5a49456f54158c5f78062ed00e18cdb1908f830a246d85938dfbda2e2a1edbc","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-311a83a867ee4c7dadefdaca58f5c533","title":"2 · 训练分配和评价匹配解决两个问题","number":3},"sectionTitle":"2 · 训练分配和评价匹配解决两个问题","currentQuestion":"2 · 训练分配和评价匹配解决两个问题","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-256402efee2811b83d00227b","nextBlock":"b-2ced4bbd51bd7924020831dc","prerequisites":[{"id":"b-7b179561dfef0ec24061f5aa","url":"#b-7b179561dfef0ec24061f5aa","role":"section-title"},{"id":"b-b4e7d8a654b8949ed0fc9ada","url":"#b-b4e7d8a654b8949ed0fc9ada","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-2ced4bbd51bd7924020831dc","type":"pre","scope":"block-ef7e83a286ba4b14912267d87243dc13","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-2ced4bbd51bd7924020831dc","content":"```\ndef assign_training_anchors(anchors, gt_boxes, positive_iou=0.50):\n    \"\"\"D2L-style target assignment: threshold positives + forced GT coverage.\n\n    One anchor has at most one GT, but several anchors may target the same GT.\n    Returns GT index per anchor (-1 means background in this simplified lab).\n    Scores and predicted classes are intentionally absent from the inputs.\n    \"\"\"\n    if not 0 <= positive_iou <= 1:\n        raise ValueError(\"positive_iou must be in [0,1]\")\n    ious = box_iou(anchors, gt_boxes)\n    n_anchor, n_gt = ious.shape\n    assigned = np.full(n_anchor, -1, dtype=int)\n    forced = np.zeros(n_anchor, dtype=bool)\n    if n_gt == 0:\n        return assigned, forced\n    if n_anchor < n_gt:\n        raise ValueError(\"Forced GT coverage requires anchors >= GTs\")\n    best_gt = ious.argmax(axis=1)\n    best_iou = ious[np.arange(n_anchor), best_gt]\n    positive = best_iou >= positive_iou\n    assigned[positive] = best_gt[positive]\n    remaining = ious.copy()\n    for _ in range(n_gt):\n        anchor_i, gt_i = np.unravel_index(np.argmax(remaining), remaining.shape)\n        assigned[anchor_i] = gt_i\n        forced[anchor_i] = True\n        remaining[anchor_i, :] = -1.0\n        remaining[:, gt_i] = -1.0\n    return assigned, forced\n\nprint(\"0-based GT targets (-1=background):\", assign_training_anchors(PRED, GT)[0])\n```","sha256":"2255662c7f11f30dc784b35f6dbd86c8f8eb4e4be25419eb2f70503c20798c9b","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-311a83a867ee4c7dadefdaca58f5c533","title":"2 · 训练分配和评价匹配解决两个问题","number":3},"sectionTitle":"2 · 训练分配和评价匹配解决两个问题","currentQuestion":"2 · 训练分配和评价匹配解决两个问题","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-07f6322030efe4d4a0a4c2e5","nextBlock":null,"prerequisites":[{"id":"b-7b179561dfef0ec24061f5aa","url":"#b-7b179561dfef0ec24061f5aa","role":"section-title"},{"id":"b-b4e7d8a654b8949ed0fc9ada","url":"#b-b4e7d8a654b8949ed0fc9ada","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-9cf3d7092ae0e5441798fdea","type":"h2","scope":"block-8eced6ce67e84d02929cf23760a5eb09","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-9cf3d7092ae0e5441798fdea","content":"## 3 · 评价先降序，再限制同一 GT 只用一次","sha256":"1c70ccc601b66fd4935e666d10860b852e24341043463d5535a43c9ebd01fd17","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-8eced6ce67e84d02929cf23760a5eb09","title":"3 · 评价先降序，再限制同一 GT 只用一次","number":4},"sectionTitle":"3 · 评价先降序，再限制同一 GT 只用一次","currentQuestion":"3 · 评价先降序，再限制同一 GT 只用一次","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":null,"nextBlock":"b-d646afa26506d5a68d080326","prerequisites":[{"id":"b-d646afa26506d5a68d080326","url":"#b-d646afa26506d5a68d080326","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-d646afa26506d5a68d080326","type":"p","scope":"block-8eced6ce67e84d02929cf23760a5eb09","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-d646afa26506d5a68d080326","content":"本例与 LAB10 统一使用 **VOC 风格的贪心对应规则**：对每个预测，先在该图像、该类别的全部 GT 中找 IoU 最大者，再检查它是否满足阈值且未被使用。若最大 IoU 的 GT 已被使用，就记为重复 FP，**不转而匹配次高 IoU 的未用 GT**。评价 IoU 阈值是 **≥**，分别使用 0.50 与 0.75；平分时保留输入顺序。两个阈值独立评价，各自从空的已匹配集合开始。这里只借用该匹配思路，不声称复现完整 VOC 评估器。","sha256":"187ff0706207a267d1a1a419d7adb53cfe2c27a351b6952d8aafa177975d1168","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-8eced6ce67e84d02929cf23760a5eb09","title":"3 · 评价先降序，再限制同一 GT 只用一次","number":4},"sectionTitle":"3 · 评价先降序，再限制同一 GT 只用一次","currentQuestion":"3 · 评价先降序，再限制同一 GT 只用一次","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-9cf3d7092ae0e5441798fdea","nextBlock":"b-95ffd2b5ffe5ac209447a51f","prerequisites":[{"id":"b-9cf3d7092ae0e5441798fdea","url":"#b-9cf3d7092ae0e5441798fdea","role":"section-title"}],"relatedBlocks":[]},{"id":"b-95ffd2b5ffe5ac209447a51f","type":"table","scope":"block-8eced6ce67e84d02929cf23760a5eb09","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-95ffd2b5ffe5ac209447a51f","content":"| 排名/预测 | AP50 结果与理由 | 累计 precision | 累计 recall | AP75 结果 |\n| --- | --- | --- | --- | --- |\n| 1 / P1 | TP：首次匹配 GT1 | 1 | 1/2 | TP |\n| 2 / P2 | FP：符合几何阈值的 GT1 已被使用 | 1/2 | 1/2 | FP：重复 |\n| 3 / P3 | TP：首次匹配 GT2 | 2/3 | 1 | FP：2/3 < 0.75 |\n| 4 / P4 | FP：没有满足阈值的 GT | 1/2 | 1 | FP |","sha256":"bf08f9275b1e87a5e3aacdf42f1959271f41fbd1c7d717274ff8a06355e53cb9","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-8eced6ce67e84d02929cf23760a5eb09","title":"3 · 评价先降序，再限制同一 GT 只用一次","number":4},"sectionTitle":"3 · 评价先降序，再限制同一 GT 只用一次","currentQuestion":"3 · 评价先降序，再限制同一 GT 只用一次","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"table":{"headers":["排名/预测","AP50 结果与理由","累计 precision","累计 recall","AP75 结果"],"rows":[["排名/预测","AP50 结果与理由","累计 precision","累计 recall","AP75 结果"],["1 / P1","TP：首次匹配 GT1","1","1/2","TP"],["2 / P2","FP：符合几何阈值的 GT1 已被使用","1/2","1/2","FP：重复"],["3 / P3","TP：首次匹配 GT2","2/3","1","FP：2/3 < 0.75"],["4 / P4","FP：没有满足阈值的 GT","1/2","1","FP"]]},"previousBlock":"b-d646afa26506d5a68d080326","nextBlock":"b-6358bf68f4cda41a3ef179e7","prerequisites":[{"id":"b-9cf3d7092ae0e5441798fdea","url":"#b-9cf3d7092ae0e5441798fdea","role":"section-title"},{"id":"b-d646afa26506d5a68d080326","url":"#b-d646afa26506d5a68d080326","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-6358bf68f4cda41a3ef179e7","type":"p","scope":"block-8eced6ce67e84d02929cf23760a5eb09","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-6358bf68f4cda41a3ef179e7","content":"P2 不是因为框“不够像”而成为 FP；P3 在 AP75 中也不是因为分数低而失败。两类错误分别来自重复输出和定位精度。代码逐预测保存原因、匹配对象、累计 TP/FP、precision 与 recall，不能只凭最后一个 recall 代替 AP。","sha256":"ec42f52f300e017f976cda1af5c4bd1d6d6c4af90617bc422902888b59ab2760","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-8eced6ce67e84d02929cf23760a5eb09","title":"3 · 评价先降序，再限制同一 GT 只用一次","number":4},"sectionTitle":"3 · 评价先降序，再限制同一 GT 只用一次","currentQuestion":"3 · 评价先降序，再限制同一 GT 只用一次","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-95ffd2b5ffe5ac209447a51f","nextBlock":"b-92f05fb8305517ed4666df97","prerequisites":[{"id":"b-9cf3d7092ae0e5441798fdea","url":"#b-9cf3d7092ae0e5441798fdea","role":"section-title"},{"id":"b-d646afa26506d5a68d080326","url":"#b-d646afa26506d5a68d080326","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-92f05fb8305517ed4666df97","type":"p","scope":"block-8eced6ce67e84d02929cf23760a5eb09","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-92f05fb8305517ed4666df97","content":"**协议不能混用。**另一种规则是“先排除已用 GT，再选剩余 IoU 最大者”，它在重叠对象场景可能给出不同结果。取 GT1=`(0,0,2,2)`、GT2=`(0.5,0,2.5,2)`，预测 P1、P2 **都完全复制 GT1**，两预测对 GT 的 IoU 行均为 `[1.0, 0.6]`。在 IoU 阈值 0.50 下：","sha256":"096818f0a207394945eb2fac232b6319100606e3c51d27539f8c5924e8418e83","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-8eced6ce67e84d02929cf23760a5eb09","title":"3 · 评价先降序，再限制同一 GT 只用一次","number":4},"sectionTitle":"3 · 评价先降序，再限制同一 GT 只用一次","currentQuestion":"3 · 评价先降序，再限制同一 GT 只用一次","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-6358bf68f4cda41a3ef179e7","nextBlock":"b-ee29f84042d17dbfc95a62c9","prerequisites":[{"id":"b-9cf3d7092ae0e5441798fdea","url":"#b-9cf3d7092ae0e5441798fdea","role":"section-title"},{"id":"b-d646afa26506d5a68d080326","url":"#b-d646afa26506d5a68d080326","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-ee29f84042d17dbfc95a62c9","type":"table","scope":"block-8eced6ce67e84d02929cf23760a5eb09","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-ee29f84042d17dbfc95a62c9","content":"| 匹配规则 | P1 | P2 | AP50 | 最终 recall |\n| --- | --- | --- | --- | --- |\n| 本册：先选最大 IoU GT，再检查是否已用 | TP→GT1 | 重复 FP，仍以 GT1 为最佳 | 0.5 | 0.5 |\n| 对照：先排除已用 GT，再找最佳 | TP→GT1 | TP→GT2，IoU=0.6 | 1.0 | 1.0 |","sha256":"e9eeb83a8390c9faa218454e7b9cba24074bc75c09400de319101d0201fdd5c3","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-8eced6ce67e84d02929cf23760a5eb09","title":"3 · 评价先降序，再限制同一 GT 只用一次","number":4},"sectionTitle":"3 · 评价先降序，再限制同一 GT 只用一次","currentQuestion":"3 · 评价先降序，再限制同一 GT 只用一次","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"table":{"headers":["匹配规则","P1","P2","AP50","最终 recall"],"rows":[["匹配规则","P1","P2","AP50","最终 recall"],["本册：先选最大 IoU GT，再检查是否已用","TP→GT1","重复 FP，仍以 GT1 为最佳","0.5","0.5"],["对照：先排除已用 GT，再找最佳","TP→GT1","TP→GT2，IoU=0.6","1.0","1.0"]]},"previousBlock":"b-92f05fb8305517ed4666df97","nextBlock":"b-d25507fe61cf81db3e74ca53","prerequisites":[{"id":"b-9cf3d7092ae0e5441798fdea","url":"#b-9cf3d7092ae0e5441798fdea","role":"section-title"},{"id":"b-d646afa26506d5a68d080326","url":"#b-d646afa26506d5a68d080326","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-d25507fe61cf81db3e74ca53","type":"p","scope":"block-8eced6ce67e84d02929cf23760a5eb09","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-d25507fe61cf81db3e74ca53","content":"后者把两个完全相同的预测分配给不同对象。这组可执行反例说明：同为“一对一”，贪心选择顺序仍然属于评价协议，必须与报告的指标一起说明。后面的相邻对象 NMS 反例则为每个 GT 各有一个准确预测，属于另一种情形。","sha256":"e58c4af6fbaaf04d30eaa108ba9ece3c2bbd6a7f500a267336fa1fde4a034b50","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-8eced6ce67e84d02929cf23760a5eb09","title":"3 · 评价先降序，再限制同一 GT 只用一次","number":4},"sectionTitle":"3 · 评价先降序，再限制同一 GT 只用一次","currentQuestion":"3 · 评价先降序，再限制同一 GT 只用一次","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-ee29f84042d17dbfc95a62c9","nextBlock":null,"prerequisites":[{"id":"b-9cf3d7092ae0e5441798fdea","url":"#b-9cf3d7092ae0e5441798fdea","role":"section-title"},{"id":"b-d646afa26506d5a68d080326","url":"#b-d646afa26506d5a68d080326","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-bc1de362eb57aa58185321d8","type":"h2","scope":"block-03a49740c8684af3bd417c1030853845","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-bc1de362eb57aa58185321d8","content":"## 4 · AP 必须说明积分协议","sha256":"c145707f1bdb383bc093a32e8071c7886c9e1d9c370c86cb60c1fe35337f44d3","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-03a49740c8684af3bd417c1030853845","title":"4 · AP 必须说明积分协议","number":5},"sectionTitle":"4 · AP 必须说明积分协议","currentQuestion":"4 · AP 必须说明积分协议","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":null,"nextBlock":"b-31fcbf62c06f8e50b89ce2ec","prerequisites":[{"id":"b-31fcbf62c06f8e50b89ce2ec","url":"#b-31fcbf62c06f8e50b89ce2ec","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-31fcbf62c06f8e50b89ce2ec","type":"p","scope":"block-03a49740c8684af3bd417c1030853845","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-31fcbf62c06f8e50b89ce2ec","content":"本例使用 **all-points interpolated AP / precision envelope**：先累加 TP 和 FP，得到每个排名位置的 precision、recall；从右向左取 precision 的累计最大值，形成单调不增的上包络；只在 recall 实际增长的区间计算面积。","sha256":"f6f435fc12d010fd15ba0b40957ddf28b87daeec77f71d538b23f790871980b1","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-03a49740c8684af3bd417c1030853845","title":"4 · AP 必须说明积分协议","number":5},"sectionTitle":"4 · AP 必须说明积分协议","currentQuestion":"4 · AP 必须说明积分协议","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-bc1de362eb57aa58185321d8","nextBlock":"b-17dfadd9630e93139f81e78c","prerequisites":[{"id":"b-bc1de362eb57aa58185321d8","url":"#b-bc1de362eb57aa58185321d8","role":"section-title"}],"relatedBlocks":[]},{"id":"b-17dfadd9630e93139f81e78c","type":"p","scope":"block-03a49740c8684af3bd417c1030853845","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-17dfadd9630e93139f81e78c","content":"$\np_{\\rm interp}(r)=\\max_{\\tilde r\\ge r}p(\\tilde r),\\qquad\n\\mathrm{AP}=\\sum_k (r_k-r_{k-1})p_{\\rm interp}(r_k).\n$","sha256":"d3f0c99d3237b54e18e63608d41bd5beab5ef3818b9775162d384458afcca5c1","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-03a49740c8684af3bd417c1030853845","title":"4 · AP 必须说明积分协议","number":5},"sectionTitle":"4 · AP 必须说明积分协议","currentQuestion":"4 · AP 必须说明积分协议","sourceSlides":[],"knowledgeBlock":null,"formulas":[{"latex":"\np_{\\rm interp}(r)=\\max_{\\tilde r\\ge r}p(\\tilde r),\\qquad\n\\mathrm{AP}=\\sum_k (r_k-r_{k-1})p_{\\rm interp}(r_k).\n","definitionContext":"4 · AP 必须说明积分协议"}],"previousBlock":"b-31fcbf62c06f8e50b89ce2ec","nextBlock":"b-80614e4f0a9dbbbd41f5f4cb","prerequisites":[{"id":"b-bc1de362eb57aa58185321d8","url":"#b-bc1de362eb57aa58185321d8","role":"section-title"},{"id":"b-31fcbf62c06f8e50b89ce2ec","url":"#b-31fcbf62c06f8e50b89ce2ec","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-80614e4f0a9dbbbd41f5f4cb","type":"p","scope":"block-03a49740c8684af3bd417c1030853845","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-80614e4f0a9dbbbd41f5f4cb","content":"实现在前后补上边界点，最后补 `(recall=1, precision=0)`，保证没有达到的召回区间贡献零。**不对原始四个 precision 求算术平均，也不使用梯形积分。**","sha256":"1c2acd6b45c31a4ac283596b599dfb02ca9e707978bee1014fbbc118309af70d","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-03a49740c8684af3bd417c1030853845","title":"4 · AP 必须说明积分协议","number":5},"sectionTitle":"4 · AP 必须说明积分协议","currentQuestion":"4 · AP 必须说明积分协议","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-17dfadd9630e93139f81e78c","nextBlock":"b-a38a959e980ce5c1d7a8443b","prerequisites":[{"id":"b-bc1de362eb57aa58185321d8","url":"#b-bc1de362eb57aa58185321d8","role":"section-title"},{"id":"b-31fcbf62c06f8e50b89ce2ec","url":"#b-31fcbf62c06f8e50b89ce2ec","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-a38a959e980ce5c1d7a8443b","type":"p","scope":"block-03a49740c8684af3bd417c1030853845","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-a38a959e980ce5c1d7a8443b","content":"AP50 的 precision 为 `[1,1/2,2/3,1/2]`，recall 为 `[1/2,1/2,1,1]`。重复 recall 不增加面积；后半区间使用精度上包络 `2/3`，得到","sha256":"762c742d80949a91eaeb8ca7918d51cb4f5dab0687764f7757fa73912003c4ff","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-03a49740c8684af3bd417c1030853845","title":"4 · AP 必须说明积分协议","number":5},"sectionTitle":"4 · AP 必须说明积分协议","currentQuestion":"4 · AP 必须说明积分协议","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-80614e4f0a9dbbbd41f5f4cb","nextBlock":"b-a779e783e8da40b31fa4bce4","prerequisites":[{"id":"b-bc1de362eb57aa58185321d8","url":"#b-bc1de362eb57aa58185321d8","role":"section-title"},{"id":"b-31fcbf62c06f8e50b89ce2ec","url":"#b-31fcbf62c06f8e50b89ce2ec","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-a779e783e8da40b31fa4bce4","type":"p","scope":"block-03a49740c8684af3bd417c1030853845","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-a779e783e8da40b31fa4bce4","content":"$\n\\mathrm{AP50}=\\tfrac12\\times1+\\tfrac12\\times\\tfrac23=\\tfrac56.\n$","sha256":"e3351724b316daea9225094de0deba288be32184bd0ac5315e834e369076efcf","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-03a49740c8684af3bd417c1030853845","title":"4 · AP 必须说明积分协议","number":5},"sectionTitle":"4 · AP 必须说明积分协议","currentQuestion":"4 · AP 必须说明积分协议","sourceSlides":[],"knowledgeBlock":null,"formulas":[{"latex":"\n\\mathrm{AP50}=\\tfrac12\\times1+\\tfrac12\\times\\tfrac23=\\tfrac56.\n","definitionContext":"4 · AP 必须说明积分协议"}],"previousBlock":"b-a38a959e980ce5c1d7a8443b","nextBlock":"b-9dd8620ae9d15379709b11c1","prerequisites":[{"id":"b-bc1de362eb57aa58185321d8","url":"#b-bc1de362eb57aa58185321d8","role":"section-title"},{"id":"b-31fcbf62c06f8e50b89ce2ec","url":"#b-31fcbf62c06f8e50b89ce2ec","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-9dd8620ae9d15379709b11c1","type":"p","scope":"block-03a49740c8684af3bd417c1030853845","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-9dd8620ae9d15379709b11c1","content":"AP75 只召回 GT1，最大 recall 为 1/2。未召回的后半区间精度为零，故 AP75=`1/2×1+1/2×0=1/2`。","sha256":"409a42fa0bffff8ec3b9cb5aa2642077b014eb5ccff1db6f96783f6262bdcda0","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-03a49740c8684af3bd417c1030853845","title":"4 · AP 必须说明积分协议","number":5},"sectionTitle":"4 · AP 必须说明积分协议","currentQuestion":"4 · AP 必须说明积分协议","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-a779e783e8da40b31fa4bce4","nextBlock":"b-970ab698e1f67a172287bba0","prerequisites":[{"id":"b-bc1de362eb57aa58185321d8","url":"#b-bc1de362eb57aa58185321d8","role":"section-title"},{"id":"b-31fcbf62c06f8e50b89ce2ec","url":"#b-31fcbf62c06f8e50b89ce2ec","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-970ab698e1f67a172287bba0","type":"p","scope":"block-03a49740c8684af3bd417c1030853845","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-970ab698e1f67a172287bba0","content":"最后的可视化代码格会显示两个评价阈值下的 PR 上包络。","sha256":"6a20e9ec12bafe365604d815861a7a739b084cf4489c5dc447dd00faca037f51","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-03a49740c8684af3bd417c1030853845","title":"4 · AP 必须说明积分协议","number":5},"sectionTitle":"4 · AP 必须说明积分协议","currentQuestion":"4 · AP 必须说明积分协议","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-9dd8620ae9d15379709b11c1","nextBlock":"b-7d51adb14a0aaa5157649325","prerequisites":[{"id":"b-bc1de362eb57aa58185321d8","url":"#b-bc1de362eb57aa58185321d8","role":"section-title"},{"id":"b-31fcbf62c06f8e50b89ce2ec","url":"#b-31fcbf62c06f8e50b89ce2ec","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-7d51adb14a0aaa5157649325","type":"p","scope":"block-03a49740c8684af3bd417c1030853845","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-7d51adb14a0aaa5157649325","content":"这里的 AP50/AP75 表示同一 all-points 协议在不同 IoU 阈值的结果。它**不等于 COCO 的 101 个 recall 采样点 AP 实现**，也不是 `0.50:0.05:0.95` 多阈值 mAP。对真实数据集，应按指定协议汇总同类预测，并在各图像内部匹配，再构建整体 PR 曲线；不能直接把单张图像 AP 的平均值当作数据集 AP。本教学实现没有 crowd、ignore、面积分组或 maxDets。","sha256":"f19b1ef922e012efaaf2363ee58ba8f1909c2b51c67322adc04d5faac625c146","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-03a49740c8684af3bd417c1030853845","title":"4 · AP 必须说明积分协议","number":5},"sectionTitle":"4 · AP 必须说明积分协议","currentQuestion":"4 · AP 必须说明积分协议","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-970ab698e1f67a172287bba0","nextBlock":"b-9b7264c45228653fbccbff8f","prerequisites":[{"id":"b-bc1de362eb57aa58185321d8","url":"#b-bc1de362eb57aa58185321d8","role":"section-title"},{"id":"b-31fcbf62c06f8e50b89ce2ec","url":"#b-31fcbf62c06f8e50b89ce2ec","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-9b7264c45228653fbccbff8f","type":"pre","scope":"block-86f64f86923e48fcaaea1efc4926457c","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-9b7264c45228653fbccbff8f","content":"```\ndef all_points_ap(recall, precision):\n    \"\"\"All-points interpolated AP = sum of recall increments * envelope.\n\n    This is not 11-point AP, the mean of raw precisions, or COCO 101-point AP.\n    A sentinel at recall 1 with precision 0 gives unreached recall zero credit.\n    \"\"\"\n    recall, precision = np.asarray(recall, float), np.asarray(precision, float)\n    if recall.shape != precision.shape or np.any(np.diff(recall) < -1e-12):\n        raise ValueError(\"Aligned arrays and nondecreasing recall required\")\n    if np.any((recall < 0) | (recall > 1) | (precision < 0) | (precision > 1)):\n        raise ValueError(\"Recall and precision must be in [0,1]\")\n    mrec = np.r_[0.0, recall, 1.0]\n    mpre = np.r_[0.0, precision, 0.0]\n    envelope = np.maximum.accumulate(mpre[::-1])[::-1]\n    changed = np.where(mrec[1:] > mrec[:-1])[0]\n    ap = np.sum((mrec[changed + 1] - mrec[changed]) * envelope[changed + 1])\n    return float(ap), mrec, envelope\n\n\ndef evaluate_single_class(pred_boxes, scores, gt_boxes, iou_threshold=0.50):\n    \"\"\"One image / one class: choose the best-IoU GT, then check if already used.\n\n    VOC-style greedy matching, aligned with LAB10: a used best GT makes the\n    prediction a duplicate FP; do not fall back to a lower-IoU unused GT.\n    Score ties and IoU ties preserve input order. Threshold comparison is >=.\n    No crowd, ignore regions, maxDets, area bins, or dataset pooling.\n    \"\"\"\n    if not 0 <= iou_threshold <= 1:\n        raise ValueError(\"iou_threshold must be in [0,1]\")\n    pred_boxes, gt_boxes = boxes_xyxy(pred_boxes), boxes_xyxy(gt_boxes)\n    scores = np.asarray(scores, dtype=float)\n    if scores.shape != (len(pred_boxes),) or not np.isfinite(scores).all():\n        raise ValueError(\"Require one finite score per prediction\")\n    if len(gt_boxes) == 0:\n        raise ValueError(\"AP is undefined for this no-GT single-class example\")\n    order = np.argsort(-scores, kind=\"stable\")\n    used = np.zeros(len(gt_boxes), dtype=bool)\n    overlaps = box_iou(pred_boxes, gt_boxes)\n    tp, rows = [], []\n    for rank, pred_i in enumerate(order, 1):\n        gt_i = int(np.argmax(overlaps[pred_i]))\n        best_iou = float(overlaps[pred_i, gt_i])\n        meets_threshold = best_iou >= iou_threshold\n        is_tp = bool(meets_threshold and not used[gt_i])\n        if is_tp:\n            used[gt_i] = True\n            reason = \"new GT matched\"\n        elif meets_threshold:\n            reason = \"duplicate: maximum-IoU GT already used; no fallback\"\n        else:\n            reason = \"IoU below evaluation threshold\"\n        tp.append(int(is_tp))\n        rows.append({\"rank\": rank, \"prediction\": int(pred_i + 1),\n                     \"score\": float(scores[pred_i]), \"status\": \"TP\" if is_tp else \"FP\",\n                     \"gt\": gt_i + 1 if is_tp else None,\n                     \"best_gt\": gt_i + 1, \"best_iou_any_gt\": best_iou, \"reason\": reason})\n    tp = np.asarray(tp, dtype=int)\n    cumulative_tp, cumulative_fp = np.cumsum(tp), np.cumsum(1 - tp)\n    recall = cumulative_tp / len(gt_boxes)\n    precision = np.divide(cumulative_tp, np.arange(1, len(tp) + 1), dtype=float)\n    ap, mrec, envelope = all_points_ap(recall, precision)\n    for i, row in enumerate(rows):\n        row.update(cumulative_tp=int(cumulative_tp[i]), cumulative_fp=int(cumulative_fp[i]),\n                   recall=float(recall[i]), precision=float(precision[i]))\n    return {\"iou_threshold\": iou_threshold, \"rows\": rows, \"ap\": ap,\n            \"recall\": recall.tolist(), \"precision\": precision.tolist(),\n            \"envelope_recall\": mrec.tolist(), \"precision_envelope\": envelope.tolist(),\n            \"final_recall\": float(recall[-1]) if len(recall) else 0.0}\n\nfor threshold in EVAL_THRESHOLDS:\n    evaluation = evaluate_single_class(PRED, SCORES, GT, threshold)\n    print(\"IoU threshold:\", threshold, \"all-points AP:\", evaluation[\"ap\"])\n    for row in evaluation[\"rows\"]:\n        print(row)\n```","sha256":"f31cf1d9a14598b7df30758514ff673215dd7e7f6b95d40db8325a0cf067437d","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-03a49740c8684af3bd417c1030853845","title":"4 · AP 必须说明积分协议","number":5},"sectionTitle":"4 · AP 必须说明积分协议","currentQuestion":"4 · AP 必须说明积分协议","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-7d51adb14a0aaa5157649325","nextBlock":null,"prerequisites":[{"id":"b-bc1de362eb57aa58185321d8","url":"#b-bc1de362eb57aa58185321d8","role":"section-title"},{"id":"b-31fcbf62c06f8e50b89ce2ec","url":"#b-31fcbf62c06f8e50b89ce2ec","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-268ac124429a2d26908f206c","type":"h2","scope":"block-cf51f5d05100404d88c27df74895324d","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-268ac124429a2d26908f206c","content":"## 5 · NMS 的阈值不是评价的阈值","sha256":"99b2e6e24035851332a4887c1978f2bbacb01b592049fd2378d378923f9664a2","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-cf51f5d05100404d88c27df74895324d","title":"5 · NMS 的阈值不是评价的阈值","number":6},"sectionTitle":"5 · NMS 的阈值不是评价的阈值","currentQuestion":"5 · NMS 的阈值不是评价的阈值","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":null,"nextBlock":"b-0470c0f5e5caf4a3e45beecb","prerequisites":[{"id":"b-0470c0f5e5caf4a3e45beecb","url":"#b-0470c0f5e5caf4a3e45beecb","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-0470c0f5e5caf4a3e45beecb","type":"p","scope":"block-cf51f5d05100404d88c27df74895324d","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-0470c0f5e5caf4a3e45beecb","content":"代码实现 **class-aware NMS**：按分数降序保留当前框；仅当另一个框与它**类别相同且 IoU > 0.50** 时才抑制。相等时保留；不同类别即使坐标完全一致也保留。本例没有额外分数过滤。NMS 输入不包含 GT，因此不是训练匹配，也不能知道两个重叠框是否对应同一个真实对象。","sha256":"ff44778ca5c7eeffd58655ecd14f2f76e6c6de9e6c4a98686ed1e0c15217ef2b","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-cf51f5d05100404d88c27df74895324d","title":"5 · NMS 的阈值不是评价的阈值","number":6},"sectionTitle":"5 · NMS 的阈值不是评价的阈值","currentQuestion":"5 · NMS 的阈值不是评价的阈值","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-268ac124429a2d26908f206c","nextBlock":"b-269b3de9a82ffd191d9a4266","prerequisites":[{"id":"b-268ac124429a2d26908f206c","url":"#b-268ac124429a2d26908f206c","role":"section-title"}],"relatedBlocks":[]},{"id":"b-269b3de9a82ffd191d9a4266","type":"p","scope":"block-cf51f5d05100404d88c27df74895324d","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-269b3de9a82ffd191d9a4266","content":"原例 P1/P2 同类，互相 IoU=`9/11 > 0.50`，所以 P2 被删，保留原编号 `[P1,P3,P4]`。","sha256":"e9598bbdffe74d165e2e2c5ccdbbf7874c6f5cd6a3cb7db83f9c8df436452870","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-cf51f5d05100404d88c27df74895324d","title":"5 · NMS 的阈值不是评价的阈值","number":6},"sectionTitle":"5 · NMS 的阈值不是评价的阈值","currentQuestion":"5 · NMS 的阈值不是评价的阈值","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-0470c0f5e5caf4a3e45beecb","nextBlock":"b-22ee2aaae4cf67a42468af9f","prerequisites":[{"id":"b-268ac124429a2d26908f206c","url":"#b-268ac124429a2d26908f206c","role":"section-title"},{"id":"b-0470c0f5e5caf4a3e45beecb","url":"#b-0470c0f5e5caf4a3e45beecb","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-22ee2aaae4cf67a42468af9f","type":"table","scope":"block-cf51f5d05100404d88c27df74895324d","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-22ee2aaae4cf67a42468af9f","content":"| 条件 | AP50 的 TP/FP 顺序 | AP50 | AP75 | AP50 最终 recall |\n| --- | --- | --- | --- | --- |\n| NMS 前 | TP, FP, TP, FP | 5/6 | 1/2 | 1 |\n| NMS 后 | TP, TP, FP | 1 | 1/2 | 1 |","sha256":"4dd65e80188fecd322b1ed169bd716718a7ab85d7ac95618c6543e0ec8506461","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-cf51f5d05100404d88c27df74895324d","title":"5 · NMS 的阈值不是评价的阈值","number":6},"sectionTitle":"5 · NMS 的阈值不是评价的阈值","currentQuestion":"5 · NMS 的阈值不是评价的阈值","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"table":{"headers":["条件","AP50 的 TP/FP 顺序","AP50","AP75","AP50 最终 recall"],"rows":[["条件","AP50 的 TP/FP 顺序","AP50","AP75","AP50 最终 recall"],["NMS 前","TP, FP, TP, FP","5/6","1/2","1"],["NMS 后","TP, TP, FP","1","1/2","1"]]},"previousBlock":"b-269b3de9a82ffd191d9a4266","nextBlock":"b-4e82f4fdc246b9c47e2fd81e","prerequisites":[{"id":"b-268ac124429a2d26908f206c","url":"#b-268ac124429a2d26908f206c","role":"section-title"},{"id":"b-0470c0f5e5caf4a3e45beecb","url":"#b-0470c0f5e5caf4a3e45beecb","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-4e82f4fdc246b9c47e2fd81e","type":"p","scope":"block-cf51f5d05100404d88c27df74895324d","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-4e82f4fdc246b9c47e2fd81e","content":"NMS 清理了 P2 重复错误，因此 AP50 改善；它没有调整 P3 坐标，AP75 没有改善。NMS 后仍留有 P4 这个 FP，但它排在全部真值被召回之后，故此处 all-points AP50 仍为 1。**AP=1 不表示预测列表中绝无 FP。**","sha256":"66f68d3235a1e4b9040cc5899b3ed4cbb50ffe431cf9d426948cb0450dbf573f","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-cf51f5d05100404d88c27df74895324d","title":"5 · NMS 的阈值不是评价的阈值","number":6},"sectionTitle":"5 · NMS 的阈值不是评价的阈值","currentQuestion":"5 · NMS 的阈值不是评价的阈值","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-22ee2aaae4cf67a42468af9f","nextBlock":"b-67a3487109d7991fc344d0da","prerequisites":[{"id":"b-268ac124429a2d26908f206c","url":"#b-268ac124429a2d26908f206c","role":"section-title"},{"id":"b-0470c0f5e5caf4a3e45beecb","url":"#b-0470c0f5e5caf4a3e45beecb","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-67a3487109d7991fc344d0da","type":"pre","scope":"block-afc86821efbb4021940cb56bf27497ec","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-67a3487109d7991fc344d0da","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":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-cf51f5d05100404d88c27df74895324d","title":"5 · NMS 的阈值不是评价的阈值","number":6},"sectionTitle":"5 · NMS 的阈值不是评价的阈值","currentQuestion":"5 · NMS 的阈值不是评价的阈值","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-4e82f4fdc246b9c47e2fd81e","nextBlock":null,"prerequisites":[{"id":"b-268ac124429a2d26908f206c","url":"#b-268ac124429a2d26908f206c","role":"section-title"},{"id":"b-0470c0f5e5caf4a3e45beecb","url":"#b-0470c0f5e5caf4a3e45beecb","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-e98f3f34077fd31350d38c1f","type":"h2","scope":"block-0a71ec88a039404fbc98fde29df4fe9d","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-e98f3f34077fd31350d38c1f","content":"## 6 · 反例：相邻真实对象被 NMS 合并","sha256":"057b419e2a6f1c41cacfdca38da03ad6ba8650d0bd782da825b7dd0f23916f22","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-0a71ec88a039404fbc98fde29df4fe9d","title":"6 · 反例：相邻真实对象被 NMS 合并","number":7},"sectionTitle":"6 · 反例：相邻真实对象被 NMS 合并","currentQuestion":"6 · 反例：相邻真实对象被 NMS 合并","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":null,"nextBlock":"b-7aafddeade5ec24686f4dcd3","prerequisites":[{"id":"b-7aafddeade5ec24686f4dcd3","url":"#b-7aafddeade5ec24686f4dcd3","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-7aafddeade5ec24686f4dcd3","type":"p","scope":"block-0a71ec88a039404fbc98fde29df4fe9d","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-7aafddeade5ec24686f4dcd3","content":"把场景换成两个同类 GT：`(0,0,2,2)` 与 `(0.5,0,2.5,2)`。二者交集为 3，并集为 5，互相 IoU=`0.6`。对应预测与 GT 完全一致，分数分别为 0.95、0.90。","sha256":"a9edb5918459c5b3d18b937e2bd7182a7ef99bbfe8df3b9d1571ba6ef3f65d37","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-0a71ec88a039404fbc98fde29df4fe9d","title":"6 · 反例：相邻真实对象被 NMS 合并","number":7},"sectionTitle":"6 · 反例：相邻真实对象被 NMS 合并","currentQuestion":"6 · 反例：相邻真实对象被 NMS 合并","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-e98f3f34077fd31350d38c1f","nextBlock":"b-b6ad3375758c8ecd430cfb88","prerequisites":[{"id":"b-e98f3f34077fd31350d38c1f","url":"#b-e98f3f34077fd31350d38c1f","role":"section-title"}],"relatedBlocks":[]},{"id":"b-b6ad3375758c8ecd430cfb88","type":"p","scope":"block-0a71ec88a039404fbc98fde29df4fe9d","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-b6ad3375758c8ecd430cfb88","content":"NMS 前，两个预测分别匹配不同 GT，AP50=1、recall=1。使用相同 NMS 阈值 0.50，第二个预测会被抑制，于是 AP50=0.5、recall=0.5。仅将 NMS 阈值改为 0.70，两框都保留。本例还断言不同类别的完全重合框能同时保留，检查了 class-aware 分支。","sha256":"fa671c678fe0a1c60ae3e45a170194051904ba8c100efec9c1e1312559e0717a","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-0a71ec88a039404fbc98fde29df4fe9d","title":"6 · 反例：相邻真实对象被 NMS 合并","number":7},"sectionTitle":"6 · 反例：相邻真实对象被 NMS 合并","currentQuestion":"6 · 反例：相邻真实对象被 NMS 合并","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-7aafddeade5ec24686f4dcd3","nextBlock":"b-0b18a26a36e64d0e519b4cca","prerequisites":[{"id":"b-e98f3f34077fd31350d38c1f","url":"#b-e98f3f34077fd31350d38c1f","role":"section-title"},{"id":"b-7aafddeade5ec24686f4dcd3","url":"#b-7aafddeade5ec24686f4dcd3","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-0b18a26a36e64d0e519b4cca","type":"p","scope":"block-0a71ec88a039404fbc98fde29df4fe9d","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-0b18a26a36e64d0e519b4cca","content":"接下格将同时验证原例与相邻真对象反例，再生成对照图。","sha256":"abd49d75d7f2172ebb0b23c067ed984f4a20c61b79a7927c329effde809d940a","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-0a71ec88a039404fbc98fde29df4fe9d","title":"6 · 反例：相邻真实对象被 NMS 合并","number":7},"sectionTitle":"6 · 反例：相邻真实对象被 NMS 合并","currentQuestion":"6 · 反例：相邻真实对象被 NMS 合并","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-b6ad3375758c8ecd430cfb88","nextBlock":"b-7cbdab472dadba15927a4363","prerequisites":[{"id":"b-e98f3f34077fd31350d38c1f","url":"#b-e98f3f34077fd31350d38c1f","role":"section-title"},{"id":"b-7aafddeade5ec24686f4dcd3","url":"#b-7aafddeade5ec24686f4dcd3","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-7cbdab472dadba15927a4363","type":"p","scope":"block-0a71ec88a039404fbc98fde29df4fe9d","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-7cbdab472dadba15927a4363","content":"由此可以支持：“固定 NMS 规则会在重复框清理与相邻对象保留之间产生取舍。”不能支持：“0.70 是真实数据的最佳阈值”，因为这里只有两个手工场景。","sha256":"ceb02fe3d79ee675f25df17f834797146f96ba38d62332734e01c1df934950fc","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-0a71ec88a039404fbc98fde29df4fe9d","title":"6 · 反例：相邻真实对象被 NMS 合并","number":7},"sectionTitle":"6 · 反例：相邻真实对象被 NMS 合并","currentQuestion":"6 · 反例：相邻真实对象被 NMS 合并","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-0b18a26a36e64d0e519b4cca","nextBlock":"b-bd776c63facd8050676d0dbd","prerequisites":[{"id":"b-e98f3f34077fd31350d38c1f","url":"#b-e98f3f34077fd31350d38c1f","role":"section-title"},{"id":"b-7aafddeade5ec24686f4dcd3","url":"#b-7aafddeade5ec24686f4dcd3","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-bd776c63facd8050676d0dbd","type":"pre","scope":"block-e4240ba681bd49f3871529d076ed4b97","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-bd776c63facd8050676d0dbd","content":"```\nGT = np.array([[0, 0, 2, 2], [3, 0, 5, 2]], dtype=float)\nPRED = np.array([[0, 0, 2, 2], [.2, 0, 2.2, 2], [3.4, 0, 5.4, 2], [7, 7, 8, 8]], float)\nSCORES = np.array([.9, .8, .7, .4])\nCLASSES = np.zeros(4, dtype=int)\n\niou_matrix = box_iou(PRED, GT)\ntraining_assignment, forced_anchors = assign_training_anchors(PRED, GT, positive_iou=.5)\nbaseline = {f\"AP{round(t * 100)}\": evaluate_single_class(PRED, SCORES, GT, t)\n            for t in EVAL_THRESHOLDS}\nkept, suppressed = class_aware_nms(PRED, SCORES, CLASSES, NMS_THRESHOLD)\nafter_nms = {f\"AP{round(t * 100)}\": evaluate_single_class(PRED[kept], SCORES[kept], GT, t)\n             for t in EVAL_THRESHOLDS}\nfor result in after_nms.values():\n    for row in result[\"rows\"]:\n        row[\"prediction\"] = int(kept[row[\"prediction\"] - 1] + 1)\n\n# Two real, same-class objects overlap by IoU=0.6. Both predictions are exact.\nNEIGHBOR_GT = np.array([[0, 0, 2, 2], [.5, 0, 2.5, 2]], float)\nNEIGHBOR_SCORES = np.array([.95, .90])\nneighbor_kept, neighbor_suppressed = class_aware_nms(\n    NEIGHBOR_GT, NEIGHBOR_SCORES, [0, 0], NMS_THRESHOLD)\nneighbor_before = evaluate_single_class(NEIGHBOR_GT, NEIGHBOR_SCORES, NEIGHBOR_GT, .5)\nneighbor_after = evaluate_single_class(NEIGHBOR_GT[neighbor_kept],\n                                      NEIGHBOR_SCORES[neighbor_kept], NEIGHBOR_GT, .5)\nneighbor_kept_070, _ = class_aware_nms(NEIGHBOR_GT, NEIGHBOR_SCORES, [0, 0], .70)\n\n# A forced training positive can fall below the positive IoU threshold.\nLOW_OVERLAP_ANCHORS = np.array([[0, 0, .7, .7], [.8, 0, .9, .1], [3, 0, 3.6, .6]])\nlow_assignment, low_forced = assign_training_anchors(LOW_OVERLAP_ANCHORS, GT, .5)\n\n# Protocol counterexample: two exact copies of GT1, while GT2 overlaps it by 0.6.\n# The production evaluator above must NOT reassign a duplicate to second-best GT2.\nDUPLICATE_NEIGHBOR_PRED = np.repeat(NEIGHBOR_GT[:1], 2, axis=0)\nprotocol_standard = evaluate_single_class(DUPLICATE_NEIGHBOR_PRED, NEIGHBOR_SCORES,\n                                          NEIGHBOR_GT, .5)\n# The following trace deliberately implements the OTHER protocol for comparison.\nalternative_used = np.zeros(len(NEIGHBOR_GT), dtype=bool)\nalternative_tp = []\nalternative_ious = box_iou(DUPLICATE_NEIGHBOR_PRED, NEIGHBOR_GT)\nfor pred_i in np.argsort(-NEIGHBOR_SCORES, kind=\"stable\"):\n    eligible = np.flatnonzero((~alternative_used) & (alternative_ious[pred_i] >= .5))\n    if len(eligible):\n        gt_i = int(eligible[np.argmax(alternative_ious[pred_i, eligible])])\n        alternative_used[gt_i] = True\n    alternative_tp.append(int(len(eligible) > 0))\nalternative_recall = np.cumsum(alternative_tp) / len(NEIGHBOR_GT)\nalternative_precision = np.cumsum(alternative_tp) / np.arange(1, len(alternative_tp) + 1)\nalternative_ap = all_points_ap(alternative_recall, alternative_precision)[0]\n\n# Meaningful invariants and protocol boundaries, not a network benchmark.\nassert iou_matrix.shape == (4, 2)\nnp.testing.assert_allclose(iou_matrix, [[1, 0], [9 / 11, 0], [0, 2 / 3], [0, 0]])\nassert training_assignment.tolist() == [0, 0, 1, -1]\nassert [r[\"status\"] for r in baseline[\"AP50\"][\"rows\"]] == [\"TP\", \"FP\", \"TP\", \"FP\"]\nassert [r[\"status\"] for r in baseline[\"AP75\"][\"rows\"]] == [\"TP\", \"FP\", \"FP\", \"FP\"]\nnp.testing.assert_allclose([baseline[\"AP50\"][\"ap\"], baseline[\"AP75\"][\"ap\"]], [5 / 6, .5])\nassert kept.tolist() == [0, 2, 3]\nnp.testing.assert_allclose([after_nms[\"AP50\"][\"ap\"], after_nms[\"AP75\"][\"ap\"]], [1, .5])\nnp.testing.assert_allclose([neighbor_before[\"ap\"], neighbor_after[\"ap\"]], [1, .5])\nassert neighbor_kept_070.tolist() == [0, 1]\nassert low_assignment.tolist() == [0, -1, 1] and low_forced.tolist() == [True, False, True]\nassert class_aware_nms([[0, 0, 2, 2]] * 2, [.9, .8], [0, 1], .5)[0].tolist() == [0, 1]\nassert class_aware_nms([[0, 0, 2, 2]] * 2, [.9, .8], [0, 0], 1.0)[0].tolist() == [0, 1]\nassert box_iou([[0, 0, 0, 0]], [[0, 0, 0, 0]]).item() == 0\nassert evaluate_single_class([], [], GT, .5)[\"ap\"] == 0\nassert [r[\"status\"] for r in protocol_standard[\"rows\"]] == [\"TP\", \"FP\"]\nassert alternative_tp == [1, 1]\nnp.testing.assert_allclose([protocol_standard[\"ap\"], alternative_ap], [.5, 1.0])\n\nresults = {\n    \"data_identity\": \"deterministic teaching example; no model trained or inferred\",\n    \"coordinates\": \"continuous xyxy, no +1\",\n    \"ap_protocol\": \"all-points precision envelope; single image / one class; not COCO mAP\",\n    \"matching_protocol\": \"VOC-style: maximum-IoU same-image/class GT, then used check; no fallback; IoU >= threshold\",\n    \"nms_protocol\": {\"class_aware\": True, \"suppress_if\": \"IoU > threshold\", \"threshold\": NMS_THRESHOLD},\n    \"input_shapes\": {\"gt\": list(GT.shape), \"pred\": list(PRED.shape), \"scores\": list(SCORES.shape)},\n    \"gt\": GT.tolist(), \"pred\": PRED.tolist(), \"scores\": SCORES.tolist(),\n    \"iou_matrix_pred_by_gt\": iou_matrix.tolist(),\n    \"training_assignment_gt_1based\": [int(x + 1) if x >= 0 else None for x in training_assignment],\n    \"training_forced\": forced_anchors.tolist(),\n    \"baseline\": baseline, \"nms_kept_predictions\": (kept + 1).tolist(),\n    \"nms_suppressed\": suppressed, \"after_nms\": after_nms,\n    \"neighbor_case\": {\"gt\": NEIGHBOR_GT.tolist(), \"mutual_iou\": box_iou(NEIGHBOR_GT[:1], NEIGHBOR_GT[1:]).item(),\n                      \"before_nms\": neighbor_before, \"after_nms\": neighbor_after,\n                      \"suppressed\": neighbor_suppressed, \"kept_at_nms_070\": (neighbor_kept_070 + 1).tolist()},\n    \"low_iou_forced_training_case\": {\"anchors\": LOW_OVERLAP_ANCHORS.tolist(),\n                                     \"ious\": box_iou(LOW_OVERLAP_ANCHORS, GT).tolist(),\n                                     \"assignment_gt_1based\": [int(x + 1) if x >= 0 else None for x in low_assignment],\n                                     \"forced\": low_forced.tolist()},\n    \"matching_protocol_counterexample\": {\"gt\": NEIGHBOR_GT.tolist(),\n                                         \"pred\": DUPLICATE_NEIGHBOR_PRED.tolist(),\n                                         \"iou_matrix\": alternative_ious.tolist(),\n                                         \"best_gt_then_used\": protocol_standard,\n                                         \"best_unused_alternative\": {\"tp\": alternative_tp,\n                                             \"recall\": alternative_recall.tolist(),\n                                             \"precision\": alternative_precision.tolist(),\n                                             \"ap\": alternative_ap}},\n    \"checks\": \"all assertions passed\",\n}\n(OUT / \"results.json\").write_text(json.dumps(results, ensure_ascii=False, indent=2), encoding=\"utf-8\")\nprint(\"IoU matrix (prediction x GT):\\n\", np.round(iou_matrix, 6))\nprint(\"Training anchor targets (GT1, GT2; None=background):\", results[\"training_assignment_gt_1based\"])\nfor label, experiment in [(\"Before NMS\", baseline), (\"After NMS\", after_nms)]:\n    for metric, result in experiment.items():\n        print(label, metric, \"=\", round(result[\"ap\"], 9),\n              \"sequence:\", [r[\"status\"] for r in result[\"rows\"]], \"recall:\", result[\"final_recall\"])\nprint(\"NMS kept original predictions:\", (kept + 1).tolist())\nprint(\"Neighbor objects AP50:\", neighbor_before[\"ap\"], \"->\", neighbor_after[\"ap\"],\n      \"; recall:\", neighbor_before[\"final_recall\"], \"->\", neighbor_after[\"final_recall\"])\nprint(\"Low-IoU forced anchors:\", results[\"low_iou_forced_training_case\"])\nprint(\"Protocol counterexample (two copies of GT1): maximum-IoU GT then used ->\",\n      [r[\"status\"] for r in protocol_standard[\"rows\"]], \"AP50\", protocol_standard[\"ap\"],\n      \"; best-unused alternative ->\", alternative_tp, \"AP50\", alternative_ap)\n```","sha256":"019ed1e27e0ff2c7c0f21e08efbc88125eda7605362a3738b0d9b2c523479e80","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-0a71ec88a039404fbc98fde29df4fe9d","title":"6 · 反例：相邻真实对象被 NMS 合并","number":7},"sectionTitle":"6 · 反例：相邻真实对象被 NMS 合并","currentQuestion":"6 · 反例：相邻真实对象被 NMS 合并","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-7cbdab472dadba15927a4363","nextBlock":null,"prerequisites":[{"id":"b-e98f3f34077fd31350d38c1f","url":"#b-e98f3f34077fd31350d38c1f","role":"section-title"},{"id":"b-7aafddeade5ec24686f4dcd3","url":"#b-7aafddeade5ec24686f4dcd3","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-c77ea7195466ecbb6a57ae76","type":"h2","scope":"block-ba39de56ef7d4d2882d9441ecd6d1424","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-c77ea7195466ecbb6a57ae76","content":"## 可视化与实际输出","sha256":"e9cb32fe157eac264b6d74b8ff30a43e33c1ea6ea8a1a0e5eee1801aa44dab48","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-ba39de56ef7d4d2882d9441ecd6d1424","title":"可视化与实际输出","number":8},"sectionTitle":"可视化与实际输出","currentQuestion":"可视化与实际输出","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":null,"nextBlock":"b-f9ec3d0a17f12c0f92a6c9ea","prerequisites":[{"id":"b-f9ec3d0a17f12c0f92a6c9ea","url":"#b-f9ec3d0a17f12c0f92a6c9ea","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-f9ec3d0a17f12c0f92a6c9ea","type":"p","scope":"block-ba39de56ef7d4d2882d9441ecd6d1424","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-f9ec3d0a17f12c0f92a6c9ea","content":"这格用标准库生成三张 SVG 图，图中的坐标、上包络、面积和抑制结果均取自上格的实际计算。绘图部分可以折叠；前面的机制计算不依赖它。","sha256":"34b109db7f914fa53edbcfc2cdbe86ff10eba63e922c644779362e4124b23f34","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-ba39de56ef7d4d2882d9441ecd6d1424","title":"可视化与实际输出","number":8},"sectionTitle":"可视化与实际输出","currentQuestion":"可视化与实际输出","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-c77ea7195466ecbb6a57ae76","nextBlock":"b-2cae73a4f8542175499dc5a7","prerequisites":[{"id":"b-c77ea7195466ecbb6a57ae76","url":"#b-c77ea7195466ecbb6a57ae76","role":"section-title"}],"relatedBlocks":[]},{"id":"b-2cae73a4f8542175499dc5a7","type":"pre","scope":"block-8d1df38317244d5097b2ef92388bf925","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-2cae73a4f8542175499dc5a7","content":"```\ndef svg_document(width, height, fragments):\n    return (f'<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"{width}\" height=\"{height}\" '\n            f'viewBox=\"0 0 {width} {height}\"><rect width=\"100%\" height=\"100%\" fill=\"#f7f8fa\"/>'\n            '<style>text{font-family:Arial,sans-serif;fill:#162235} .title{font-size:22px;font-weight:bold}'\n            '.label{font-size:15px}.small{font-size:13px}.axis{stroke:#738095;stroke-width:1}</style>'\n            + \"\".join(fragments) + \"</svg>\")\n\n\ndef svg_text(x, y, value, cls=\"label\", extra=\"\"):\n    return f'<text x=\"{x}\" y=\"{y}\" class=\"{cls}\" {extra}>{escape(str(value))}</text>'\n\n\ngeometry = [svg_text(32, 36, \"Two GT boxes / four scored predictions\", \"title\"),\n            svg_text(32, 62, \"Continuous xyxy coordinates; dashed = GT; solid = prediction\", \"label\")]\nfor value in range(9):\n    x, y = 80 + value * 55, 100 + value * 55\n    geometry.append(f'<path d=\"M {x} 100 V 540 M 80 {y} H 520\" stroke=\"#e0e4e9\"/>')\n    geometry += [svg_text(x - 4, 566, value, \"small\"), svg_text(55, y + 5, value, \"small\")]\ngeometry += [svg_text(293, 592, \"x coordinate\"), svg_text(20, 327, \"y\", \"label\")]\nfor i, b in enumerate(GT):\n    x1, y1, x2, y2 = b\n    geometry.append(f'<rect x=\"{80 + x1 * 55}\" y=\"{100 + y1 * 55}\" width=\"{(x2 - x1) * 55}\" '\n                    f'height=\"{(y2 - y1) * 55}\" fill=\"none\" stroke=\"#111827\" stroke-width=\"4\" stroke-dasharray=\"9 5\"/>')\n    geometry.append(svg_text(83 + x1 * 55, 88, f\"GT{i+1}\"))\ncolors = [\"#156a9c\", \"#d16a20\", \"#188164\", \"#845ec2\"]\nfor i, b in enumerate(PRED):\n    x1, y1, x2, y2 = b\n    geometry.append(f'<rect x=\"{80 + x1 * 55}\" y=\"{100 + y1 * 55}\" width=\"{(x2 - x1) * 55}\" '\n                    f'height=\"{(y2 - y1) * 55}\" fill=\"none\" stroke=\"{colors[i]}\" stroke-width=\"2\"/>')\n    geometry.append(f'<line x1=\"585\" x2=\"615\" y1=\"{128+i*50}\" y2=\"{128+i*50}\" stroke=\"{colors[i]}\" stroke-width=\"4\"/>')\n    geometry.append(svg_text(627, 134 + i * 50, f\"P{i+1} | score {SCORES[i]:.2f}\"))\n    geometry.append(svg_text(627, 153 + i * 50, f\"IoU(GT1,GT2) = {iou_matrix[i,0]:.3f}, {iou_matrix[i,1]:.3f}\", \"small\"))\ngeometry += [svg_text(585, 372, \"AP50: TP, FP, TP, FP\"),\n             svg_text(585, 399, \"P2 overlaps GT1, already used.\"),\n             svg_text(585, 444, \"AP75: TP, FP, FP, FP\"),\n             svg_text(585, 471, \"P3 IoU = 2/3 < 0.75.\"),\n             svg_text(585, 527, \"The axes include the distant FP.\", \"small\")]\n(OUT / \"geometry.svg\").write_text(svg_document(955, 615, geometry), encoding=\"utf-8\")\n\npr = [svg_text(28, 36, \"All-points AP integrates the precision envelope\", \"title\"),\n      svg_text(28, 62, \"Original predictions, before NMS | solid: envelope; dots: raw ranked precision\", \"label\")]\nfor panel, key in enumerate([\"AP50\", \"AP75\"]):\n    result = baseline[key]\n    left, top, width, height = 80 + panel * 460, 108, 340, 290\n    for tick in [0, .25, .5, .75, 1]:\n        x, y = left + tick * width, top + (1 - tick) * height\n        pr += [f'<path d=\"M {x} {top} V {top+height} M {left} {y} H {left+width}\" stroke=\"#dbe1e7\"/>',\n               svg_text(x - 8, top + height + 26, f\"{tick:g}\", \"small\"),\n               svg_text(left - 35, y + 4, f\"{tick:g}\", \"small\")]\n    mrec, env = np.array(result[\"envelope_recall\"]), np.array(result[\"precision_envelope\"])\n    intervals = np.flatnonzero(np.diff(mrec) > 0)\n    for interval_i, j in enumerate(intervals):\n        x0, x1 = left + mrec[j] * width, left + mrec[j + 1] * width\n        y = top + (1 - env[j + 1]) * height\n        pr.append(f'<rect x=\"{x0}\" y=\"{y}\" width=\"{x1-x0}\" height=\"{top+height-y}\" fill=\"#cce4ec\"/>')\n        pr.append(f'<path d=\"M {x0} {y} H {x1}\" stroke=\"#136b87\" stroke-width=\"4\"/>')\n        if interval_i + 1 < len(intervals):\n            next_y = top + (1 - env[intervals[interval_i + 1] + 1]) * height\n            pr.append(f'<path d=\"M {x1} {y} V {next_y}\" stroke=\"#136b87\" stroke-width=\"3\"/>')\n    for i, (r, p) in enumerate(zip(result[\"recall\"], result[\"precision\"])):\n        x, y = left + r * width, top + (1 - p) * height\n        pr += [f'<circle cx=\"{x}\" cy=\"{y}\" r=\"5\" fill=\"#cc662c\"/>',\n               svg_text(x + (10 if x < left + width else -26), y + (18 if i in (0, 3) else -9), f\"P{i+1}\", \"small\")]\n    pr += [svg_text(left + 108, 94, f\"{key} = {result['ap']:.6f}\"),\n           svg_text(left + 130, 451, \"Recall\"), svg_text(left - 38, 85, \"Precision\", \"small\")]\npr += [svg_text(80, 489, \"AP50 = (1/2)*1 + (1/2)*(2/3) = 5/6\"),\n       svg_text(540, 489, \"AP75 = (1/2)*1 + (1/2)*0 = 1/2\"),\n       svg_text(80, 529, \"Repeated recall adds no area; the interval from 0.5 to 1 uses precision 2/3.\", \"small\")]\n(OUT / \"precision_recall.svg\").write_text(svg_document(970, 556, pr), encoding=\"utf-8\")\n\nnms = [svg_text(28, 36, \"The same NMS rule can remove a duplicate or a real object\", \"title\"),\n       svg_text(28, 63, \"Class-aware NMS: suppress same-class boxes only when IoU > 0.50\", \"label\")]\nfor panel, (title, boxes, mutual, before, after) in enumerate([\n        (\"A. Duplicate predictions for one object\", PRED[:2], 9/11, 5/6, 1.0),\n        (\"B. Two adjacent real objects\", NEIGHBOR_GT, .6, 1.0, .5)]):\n    left = 40 + panel * 485\n    nms.append(svg_text(left, 110, title))\n    for i, b in enumerate(boxes):\n        x1, y1, x2, y2 = b\n        nms.append(f'<rect x=\"{left+25+x1*105}\" y=\"{145+y1*85}\" width=\"{(x2-x1)*105}\" '\n                   f'height=\"{(y2-y1)*85}\" fill=\"none\" stroke=\"{colors[i]}\" stroke-width=\"4\" '\n                   + ('stroke-dasharray=\"8 5\"' if i == 1 else '') + '/>')\n    nms += [svg_text(left + 25, 345, f\"Mutual IoU = {mutual:.3f} > 0.50\"),\n            svg_text(left + 25, 373, \"Blue P1 retained; dashed orange P2 removed.\"),\n            svg_text(left + 25, 410, f\"AP50: {before:.6f} -> {after:.6f}\")]\n    if panel == 0:\n        nms += [svg_text(left + 25, 442, \"P2 was a duplicate FP; full-scene AP improves.\", \"small\"),\n                svg_text(left + 25, 465, \"P3 and P4 remain in the original scene.\", \"small\")]\n    else:\n        nms += [svg_text(left + 25, 442, \"P2 was a TP; recall falls from 1.0 to 0.5.\", \"small\"),\n                svg_text(left + 25, 465, \"Changing only NMS threshold to 0.70 keeps both.\", \"small\")]\n(OUT / \"nms_tradeoff.svg\").write_text(svg_document(1000, 505, nms), encoding=\"utf-8\")\n\n# Rich display is optional; SVG files are created above without IPython.\ntry:\n    from IPython.display import SVG, display\n    for figure in [\"geometry.svg\", \"precision_recall.svg\", \"nms_tradeoff.svg\"]:\n        display(SVG(filename=str(OUT / figure)))\nexcept ImportError:\n    print(\"SVG files saved; open them in a browser for viewing.\")\n```","sha256":"c18440913a5b9ceb5beb27a2efb527a7e2ba4dc882038771e5f12bc96458119e","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-ba39de56ef7d4d2882d9441ecd6d1424","title":"可视化与实际输出","number":8},"sectionTitle":"可视化与实际输出","currentQuestion":"可视化与实际输出","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-f9ec3d0a17f12c0f92a6c9ea","nextBlock":null,"prerequisites":[{"id":"b-c77ea7195466ecbb6a57ae76","url":"#b-c77ea7195466ecbb6a57ae76","role":"section-title"},{"id":"b-f9ec3d0a17f12c0f92a6c9ea","url":"#b-f9ec3d0a17f12c0f92a6c9ea","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-b9ebdd7f83987d2976039760","type":"h2","scope":"block-a913f088886f4de38fb1812ed586dc33","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-b9ebdd7f83987d2976039760","content":"## 7 · 只改一个条件，并用结果回答","sha256":"ebb98f4b24db403eca5d1d903cdc5d24617ab8381cf88664d260e17552896a57","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-a913f088886f4de38fb1812ed586dc33","title":"7 · 只改一个条件，并用结果回答","number":9},"sectionTitle":"7 · 只改一个条件，并用结果回答","currentQuestion":"7 · 只改一个条件，并用结果回答","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":null,"nextBlock":"b-c256da9939d0e3298ed3bb1f","prerequisites":[{"id":"b-c256da9939d0e3298ed3bb1f","url":"#b-c256da9939d0e3298ed3bb1f","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-c256da9939d0e3298ed3bb1f","type":"p","scope":"block-a913f088886f4de38fb1812ed586dc33","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-c256da9939d0e3298ed3bb1f","content":"保留基准输入与断言；在新的代码格中用 `.copy()` 创建改动副本，再调用相同函数。这样，固定基准检查继续说明实现是否正确，实验结果说明条件变化产生什么影响。","sha256":"bd9f02bebb512b1aac4ca28214e4d9e2f9af711b21502500271b99671765953a","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-a913f088886f4de38fb1812ed586dc33","title":"7 · 只改一个条件，并用结果回答","number":9},"sectionTitle":"7 · 只改一个条件，并用结果回答","currentQuestion":"7 · 只改一个条件，并用结果回答","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-b9ebdd7f83987d2976039760","nextBlock":"b-70bc3e7057c0ba72168947ab","prerequisites":[{"id":"b-b9ebdd7f83987d2976039760","url":"#b-b9ebdd7f83987d2976039760","role":"section-title"}],"relatedBlocks":[]},{"id":"b-70bc3e7057c0ba72168947ab","type":"ol","scope":"block-a913f088886f4de38fb1812ed586dc33","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-70bc3e7057c0ba72168947ab","content":"- **只改排名：**保持全部坐标和类别不变，把 P2 分数从 0.80 调成 0.60，再重新评价。它排到 P3 后，AP50 会怎样变化？解释为什么最终 recall 没变，AP 却可能变化。\n\n- **只改定位：**保持分数与其他框不变，把 P3 左右边界同时左移 0.4。AP75 改善来自哪个 IoU 变化？不要把它归因于 NMS。\n\n- **只改 NMS 阈值：**比较 0.50 与 0.70 在相邻真对象案例里的保留列表。再尝试更密集或分数顺序颠倒的对象，说明单一阈值何时仍失败。","sha256":"77f4a7ed7148961ee8fe1e2027fc3b53295b9b0116ab4cfd4cbe97c508ad85e9","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-a913f088886f4de38fb1812ed586dc33","title":"7 · 只改一个条件，并用结果回答","number":9},"sectionTitle":"7 · 只改一个条件，并用结果回答","currentQuestion":"7 · 只改一个条件，并用结果回答","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-c256da9939d0e3298ed3bb1f","nextBlock":"b-3745242586e3caa695fa308a","prerequisites":[{"id":"b-b9ebdd7f83987d2976039760","url":"#b-b9ebdd7f83987d2976039760","role":"section-title"},{"id":"b-c256da9939d0e3298ed3bb1f","url":"#b-c256da9939d0e3298ed3bb1f","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-3745242586e3caa695fa308a","type":"li","scope":"block-a913f088886f4de38fb1812ed586dc33","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-3745242586e3caa695fa308a","content":"- **只改排名：**保持全部坐标和类别不变，把 P2 分数从 0.80 调成 0.60，再重新评价。它排到 P3 后，AP50 会怎样变化？解释为什么最终 recall 没变，AP 却可能变化。","sha256":"dc41c5fec58b1b04f3a5a5fe8b0b61c9f5a61bc3be954bd37d1ea6a4295a2fde","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-a913f088886f4de38fb1812ed586dc33","title":"7 · 只改一个条件，并用结果回答","number":9},"sectionTitle":"7 · 只改一个条件，并用结果回答","currentQuestion":"7 · 只改一个条件，并用结果回答","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-70bc3e7057c0ba72168947ab","nextBlock":"b-6768021a6a9e66dd688ef3cf","prerequisites":[{"id":"b-b9ebdd7f83987d2976039760","url":"#b-b9ebdd7f83987d2976039760","role":"section-title"},{"id":"b-c256da9939d0e3298ed3bb1f","url":"#b-c256da9939d0e3298ed3bb1f","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-6768021a6a9e66dd688ef3cf","type":"li","scope":"block-a913f088886f4de38fb1812ed586dc33","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-6768021a6a9e66dd688ef3cf","content":"- **只改定位：**保持分数与其他框不变，把 P3 左右边界同时左移 0.4。AP75 改善来自哪个 IoU 变化？不要把它归因于 NMS。","sha256":"e27a2d1698849889fa3cb6aaf3befb9741c7266a27dbbe57c496796886e53a38","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-a913f088886f4de38fb1812ed586dc33","title":"7 · 只改一个条件，并用结果回答","number":9},"sectionTitle":"7 · 只改一个条件，并用结果回答","currentQuestion":"7 · 只改一个条件，并用结果回答","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-3745242586e3caa695fa308a","nextBlock":"b-a7839f17e85b7d80cbb2ce1f","prerequisites":[{"id":"b-b9ebdd7f83987d2976039760","url":"#b-b9ebdd7f83987d2976039760","role":"section-title"},{"id":"b-c256da9939d0e3298ed3bb1f","url":"#b-c256da9939d0e3298ed3bb1f","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-a7839f17e85b7d80cbb2ce1f","type":"li","scope":"block-a913f088886f4de38fb1812ed586dc33","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-a7839f17e85b7d80cbb2ce1f","content":"- **只改 NMS 阈值：**比较 0.50 与 0.70 在相邻真对象案例里的保留列表。再尝试更密集或分数顺序颠倒的对象，说明单一阈值何时仍失败。","sha256":"6fda65bbb6f74e3e77a80496d57c79f6a7f3114e17a777b2f996a6f1874af583","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-a913f088886f4de38fb1812ed586dc33","title":"7 · 只改一个条件，并用结果回答","number":9},"sectionTitle":"7 · 只改一个条件，并用结果回答","currentQuestion":"7 · 只改一个条件，并用结果回答","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-6768021a6a9e66dd688ef3cf","nextBlock":"b-0ae76de9fdce76c58ac76b93","prerequisites":[{"id":"b-b9ebdd7f83987d2976039760","url":"#b-b9ebdd7f83987d2976039760","role":"section-title"},{"id":"b-c256da9939d0e3298ed3bb1f","url":"#b-c256da9939d0e3298ed3bb1f","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-0ae76de9fdce76c58ac76b93","type":"p","scope":"block-a913f088886f4de38fb1812ed586dc33","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-0ae76de9fdce76c58ac76b93","content":"**完成标准：**保存真实运行输出，核对 `(4,2)` IoU 矩阵、原始 AP50=`5/6` 与 AP75=`0.5`；说明训练分配与评价 one-to-one 的差别；给出 NMS 有帮助与有损害的各一个场景。结论必须写出坐标、阈值、类别条件和 AP 协议。","sha256":"8c292dce79eed500f2e77ca246f34cc348ca0fe5ef5ead4a6d1215ef9019eaae","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-a913f088886f4de38fb1812ed586dc33","title":"7 · 只改一个条件，并用结果回答","number":9},"sectionTitle":"7 · 只改一个条件，并用结果回答","currentQuestion":"7 · 只改一个条件，并用结果回答","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-a7839f17e85b7d80cbb2ce1f","nextBlock":"b-63038113249cf18dea8bccc0","prerequisites":[{"id":"b-b9ebdd7f83987d2976039760","url":"#b-b9ebdd7f83987d2976039760","role":"section-title"},{"id":"b-c256da9939d0e3298ed3bb1f","url":"#b-c256da9939d0e3298ed3bb1f","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-63038113249cf18dea8bccc0","type":"p","scope":"block-a913f088886f4de38fb1812ed586dc33","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-63038113249cf18dea8bccc0","content":"本地运行 `python lab09.py` 会生成 `results.json`、三张 SVG 图与 `run.json`。`run.json` 记录 UTC 执行时间、Python/NumPy 版本、关键结果、输入 SHA-256 与脚本/教学材料/图的 SHA-256。notebook 的代码包含完整输入和函数，按顺序运行即可，不依赖其他 notebook 的内存或磁盘数据。","sha256":"526e7874f051e27d8639e7f2c0514a5a76bdac1b20ba8c44855862c44b788dad","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-a913f088886f4de38fb1812ed586dc33","title":"7 · 只改一个条件，并用结果回答","number":9},"sectionTitle":"7 · 只改一个条件，并用结果回答","currentQuestion":"7 · 只改一个条件，并用结果回答","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-0ae76de9fdce76c58ac76b93","nextBlock":"b-f64c8f33e82a835a1ce6fb76","prerequisites":[{"id":"b-b9ebdd7f83987d2976039760","url":"#b-b9ebdd7f83987d2976039760","role":"section-title"},{"id":"b-c256da9939d0e3298ed3bb1f","url":"#b-c256da9939d0e3298ed3bb1f","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-f64c8f33e82a835a1ce6fb76","type":"pre","scope":"block-7a672ab1408b4a068337b1162bb625a6","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-f64c8f33e82a835a1ce6fb76","content":"```\n# Optional one-condition experiments: preserve the baseline arrays.\nscores_rank_test = SCORES.copy()\nscores_rank_test[1] = .60\nprint(\"P2 score 0.60, AP50:\", evaluate_single_class(PRED, scores_rank_test, GT, .5)[\"ap\"])\n\nboxes_localization_test = PRED.copy()\nboxes_localization_test[2, [0, 2]] -= .4\nprint(\"P3 shifted left 0.4, AP75:\", evaluate_single_class(boxes_localization_test, SCORES, GT, .75)[\"ap\"])\n\nfor threshold in [.50, .70]:\n    candidate_keep, _ = class_aware_nms(NEIGHBOR_GT, NEIGHBOR_SCORES, [0, 0], threshold)\n    print(\"Neighbor NMS\", threshold, \"keeps\", (candidate_keep + 1).tolist(),\n          \"AP50\", evaluate_single_class(NEIGHBOR_GT[candidate_keep],\n                  NEIGHBOR_SCORES[candidate_keep], NEIGHBOR_GT, .5)[\"ap\"])\n```","sha256":"50bf9d16729aff07026fc1fa39d756ef43a34e0ee654b4563b07f7f2581141a2","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-a913f088886f4de38fb1812ed586dc33","title":"7 · 只改一个条件，并用结果回答","number":9},"sectionTitle":"7 · 只改一个条件，并用结果回答","currentQuestion":"7 · 只改一个条件，并用结果回答","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-63038113249cf18dea8bccc0","nextBlock":null,"prerequisites":[{"id":"b-b9ebdd7f83987d2976039760","url":"#b-b9ebdd7f83987d2976039760","role":"section-title"},{"id":"b-c256da9939d0e3298ed3bb1f","url":"#b-c256da9939d0e3298ed3bb1f","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-10cd9d21562dae59c4a6e408","type":"h2","scope":"block-8f24850741144b31ac103742e94f7ecd","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-10cd9d21562dae59c4a6e408","content":"## 来源与范围","sha256":"05e7cc3e088ee4e59b8218982a40098c3dbdae3c8f0ca10282fe366a3bd82991","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-8f24850741144b31ac103742e94f7ecd","title":"来源与范围","number":10},"sectionTitle":"来源与范围","currentQuestion":"来源与范围","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":null,"nextBlock":"b-2b5035afece27be078a5bcdd","prerequisites":[],"relatedBlocks":[]},{"id":"b-2b5035afece27be078a5bcdd","type":"ul","scope":"block-8f24850741144b31ac103742e94f7ecd","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-2b5035afece27be078a5bcdd","content":"- [Dive into Deep Learning：Anchor Boxes](https://d2l.ai/chapter_computer-vision/anchor.html)：连续坐标 IoU、anchor 目标分配与 NMS 机制的官方教材来源。\n\n- all-points AP 是本册明确给出的教学评价协议；计算、上包络、边界处理与断言均可直接检查。此处不声称完整复现某个检测评测工具包。","sha256":"870c939e2b073d1cbd378bda5ca800a161346c8d4796cd66133ef4e2328315a0","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-8f24850741144b31ac103742e94f7ecd","title":"来源与范围","number":10},"sectionTitle":"来源与范围","currentQuestion":"来源与范围","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-10cd9d21562dae59c4a6e408","nextBlock":"b-9fe2f6c5063161e1244b764b","prerequisites":[{"id":"b-10cd9d21562dae59c4a6e408","url":"#b-10cd9d21562dae59c4a6e408","role":"section-title"}],"relatedBlocks":[]},{"id":"b-9fe2f6c5063161e1244b764b","type":"li","scope":"block-8f24850741144b31ac103742e94f7ecd","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-9fe2f6c5063161e1244b764b","content":"- [Dive into Deep Learning：Anchor Boxes](https://d2l.ai/chapter_computer-vision/anchor.html)：连续坐标 IoU、anchor 目标分配与 NMS 机制的官方教材来源。","sha256":"f29b8ca82d736b7b79acf1ad9acf9124d7b36dae07d5aafd2c160eb74f7f6509","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-8f24850741144b31ac103742e94f7ecd","title":"来源与范围","number":10},"sectionTitle":"来源与范围","currentQuestion":"来源与范围","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-2b5035afece27be078a5bcdd","nextBlock":"b-ac571c6884ee52a1d6903408","prerequisites":[{"id":"b-10cd9d21562dae59c4a6e408","url":"#b-10cd9d21562dae59c4a6e408","role":"section-title"}],"relatedBlocks":[]},{"id":"b-ac571c6884ee52a1d6903408","type":"li","scope":"block-8f24850741144b31ac103742e94f7ecd","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-ac571c6884ee52a1d6903408","content":"- all-points AP 是本册明确给出的教学评价协议；计算、上包络、边界处理与断言均可直接检查。此处不声称完整复现某个检测评测工具包。","sha256":"2460f7aafadb5fd135823a52cfd6fcaa18b86c140e37264cb267459a6338b9b8","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-8f24850741144b31ac103742e94f7ecd","title":"来源与范围","number":10},"sectionTitle":"来源与范围","currentQuestion":"来源与范围","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-9fe2f6c5063161e1244b764b","nextBlock":null,"prerequisites":[{"id":"b-10cd9d21562dae59c4a6e408","url":"#b-10cd9d21562dae59c4a6e408","role":"section-title"}],"relatedBlocks":[]},{"id":"b-55c44983e2ac2fa114771e88","type":"h2","scope":"block-e40ebaef99ea481ea734c690ce85f20d","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-55c44983e2ac2fa114771e88","content":"## 本次基准的静态图","sha256":"fc6a0c525e9931316d757c82f13f0c09380475c17371090f5dfd3b3d22ad297e","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-e40ebaef99ea481ea734c690ce85f20d","title":"本次基准的静态图","number":11},"sectionTitle":"本次基准的静态图","currentQuestion":"本次基准的静态图","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":null,"nextBlock":"b-ee9fdeb2fb9f3abdeac9316e","prerequisites":[{"id":"b-ee9fdeb2fb9f3abdeac9316e","url":"#b-ee9fdeb2fb9f3abdeac9316e","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-ee9fdeb2fb9f3abdeac9316e","type":"p","scope":"block-e40ebaef99ea481ea734c690ce85f20d","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-ee9fdeb2fb9f3abdeac9316e","content":"以下三图来自本册已完成本地计算；重新执行绘图格可从同一输入重建。","sha256":"8a733cf37d7a47cc493da01ba8d8fea0bd1d094a6e21f3fc205383ccc0c79049","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-e40ebaef99ea481ea734c690ce85f20d","title":"本次基准的静态图","number":11},"sectionTitle":"本次基准的静态图","currentQuestion":"本次基准的静态图","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-55c44983e2ac2fa114771e88","nextBlock":"b-58718bc54f5c4e0ee9fc1134","prerequisites":[{"id":"b-55c44983e2ac2fa114771e88","url":"#b-55c44983e2ac2fa114771e88","role":"section-title"}],"relatedBlocks":[]},{"id":"b-58718bc54f5c4e0ee9fc1134","type":"p","scope":"block-e40ebaef99ea481ea734c690ce85f20d","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-58718bc54f5c4e0ee9fc1134","content":"![框与匹配](/assets/display/8598b4f35f0c1f867e932c55.webp)","sha256":"54dfc76f35a4a399dcd1cc411d7156370a3d257d6937528aba087b3b3aaaadd3","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-e40ebaef99ea481ea734c690ce85f20d","title":"本次基准的静态图","number":11},"sectionTitle":"本次基准的静态图","currentQuestion":"本次基准的静态图","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-ee9fdeb2fb9f3abdeac9316e","nextBlock":"b-7b3f3e40870cce4e09532f9b","prerequisites":[{"id":"b-55c44983e2ac2fa114771e88","url":"#b-55c44983e2ac2fa114771e88","role":"section-title"},{"id":"b-ee9fdeb2fb9f3abdeac9316e","url":"#b-ee9fdeb2fb9f3abdeac9316e","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-7b3f3e40870cce4e09532f9b","type":"p","scope":"block-e40ebaef99ea481ea734c690ce85f20d","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-7b3f3e40870cce4e09532f9b","content":"![precision–recall 与 AP](/assets/display/b723b855b886fdcda83717ce.webp)","sha256":"bbd713be3eb0316d1c91a573153ab103264b8ee6fbd92ddec04cd0b708637d0b","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-e40ebaef99ea481ea734c690ce85f20d","title":"本次基准的静态图","number":11},"sectionTitle":"本次基准的静态图","currentQuestion":"本次基准的静态图","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-58718bc54f5c4e0ee9fc1134","nextBlock":"b-8765b7e2729993bd9a56ff0c","prerequisites":[{"id":"b-55c44983e2ac2fa114771e88","url":"#b-55c44983e2ac2fa114771e88","role":"section-title"},{"id":"b-ee9fdeb2fb9f3abdeac9316e","url":"#b-ee9fdeb2fb9f3abdeac9316e","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-8765b7e2729993bd9a56ff0c","type":"p","scope":"block-e40ebaef99ea481ea734c690ce85f20d","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-8765b7e2729993bd9a56ff0c","content":"![NMS 阈值对照](/assets/display/f0262a290b9cdbe851e2f89b.webp)","sha256":"d77aab495c80eb136858da9d881b37f94cdf29efe1c9ac455a23af826e814f48","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-e40ebaef99ea481ea734c690ce85f20d","title":"本次基准的静态图","number":11},"sectionTitle":"本次基准的静态图","currentQuestion":"本次基准的静态图","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-7b3f3e40870cce4e09532f9b","nextBlock":null,"prerequisites":[{"id":"b-55c44983e2ac2fa114771e88","url":"#b-55c44983e2ac2fa114771e88","role":"section-title"},{"id":"b-ee9fdeb2fb9f3abdeac9316e","url":"#b-ee9fdeb2fb9f3abdeac9316e","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-7313dbb71185ddecd04a5340","type":"h2","scope":"block-01778787c2ab4952b60963cbffd5b7c1","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-7313dbb71185ddecd04a5340","content":"## 运行记录","sha256":"0275f594bfdeff793c216d3ae029477ac23be2ba06aef0a1fdd00a301c326c99","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-01778787c2ab4952b60963cbffd5b7c1","title":"运行记录","number":12},"sectionTitle":"运行记录","currentQuestion":"运行记录","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":null,"nextBlock":"b-343c8f3b441ccfd63f5ed7c2","prerequisites":[{"id":"b-343c8f3b441ccfd63f5ed7c2","url":"#b-343c8f3b441ccfd63f5ed7c2","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-343c8f3b441ccfd63f5ed7c2","type":"p","scope":"block-01778787c2ab4952b60963cbffd5b7c1","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-343c8f3b441ccfd63f5ed7c2","content":"此格记录本次运行时间、环境、输入和输出哈希。在独立 notebook 中，只记录本次目录里实际存在的文件；完整交付的本地运行还记录脚本与 notebook 本身的哈希。","sha256":"6ff95e585147719b3e0f87ccfe14c93bc1747bc857cac639b8984dc6bee40715","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-01778787c2ab4952b60963cbffd5b7c1","title":"运行记录","number":12},"sectionTitle":"运行记录","currentQuestion":"运行记录","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-7313dbb71185ddecd04a5340","nextBlock":"b-fe4c064ad7ec41d6b99e2c39","prerequisites":[{"id":"b-7313dbb71185ddecd04a5340","url":"#b-7313dbb71185ddecd04a5340","role":"section-title"}],"relatedBlocks":[]},{"id":"b-fe4c064ad7ec41d6b99e2c39","type":"pre","scope":"block-66bcd9627b4841bfbeed4228ff02efd7","url":"https://codingai-lec03.pages.dev/course/lab09-检测几何-框匹配nms-与-ap.html#b-fe4c064ad7ec41d6b99e2c39","content":"```\nartifact_names = [\"lab09.py\", \"notebook.json\", \"teaching.md\", \"results.json\",\n                  \"geometry.svg\", \"precision_recall.svg\", \"nms_tradeoff.svg\"]\nartifact_hashes = {name: hashlib.sha256((OUT / name).read_bytes()).hexdigest()\n                   for name in artifact_names if (OUT / name).exists()}\ninput_json = json.dumps({\"gt\": GT.tolist(), \"pred\": PRED.tolist(), \"scores\": SCORES.tolist(),\n                         \"nms_threshold\": NMS_THRESHOLD, \"eval_thresholds\": EVAL_THRESHOLDS},\n                        sort_keys=True, separators=(\",\", \":\"))\nmanifest = {\"notebook_id\": \"90d213b4e1e04c7e889ee6fc042b2358\",\n            \"notebook_name\": \"LAB 09 · 检测几何：框、匹配、NMS 与 AP\",\n            \"started_at_utc\": STARTED_AT, \"finished_at_utc\": datetime.now(timezone.utc).isoformat(),\n            \"elapsed_seconds\": time.perf_counter() - STARTED_CLOCK,\n            \"execution\": \"actual local Python execution\", \"status\": \"passed\",\n            \"command\": \"python lab09.py\", \"python_version\": platform.python_version(),\n            \"numpy_version\": np.__version__, \"input_sha256\": hashlib.sha256(input_json.encode()).hexdigest(),\n            \"sha256\": artifact_hashes, \"key_results\": {\"AP50\": baseline[\"AP50\"][\"ap\"],\n                \"AP75\": baseline[\"AP75\"][\"ap\"], \"nms_AP50\": after_nms[\"AP50\"][\"ap\"],\n                \"nms_AP75\": after_nms[\"AP75\"][\"ap\"], \"neighbor_nms_AP50\": neighbor_after[\"ap\"],\n                \"protocol_duplicate_AP50\": protocol_standard[\"ap\"],\n                \"alternative_best_unused_AP50\": alternative_ap}}\n(OUT / \"run.json\").write_text(json.dumps(manifest, ensure_ascii=False, indent=2), encoding=\"utf-8\")\nprint(\"Assertions: passed. Saved results.json, 3 SVG figures and run.json.\")\n```","sha256":"1718e1bbf0c46a010b36c4464afbdce3baf82362119649cbefa63486b8b19683","chapter":{"id":"course","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"unit":{"id":"lab09-检测几何-框匹配nms-与-ap","title":"LAB 09 · 检测几何：框、匹配、NMS 与 AP"},"page":{"id":"reading-block-01778787c2ab4952b60963cbffd5b7c1","title":"运行记录","number":12},"sectionTitle":"运行记录","currentQuestion":"运行记录","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-343c8f3b441ccfd63f5ed7c2","nextBlock":null,"prerequisites":[{"id":"b-7313dbb71185ddecd04a5340","url":"#b-7313dbb71185ddecd04a5340","role":"section-title"},{"id":"b-343c8f3b441ccfd63f5ed7c2","url":"#b-343c8f3b441ccfd63f5ed7c2","role":"problem-context"}],"relatedBlocks":[]}]}
