{"id":70839,"date":"2026-02-02T13:49:34","date_gmt":"2026-02-02T05:49:34","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/70839.html"},"modified":"2026-02-02T13:49:34","modified_gmt":"2026-02-02T05:49:34","slug":"%e3%80%90%e5%ae%8c%e6%95%b4%e6%ba%90%e7%a0%81%e6%95%b0%e6%8d%ae%e9%9b%86%e9%83%a8%e7%bd%b2%e6%95%99%e7%a8%8b%e3%80%91%e5%bf%ab%e9%80%92%e7%9b%92%e6%a3%80%e6%b5%8b%e6%a3%80%e6%b5%8b%e7%b3%bb%e7%bb%9f","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/70839.html","title":{"rendered":"\u3010\u5b8c\u6574\u6e90\u7801+\u6570\u636e\u96c6+\u90e8\u7f72\u6559\u7a0b\u3011\u5feb\u9012\u76d2\u68c0\u6d4b\u68c0\u6d4b\u7cfb\u7edf\u6e90\u7801 [\u4e00\u6761\u9f99\u6559\u5b66YOLOV8\u6807\u6ce8\u597d\u7684\u6570\u636e\u96c6\u4e00\u952e\u8bad\u7ec3_70+\u5168\u5957\u6539\u8fdb\u521b\u65b0\u70b9\u53d1\u520a_Web\u524d\u7aef\u5c55\u793a]"},"content":{"rendered":"<h2>\u80cc\u666f\u610f\u4e49<\/h2>\n<p>\u968f\u7740\u7535\u5b50\u5546\u52a1\u7684\u8fc5\u731b\u53d1\u5c55&#xff0c;\u5feb\u9012\u884c\u4e1a\u4e5f\u968f\u4e4b\u84ec\u52c3\u5174\u8d77&#xff0c;\u5feb\u9012\u5305\u88f9\u7684\u6570\u91cf\u65e5\u76ca\u589e\u52a0\u3002\u6839\u636e\u7edf\u8ba1\u6570\u636e&#xff0c;\u5168\u7403\u5feb\u9012\u5e02\u573a\u7684\u5e74\u589e\u957f\u7387\u5df2\u8d85\u8fc710%&#xff0c;\u9884\u8ba1\u5728\u672a\u6765\u51e0\u5e74\u5185\u5c06\u7ee7\u7eed\u4fdd\u6301\u8fd9\u4e00\u589e\u957f\u8d8b\u52bf\u3002\u5728\u8fd9\u4e00\u80cc\u666f\u4e0b&#xff0c;\u5feb\u9012\u5305\u88f9\u7684\u7ba1\u7406\u548c\u5904\u7406\u6548\u7387\u6210\u4e3a\u4e86\u884c\u4e1a\u5185\u4e9f\u5f85\u89e3\u51b3\u7684\u91cd\u8981\u95ee\u9898\u3002\u4f20\u7edf\u7684\u5feb\u9012\u5305\u88f9\u68c0\u6d4b\u65b9\u6cd5\u5f80\u5f80\u4f9d\u8d56\u4eba\u5de5\u64cd\u4f5c&#xff0c;\u4e0d\u4ec5\u6548\u7387\u4f4e\u4e0b&#xff0c;\u800c\u4e14\u5bb9\u6613\u53d7\u5230\u4eba\u4e3a\u56e0\u7d20\u7684\u5f71\u54cd&#xff0c;\u5bfc\u81f4\u9519\u8bef\u7387\u8f83\u9ad8\u3002\u56e0\u6b64&#xff0c;\u57fa\u4e8e\u8ba1\u7b97\u673a\u89c6\u89c9\u7684\u81ea\u52a8\u5316\u68c0\u6d4b\u7cfb\u7edf\u5e94\u8fd0\u800c\u751f&#xff0c;\u6210\u4e3a\u63d0\u5347\u5feb\u9012\u5904\u7406\u6548\u7387\u548c\u51c6\u786e\u6027\u7684\u91cd\u8981\u624b\u6bb5\u3002<\/p>\n<p>\u5728\u4f17\u591a\u8ba1\u7b97\u673a\u89c6\u89c9\u6280\u672f\u4e2d&#xff0c;\u76ee\u6807\u68c0\u6d4b\u6280\u672f\u56e0\u5176\u5728\u5b9e\u65f6\u6027\u548c\u51c6\u786e\u6027\u65b9\u9762\u7684\u4f18\u52bf&#xff0c;\u9010\u6e10\u6210\u4e3a\u5feb\u9012\u5305\u88f9\u68c0\u6d4b\u7684\u4e3b\u6d41\u9009\u62e9\u3002YOLO&#xff08;You Only Look Once&#xff09;\u7cfb\u5217\u6a21\u578b\u4ee5\u5176\u9ad8\u6548\u7684\u7279\u6027\u53d7\u5230\u5e7f\u6cdb\u5173\u6ce8\u3002YOLOv8\u4f5c\u4e3a\u8be5\u7cfb\u5217\u7684\u6700\u65b0\u7248\u672c&#xff0c;\u7ed3\u5408\u4e86\u6df1\u5ea6\u5b66\u4e60\u7684\u5148\u8fdb\u6280\u672f&#xff0c;\u80fd\u591f\u5728\u4fdd\u6301\u9ad8\u7cbe\u5ea6\u7684\u540c\u65f6\u5b9e\u73b0\u5feb\u901f\u7684\u76ee\u6807\u68c0\u6d4b\u3002\u7136\u800c&#xff0c;\u5c3d\u7ba1YOLOv8\u5728\u591a\u79cd\u5e94\u7528\u573a\u666f\u4e2d\u8868\u73b0\u51fa\u8272&#xff0c;\u4f46\u5728\u7279\u5b9a\u9886\u57df\u5982\u5feb\u9012\u76d2\u68c0\u6d4b\u4e2d&#xff0c;\u4ecd\u7136\u5b58\u5728\u4e00\u4e9b\u6311\u6218&#xff0c;\u4f8b\u5982\u5bf9\u4e0d\u540c\u5c3a\u5bf8\u3001\u5f62\u72b6\u548c\u989c\u8272\u7684\u5feb\u9012\u76d2\u7684\u8bc6\u522b\u80fd\u529b&#xff0c;\u4ee5\u53ca\u5728\u590d\u6742\u80cc\u666f\u4e0b\u7684\u68c0\u6d4b\u51c6\u786e\u6027\u7b49\u3002\u56e0\u6b64&#xff0c;\u9488\u5bf9\u5feb\u9012\u76d2\u68c0\u6d4b\u4efb\u52a1\u5bf9YOLOv8\u8fdb\u884c\u6539\u8fdb\u548c\u4f18\u5316&#xff0c;\u5177\u6709\u91cd\u8981\u7684\u7814\u7a76\u610f\u4e49\u3002<\/p>\n<p>\u672c\u7814\u7a76\u6240\u4f7f\u7528\u7684\u6570\u636e\u96c6\u5305\u542b7815\u5f20\u56fe\u50cf&#xff0c;\u6db5\u76d6\u4e86\u56db\u4e2a\u7c7b\u522b\u7684\u5feb\u9012\u76d2&#xff0c;\u5206\u522b\u4e3a0\u30011\u300115\u548cbox\u3002\u8fd9\u4e00\u6570\u636e\u96c6\u7684\u6784\u5efa\u4e3a\u6a21\u578b\u7684\u8bad\u7ec3\u548c\u8bc4\u4f30\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u6837\u672c&#xff0c;\u80fd\u591f\u6709\u6548\u652f\u6301\u76ee\u6807\u68c0\u6d4b\u7b97\u6cd5\u7684\u4f18\u5316\u4e0e\u6539\u8fdb\u3002\u901a\u8fc7\u5bf9\u6570\u636e\u96c6\u7684\u6df1\u5165\u5206\u6790&#xff0c;\u6211\u4eec\u53ef\u4ee5\u8bc6\u522b\u51fa\u5feb\u9012\u76d2\u5728\u4e0d\u540c\u73af\u5883\u4e0b\u7684\u7279\u5f81&#xff0c;\u8fdb\u800c\u9488\u5bf9\u6027\u5730\u8c03\u6574YOLOv8\u7684\u7f51\u7edc\u7ed3\u6784\u548c\u53c2\u6570\u8bbe\u7f6e&#xff0c;\u4ee5\u63d0\u9ad8\u5176\u5728\u5feb\u9012\u76d2\u68c0\u6d4b\u4e2d\u7684\u8868\u73b0\u3002\u6b64\u5916&#xff0c;\u6570\u636e\u96c6\u7684\u591a\u6837\u6027\u4e5f\u4e3a\u6a21\u578b\u7684\u6cdb\u5316\u80fd\u529b\u63d0\u4f9b\u4e86\u4fdd\u969c&#xff0c;\u4f7f\u5176\u80fd\u591f\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\u9002\u5e94\u4e0d\u540c\u7684\u5feb\u9012\u573a\u666f\u3002<\/p>\n<p>\u672c\u7814\u7a76\u7684\u610f\u4e49\u4e0d\u4ec5\u5728\u4e8e\u63d0\u5347\u5feb\u9012\u76d2\u7684\u68c0\u6d4b\u7cbe\u5ea6\u548c\u6548\u7387&#xff0c;\u66f4\u5728\u4e8e\u63a8\u52a8\u5feb\u9012\u884c\u4e1a\u7684\u667a\u80fd\u5316\u8fdb\u7a0b\u3002\u901a\u8fc7\u5f15\u5165\u5148\u8fdb\u7684\u76ee\u6807\u68c0\u6d4b\u6280\u672f&#xff0c;\u6211\u4eec\u53ef\u4ee5\u5b9e\u73b0\u5feb\u9012\u5305\u88f9\u7684\u81ea\u52a8\u5316\u7ba1\u7406&#xff0c;\u964d\u4f4e\u4eba\u5de5\u6210\u672c&#xff0c;\u63d0\u9ad8\u5de5\u4f5c\u6548\u7387&#xff0c;\u8fdb\u800c\u4e3a\u5feb\u9012\u884c\u4e1a\u7684\u53ef\u6301\u7eed\u53d1\u5c55\u63d0\u4f9b\u6709\u529b\u652f\u6301\u3002\u540c\u65f6&#xff0c;\u7814\u7a76\u6210\u679c\u4e5f\u5c06\u4e3a\u5176\u4ed6\u9886\u57df\u7684\u76ee\u6807\u68c0\u6d4b\u4efb\u52a1\u63d0\u4f9b\u501f\u9274&#xff0c;\u63a8\u52a8\u8ba1\u7b97\u673a\u89c6\u89c9\u6280\u672f\u7684\u5e7f\u6cdb\u5e94\u7528\u3002<\/p>\n<p>\u7efc\u4e0a\u6240\u8ff0&#xff0c;\u57fa\u4e8e\u6539\u8fdbYOLOv8\u7684\u5feb\u9012\u76d2\u68c0\u6d4b\u7cfb\u7edf\u7684\u7814\u7a76&#xff0c;\u4e0d\u4ec5\u5177\u6709\u91cd\u8981\u7684\u7406\u8bba\u4ef7\u503c&#xff0c;\u4e5f\u5177\u5907\u663e\u8457\u7684\u5b9e\u9645\u5e94\u7528\u524d\u666f\u3002\u901a\u8fc7\u6df1\u5165\u63a2\u8ba8\u548c\u4f18\u5316\u76ee\u6807\u68c0\u6d4b\u6280\u672f&#xff0c;\u6211\u4eec\u671f\u5f85\u80fd\u591f\u4e3a\u5feb\u9012\u884c\u4e1a\u7684\u667a\u80fd\u5316\u8f6c\u578b\u8d21\u732e\u4e00\u4efd\u529b\u91cf&#xff0c;\u540c\u65f6\u4e3a\u76f8\u5173\u9886\u57df\u7684\u7814\u7a76\u63d0\u4f9b\u65b0\u7684\u601d\u8def\u548c\u65b9\u6cd5\u3002<\/p>\n<h2>\u56fe\u7247\u6548\u679c<\/h2>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260202054924-69803ae457a04.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260202054927-69803ae711292.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260202054929-69803ae9a21ee.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h2>\u6570\u636e\u96c6\u4fe1\u606f<\/h2>\n<p>\u5728\u672c\u7814\u7a76\u4e2d&#xff0c;\u6211\u4eec\u4f7f\u7528\u4e86\u540d\u4e3a\u201c1_box\u201d\u7684\u6570\u636e\u96c6&#xff0c;\u4ee5\u6539\u8fdbYOLOv8\u7684\u5feb\u9012\u76d2\u68c0\u6d4b\u7cfb\u7edf\u3002\u8be5\u6570\u636e\u96c6\u4e13\u95e8\u4e3a\u5feb\u9012\u76d2\u7684\u68c0\u6d4b\u4efb\u52a1\u800c\u8bbe\u8ba1&#xff0c;\u5305\u542b\u4e86\u4e30\u5bcc\u7684\u6837\u672c\u548c\u591a\u6837\u7684\u573a\u666f&#xff0c;\u65e8\u5728\u63d0\u9ad8\u6a21\u578b\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\u7684\u51c6\u786e\u6027\u548c\u9c81\u68d2\u6027\u3002\u6570\u636e\u96c6\u7684\u7c7b\u522b\u6570\u91cf\u4e3a\u56db\u4e2a&#xff0c;\u5177\u4f53\u7c7b\u522b\u5305\u62ec\u201c0\u201d\u3001\u201c1\u201d\u3001\u201c15\u201d\u548c\u201cbox\u201d\u3002\u8fd9\u4e9b\u7c7b\u522b\u4ee3\u8868\u4e86\u4e0d\u540c\u7c7b\u578b\u7684\u5feb\u9012\u76d2&#xff0c;\u6db5\u76d6\u4e86\u4ece\u5e38\u89c1\u7684\u6807\u51c6\u5feb\u9012\u76d2\u5230\u7279\u6b8a\u5f62\u72b6\u548c\u5c3a\u5bf8\u7684\u5305\u88c5&#xff0c;\u786e\u4fdd\u4e86\u6a21\u578b\u5728\u591a\u79cd\u60c5\u51b5\u4e0b\u7684\u6709\u6548\u6027\u3002<\/p>\n<p>\u201c1_box\u201d\u6570\u636e\u96c6\u7684\u6784\u5efa\u7ecf\u8fc7\u7cbe\u5fc3\u8bbe\u8ba1&#xff0c;\u5305\u542b\u4e86\u5927\u91cf\u7684\u6807\u6ce8\u56fe\u50cf&#xff0c;\u6db5\u76d6\u4e86\u5404\u79cd\u5149\u7167\u6761\u4ef6\u3001\u80cc\u666f\u73af\u5883\u548c\u62cd\u6444\u89d2\u5ea6\u3002\u8fd9\u4e9b\u56fe\u50cf\u4e0d\u4ec5\u5c55\u793a\u4e86\u5feb\u9012\u76d2\u7684\u4e0d\u540c\u5916\u89c2&#xff0c;\u8fd8\u8003\u8651\u4e86\u4e0d\u540c\u7684\u906e\u6321\u60c5\u51b5\u548c\u590d\u6742\u7684\u80cc\u666f&#xff0c;\u4ee5\u589e\u5f3a\u6a21\u578b\u7684\u6cdb\u5316\u80fd\u529b\u3002\u6570\u636e\u96c6\u4e2d\u7684\u6bcf\u4e00\u5f20\u56fe\u50cf\u90fd\u7ecf\u8fc7\u4e13\u4e1a\u6807\u6ce8&#xff0c;\u786e\u4fdd\u4e86\u76ee\u6807\u7269\u4f53\u7684\u51c6\u786e\u5b9a\u4f4d\u548c\u7c7b\u522b\u8bc6\u522b\u3002\u8fd9\u79cd\u9ad8\u8d28\u91cf\u7684\u6807\u6ce8\u6570\u636e\u4e3aYOLOv8\u6a21\u578b\u7684\u8bad\u7ec3\u63d0\u4f9b\u4e86\u575a\u5b9e\u7684\u57fa\u7840&#xff0c;\u4f7f\u5176\u80fd\u591f\u5728\u5feb\u9012\u76d2\u68c0\u6d4b\u4efb\u52a1\u4e2d\u5b9e\u73b0\u66f4\u9ad8\u7684\u51c6\u786e\u7387\u3002<\/p>\n<p>\u5728\u6570\u636e\u96c6\u7684\u4f7f\u7528\u8fc7\u7a0b\u4e2d&#xff0c;\u6211\u4eec\u5c06\u5176\u5212\u5206\u4e3a\u8bad\u7ec3\u96c6\u548c\u9a8c\u8bc1\u96c6&#xff0c;\u4ee5\u4fbf\u4e8e\u5bf9\u6a21\u578b\u7684\u6027\u80fd\u8fdb\u884c\u8bc4\u4f30\u548c\u8c03\u4f18\u3002\u8bad\u7ec3\u96c6\u5305\u542b\u4e86\u5927\u90e8\u5206\u6837\u672c&#xff0c;\u7528\u4e8e\u6a21\u578b\u7684\u5b66\u4e60\u548c\u53c2\u6570\u4f18\u5316&#xff0c;\u800c\u9a8c\u8bc1\u96c6\u5219\u7528\u4e8e\u5b9e\u65f6\u76d1\u6d4b\u6a21\u578b\u5728\u672a\u89c1\u6570\u636e\u4e0a\u7684\u8868\u73b0\u3002\u901a\u8fc7\u8fd9\u79cd\u5212\u5206&#xff0c;\u6211\u4eec\u80fd\u591f\u6709\u6548\u5730\u907f\u514d\u8fc7\u62df\u5408\u73b0\u8c61&#xff0c;\u786e\u4fdd\u6a21\u578b\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\u7684\u53ef\u9760\u6027\u3002<\/p>\n<p>\u4e3a\u4e86\u8fdb\u4e00\u6b65\u63d0\u5347\u6a21\u578b\u7684\u6027\u80fd&#xff0c;\u6211\u4eec\u8fd8\u5bf9\u6570\u636e\u96c6\u8fdb\u884c\u4e86\u6570\u636e\u589e\u5f3a\u5904\u7406\u3002\u8fd9\u5305\u62ec\u56fe\u50cf\u7684\u65cb\u8f6c\u3001\u7f29\u653e\u3001\u88c1\u526a\u3001\u7ffb\u8f6c\u4ee5\u53ca\u989c\u8272\u8c03\u6574\u7b49\u64cd\u4f5c&#xff0c;\u4ee5\u589e\u52a0\u6570\u636e\u7684\u591a\u6837\u6027\u548c\u4e30\u5bcc\u6027\u3002\u8fd9\u79cd\u589e\u5f3a\u7b56\u7565\u4e0d\u4ec5\u63d0\u9ad8\u4e86\u6a21\u578b\u7684\u9c81\u68d2\u6027&#xff0c;\u8fd8\u5e2e\u52a9\u6a21\u578b\u66f4\u597d\u5730\u9002\u5e94\u4e0d\u540c\u7684\u5e94\u7528\u573a\u666f&#xff0c;\u4f8b\u5982\u5728\u5feb\u9012\u6295\u9012\u8fc7\u7a0b\u4e2d\u53ef\u80fd\u9047\u5230\u7684\u5404\u79cd\u590d\u6742\u73af\u5883\u3002<\/p>\n<p>\u6b64\u5916&#xff0c;\u6570\u636e\u96c6\u7684\u8bbe\u8ba1\u4e5f\u8003\u8651\u5230\u4e86\u5feb\u9012\u884c\u4e1a\u7684\u5b9e\u9645\u9700\u6c42\u3002\u968f\u7740\u7535\u5b50\u5546\u52a1\u7684\u5feb\u901f\u53d1\u5c55&#xff0c;\u5feb\u9012\u76d2\u7684\u79cd\u7c7b\u548c\u5f62\u72b6\u65e5\u76ca\u591a\u6837\u5316&#xff0c;\u56e0\u6b64\u201c1_box\u201d\u6570\u636e\u96c6\u7684\u7c7b\u522b\u8bbe\u7f6e\u6db5\u76d6\u4e86\u5e38\u89c1\u7684\u5feb\u9012\u76d2\u7c7b\u578b&#xff0c;\u4f7f\u5f97\u8bad\u7ec3\u51fa\u7684\u6a21\u578b\u80fd\u591f\u6709\u6548\u5e94\u5bf9\u5e02\u573a\u4e0a\u5404\u79cd\u5feb\u9012\u76d2\u7684\u68c0\u6d4b\u9700\u6c42\u3002\u8fd9\u4e00\u7279\u6027\u4f7f\u5f97\u6211\u4eec\u7684\u5feb\u9012\u76d2\u68c0\u6d4b\u7cfb\u7edf\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\u5177\u6709\u8f83\u9ad8\u7684\u5b9e\u7528\u4ef7\u503c\u3002<\/p>\n<p>\u603b\u4e4b&#xff0c;\u201c1_box\u201d\u6570\u636e\u96c6\u4e3a\u6539\u8fdbYOLOv8\u7684\u5feb\u9012\u76d2\u68c0\u6d4b\u7cfb\u7edf\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u6837\u672c\u548c\u9ad8\u8d28\u91cf\u7684\u6807\u6ce8&#xff0c;\u786e\u4fdd\u4e86\u6a21\u578b\u7684\u8bad\u7ec3\u548c\u8bc4\u4f30\u8fc7\u7a0b\u7684\u79d1\u5b66\u6027\u548c\u6709\u6548\u6027\u3002\u901a\u8fc7\u5bf9\u6570\u636e\u96c6\u7684\u5408\u7406\u5229\u7528&#xff0c;\u6211\u4eec\u671f\u671b\u80fd\u591f\u63d0\u5347\u5feb\u9012\u76d2\u68c0\u6d4b\u7684\u51c6\u786e\u6027\u548c\u6548\u7387&#xff0c;\u4e3a\u5feb\u9012\u884c\u4e1a\u7684\u667a\u80fd\u5316\u53d1\u5c55\u8d21\u732e\u529b\u91cf\u3002<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260202054932-69803aece79c1.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260202054933-69803aed1ab4f.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260202054933-69803aed57bb7.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260202054933-69803aed715fe.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260202054933-69803aed87d89.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h2>\u6838\u5fc3\u4ee3\u7801<\/h2>\n<p>&#096;&#096;&#096;python<br \/>\n# Ultralytics YOLO &#x1f680;, AGPL-3.0 license<\/p>\n<p>from pathlib import Path<br \/>\nimport numpy as np<br \/>\nimport torch<br \/>\nfrom ultralytics.models.yolo.detect import DetectionValidator<br \/>\nfrom ultralytics.utils import LOGGER, ops<br \/>\nfrom ultralytics.utils.metrics import PoseMetrics, box_iou, kpt_iou<br \/>\nfrom ultralytics.utils.plotting import output_to_target, plot_images<\/p>\n<p>class PoseValidator(DetectionValidator):<br \/>\n    &#034;&#034;&#034;<br \/>\n    PoseValidator\u7c7b\u6269\u5c55\u4e86DetectionValidator\u7c7b&#xff0c;\u7528\u4e8e\u57fa\u4e8e\u59ff\u6001\u6a21\u578b\u7684\u9a8c\u8bc1\u3002<br \/>\n    &#034;&#034;&#034;<\/p>\n<p>    def __init__(self, dataloader&#061;None, save_dir&#061;None, pbar&#061;None, args&#061;None, _callbacks&#061;None):<br \/>\n        &#034;&#034;&#034;\u521d\u59cb\u5316PoseValidator\u5bf9\u8c61&#xff0c;\u8bbe\u7f6e\u81ea\u5b9a\u4e49\u53c2\u6570\u548c\u5c5e\u6027\u3002&#034;&#034;&#034;<br \/>\n        super().__init__(dataloader, save_dir, pbar, args, _callbacks)<br \/>\n        self.sigma &#061; None  # \u7528\u4e8e\u8ba1\u7b97\u5173\u952e\u70b9\u7684\u6807\u51c6\u5dee<br \/>\n        self.kpt_shape &#061; None  # \u5173\u952e\u70b9\u7684\u5f62\u72b6<br \/>\n        self.args.task &#061; &#039;pose&#039;  # \u8bbe\u7f6e\u4efb\u52a1\u7c7b\u578b\u4e3a\u59ff\u6001\u4f30\u8ba1<br \/>\n        self.metrics &#061; PoseMetrics(save_dir&#061;self.save_dir, on_plot&#061;self.on_plot)  # \u521d\u59cb\u5316\u59ff\u6001\u5ea6\u91cf<br \/>\n        if isinstance(self.args.device, str) and self.args.device.lower() &#061;&#061; &#039;mps&#039;:<br \/>\n            LOGGER.warning(&#034;WARNING \u26a0\ufe0f Apple MPS known Pose bug. Recommend &#039;device&#061;cpu&#039; for Pose models.&#034;)<\/p>\n<p>    def preprocess(self, batch):<br \/>\n        &#034;&#034;&#034;\u9884\u5904\u7406\u6279\u6b21\u6570\u636e&#xff0c;\u5c06\u5173\u952e\u70b9\u6570\u636e\u8f6c\u6362\u4e3a\u6d6e\u70b9\u6570\u5e76\u79fb\u52a8\u5230\u8bbe\u5907\u4e0a\u3002&#034;&#034;&#034;<br \/>\n        batch &#061; super().preprocess(batch)  # \u8c03\u7528\u7236\u7c7b\u7684\u9884\u5904\u7406\u65b9\u6cd5<br \/>\n        batch[&#039;keypoints&#039;] &#061; batch[&#039;keypoints&#039;].to(self.device).float()  # \u8f6c\u6362\u5173\u952e\u70b9\u6570\u636e\u7c7b\u578b<br \/>\n        return batch<\/p>\n<p>    def postprocess(self, preds):<br \/>\n        &#034;&#034;&#034;\u5e94\u7528\u975e\u6700\u5927\u6291\u5236&#xff0c;\u8fd4\u56de\u9ad8\u7f6e\u4fe1\u5ea6\u7684\u68c0\u6d4b\u7ed3\u679c\u3002&#034;&#034;&#034;<br \/>\n        return ops.non_max_suppression(preds,<br \/>\n                                       self.args.conf,<br \/>\n                                       self.args.iou,<br \/>\n                                       labels&#061;self.lb,<br \/>\n                                       multi_label&#061;True,<br \/>\n                                       agnostic&#061;self.args.single_cls,<br \/>\n                                       max_det&#061;self.args.max_det,<br \/>\n                                       nc&#061;self.nc)<\/p>\n<p>    def init_metrics(self, model):<br \/>\n        &#034;&#034;&#034;\u521d\u59cb\u5316YOLO\u6a21\u578b\u7684\u59ff\u6001\u4f30\u8ba1\u5ea6\u91cf\u3002&#034;&#034;&#034;<br \/>\n        super().init_metrics(model)  # \u8c03\u7528\u7236\u7c7b\u7684\u521d\u59cb\u5316\u65b9\u6cd5<br \/>\n        self.kpt_shape &#061; self.data[&#039;kpt_shape&#039;]  # \u83b7\u53d6\u5173\u952e\u70b9\u5f62\u72b6<br \/>\n        is_pose &#061; self.kpt_shape &#061;&#061; [17, 3]  # \u5224\u65ad\u662f\u5426\u4e3a\u59ff\u6001\u6a21\u578b<br \/>\n        nkpt &#061; self.kpt_shape[0]  # \u5173\u952e\u70b9\u6570\u91cf<br \/>\n        self.sigma &#061; OKS_SIGMA if is_pose else np.ones(nkpt) \/ nkpt  # \u8bbe\u7f6e\u6807\u51c6\u5dee<\/p>\n<p>    def update_metrics(self, preds, batch):<br \/>\n        &#034;&#034;&#034;\u66f4\u65b0\u5ea6\u91cf\u6307\u6807\u3002&#034;&#034;&#034;<br \/>\n        for si, pred in enumerate(preds):<br \/>\n            idx &#061; batch[&#039;batch_idx&#039;] &#061;&#061; si  # \u83b7\u53d6\u5f53\u524d\u6279\u6b21\u7684\u7d22\u5f15<br \/>\n            cls &#061; batch[&#039;cls&#039;][idx]  # \u83b7\u53d6\u5f53\u524d\u6279\u6b21\u7684\u7c7b\u522b<br \/>\n            bbox &#061; batch[&#039;bboxes&#039;][idx]  # \u83b7\u53d6\u5f53\u524d\u6279\u6b21\u7684\u8fb9\u754c\u6846<br \/>\n            kpts &#061; batch[&#039;keypoints&#039;][idx]  # \u83b7\u53d6\u5f53\u524d\u6279\u6b21\u7684\u5173\u952e\u70b9<br \/>\n            nl, npr &#061; cls.shape[0], pred.shape[0]  # \u6807\u7b7e\u6570\u91cf\u548c\u9884\u6d4b\u6570\u91cf<br \/>\n            nk &#061; kpts.shape[1]  # \u5173\u952e\u70b9\u6570\u91cf<br \/>\n            shape &#061; batch[&#039;ori_shape&#039;][si]  # \u539f\u59cb\u56fe\u50cf\u5f62\u72b6<br \/>\n            correct_kpts &#061; torch.zeros(npr, self.niou, dtype&#061;torch.bool, device&#061;self.device)  # \u521d\u59cb\u5316\u6b63\u786e\u5173\u952e\u70b9<br \/>\n            correct_bboxes &#061; torch.zeros(npr, self.niou, dtype&#061;torch.bool, device&#061;self.device)  # \u521d\u59cb\u5316\u6b63\u786e\u8fb9\u754c\u6846<br \/>\n            self.seen &#043;&#061; 1  # \u589e\u52a0\u5df2\u5904\u7406\u7684\u6279\u6b21\u6570<\/p>\n<p>            if npr &#061;&#061; 0:  # \u5982\u679c\u6ca1\u6709\u9884\u6d4b<br \/>\n                if nl:<br \/>\n                    self.stats.append((correct_bboxes, correct_kpts, *torch.zeros((2, 0), device&#061;self.device), cls.squeeze(-1)))<br \/>\n                continue<\/p>\n<p>            # \u5904\u7406\u9884\u6d4b<br \/>\n            if self.args.single_cls:<br \/>\n                pred[:, 5] &#061; 0  # \u5982\u679c\u662f\u5355\u7c7b&#xff0c;\u8bbe\u7f6e\u7c7b\u522b\u4e3a0<br \/>\n            predn &#061; pred.clone()  # \u514b\u9686\u9884\u6d4b\u7ed3\u679c<br \/>\n            ops.scale_boxes(batch[&#039;img&#039;][si].shape[1:], predn[:, :4], shape, ratio_pad&#061;batch[&#039;ratio_pad&#039;][si])  # \u7f29\u653e\u8fb9\u754c\u6846<br \/>\n            pred_kpts &#061; predn[:, 6:].view(npr, nk, -1)  # \u91cd\u5851\u5173\u952e\u70b9<br \/>\n            ops.scale_coords(batch[&#039;img&#039;][si].shape[1:], pred_kpts, shape, ratio_pad&#061;batch[&#039;ratio_pad&#039;][si])  # \u7f29\u653e\u5173\u952e\u70b9\u5750\u6807<\/p>\n<p>            # \u8bc4\u4f30<br \/>\n            if nl:<br \/>\n                height, width &#061; batch[&#039;img&#039;].shape[2:]  # \u83b7\u53d6\u56fe\u50cf\u9ad8\u5ea6\u548c\u5bbd\u5ea6<br \/>\n                tbox &#061; ops.xywh2xyxy(bbox) * torch.tensor((width, height, width, height), device&#061;self.device)  # \u76ee\u6807\u8fb9\u754c\u6846<br \/>\n                ops.scale_boxes(batch[&#039;img&#039;][si].shape[1:], tbox, shape, ratio_pad&#061;batch[&#039;ratio_pad&#039;][si])  # \u7f29\u653e\u76ee\u6807\u8fb9\u754c\u6846<br \/>\n                tkpts &#061; kpts.clone()  # \u514b\u9686\u5173\u952e\u70b9<br \/>\n                tkpts[&#8230;, 0] *&#061; width  # \u7f29\u653ex\u5750\u6807<br \/>\n                tkpts[&#8230;, 1] *&#061; height  # \u7f29\u653ey\u5750\u6807<br \/>\n                tkpts &#061; ops.scale_coords(batch[&#039;img&#039;][si].shape[1:], tkpts, shape, ratio_pad&#061;batch[&#039;ratio_pad&#039;][si])  # \u7f29\u653e\u5173\u952e\u70b9\u5750\u6807<br \/>\n                labelsn &#061; torch.cat((cls, tbox), 1)  # \u5408\u5e76\u7c7b\u522b\u548c\u8fb9\u754c\u6846<br \/>\n                correct_bboxes &#061; self._process_batch(predn[:, :6], labelsn)  # \u5904\u7406\u8fb9\u754c\u6846<br \/>\n                correct_kpts &#061; self._process_batch(predn[:, :6], labelsn, pred_kpts, tkpts)  # \u5904\u7406\u5173\u952e\u70b9<\/p>\n<p>            # \u8bb0\u5f55\u7edf\u8ba1\u4fe1\u606f<br \/>\n            self.stats.append((correct_bboxes, correct_kpts, pred[:, 4], pred[:, 5], cls.squeeze(-1)))<\/p>\n<p>    def _process_batch(self, detections, labels, pred_kpts&#061;None, gt_kpts&#061;None):<br \/>\n        &#034;&#034;&#034;<br \/>\n        \u8fd4\u56de\u6b63\u786e\u7684\u9884\u6d4b\u77e9\u9635\u3002<\/p>\n<p>        \u53c2\u6570:<br \/>\n            detections (torch.Tensor): \u5f62\u72b6\u4e3a[N, 6]\u7684\u68c0\u6d4b\u5f20\u91cf\u3002<br \/>\n            labels (torch.Tensor): \u5f62\u72b6\u4e3a[M, 5]\u7684\u6807\u7b7e\u5f20\u91cf\u3002<br \/>\n            pred_kpts (torch.Tensor, \u53ef\u9009): \u5f62\u72b6\u4e3a[N, 51]\u7684\u9884\u6d4b\u5173\u952e\u70b9\u5f20\u91cf\u3002<br \/>\n            gt_kpts (torch.Tensor, \u53ef\u9009): \u5f62\u72b6\u4e3a[N, 51]\u7684\u771f\u5b9e\u5173\u952e\u70b9\u5f20\u91cf\u3002<\/p>\n<p>        \u8fd4\u56de:<br \/>\n            torch.Tensor: \u5f62\u72b6\u4e3a[N, 10]\u7684\u6b63\u786e\u9884\u6d4b\u77e9\u9635\u3002<br \/>\n        &#034;&#034;&#034;<br \/>\n        if pred_kpts is not None and gt_kpts is not None:<br \/>\n            area &#061; ops.xyxy2xywh(labels[:, 1:])[:, 2:].prod(1) * 0.53  # \u8ba1\u7b97\u9762\u79ef<br \/>\n            iou &#061; kpt_iou(gt_kpts, pred_kpts, sigma&#061;self.sigma, area&#061;area)  # \u8ba1\u7b97\u5173\u952e\u70b9\u7684IoU<br \/>\n        else:  # \u5904\u7406\u8fb9\u754c\u6846<br \/>\n            iou &#061; box_iou(labels[:, 1:], detections[:, :4])  # \u8ba1\u7b97\u8fb9\u754c\u6846\u7684IoU<\/p>\n<p>        return self.match_predictions(detections[:, 5], labels[:, 0], iou)  # \u5339\u914d\u9884\u6d4b<\/p>\n<p>    def plot_val_samples(self, batch, ni):<br \/>\n        &#034;&#034;&#034;\u7ed8\u5236\u5e76\u4fdd\u5b58\u9a8c\u8bc1\u96c6\u6837\u672c\u53ca\u5176\u9884\u6d4b\u7684\u8fb9\u754c\u6846\u548c\u5173\u952e\u70b9\u3002&#034;&#034;&#034;<br \/>\n        plot_images(batch[&#039;img&#039;],<br \/>\n                    batch[&#039;batch_idx&#039;],<br \/>\n                    batch[&#039;cls&#039;].squeeze(-1),<br \/>\n                    batch[&#039;bboxes&#039;],<br \/>\n                    kpts&#061;batch[&#039;keypoints&#039;],<br \/>\n                    paths&#061;batch[&#039;im_file&#039;],<br \/>\n                    fname&#061;self.save_dir \/ f&#039;val_batch{ni}_labels.jpg&#039;,<br \/>\n                    names&#061;self.names,<br \/>\n                    on_plot&#061;self.on_plot)<\/p>\n<p>    def plot_predictions(self, batch, preds, ni):<br \/>\n        &#034;&#034;&#034;\u7ed8\u5236YOLO\u6a21\u578b\u7684\u9884\u6d4b\u7ed3\u679c\u3002&#034;&#034;&#034;<br \/>\n        pred_kpts &#061; torch.cat([p[:, 6:].view(-1, *self.kpt_shape) for p in preds], 0)  # \u5408\u5e76\u6240\u6709\u9884\u6d4b\u7684\u5173\u952e\u70b9<br \/>\n        plot_images(batch[&#039;img&#039;],<br \/>\n                    *output_to_target(preds, max_det&#061;self.args.max_det),<br \/>\n                    kpts&#061;pred_kpts,<br \/>\n                    paths&#061;batch[&#039;im_file&#039;],<br \/>\n                    fname&#061;self.save_dir \/ f&#039;val_batch{ni}_pred.jpg&#039;,<br \/>\n                    names&#061;self.names,<br \/>\n                    on_plot&#061;self.on_plot)  # \u7ed8\u5236\u9884\u6d4b\u7ed3\u679c<\/p>\n<p>    def pred_to_json(self, predn, filename):<br \/>\n        &#034;&#034;&#034;\u5c06YOLO\u9884\u6d4b\u7ed3\u679c\u8f6c\u6362\u4e3aCOCO JSON\u683c\u5f0f\u3002&#034;&#034;&#034;<br \/>\n        stem &#061; Path(filename).stem<br \/>\n        image_id &#061; int(stem) if stem.isnumeric() else stem  # \u83b7\u53d6\u56fe\u50cfID<br \/>\n        box &#061; ops.xyxy2xywh(predn[:, :4])  # \u8f6c\u6362\u4e3axywh\u683c\u5f0f<br \/>\n        box[:, :2] -&#061; box[:, 2:] \/ 2  # \u5c06\u4e2d\u5fc3\u5750\u6807\u8f6c\u6362\u4e3a\u5de6\u4e0a\u89d2\u5750\u6807<br \/>\n        for p, b in zip(predn.tolist(), box.tolist()):<br \/>\n            self.jdict.append({<br \/>\n                &#039;image_id&#039;: image_id,<br \/>\n                &#039;category_id&#039;: self.class_map[int(p[5])],<br \/>\n                &#039;bbox&#039;: [round(x, 3) for x in b],<br \/>\n                &#039;keypoints&#039;: p[6:],<br \/>\n                &#039;score&#039;: round(p[4], 5)})<\/p>\n<p>    def eval_json(self, stats):<br \/>\n        &#034;&#034;&#034;\u4f7f\u7528COCO JSON\u683c\u5f0f\u8bc4\u4f30\u76ee\u6807\u68c0\u6d4b\u6a21\u578b\u3002&#034;&#034;&#034;<br \/>\n        if self.args.save_json and self.is_coco and len(self.jdict):<br \/>\n            anno_json &#061; self.data[&#039;path&#039;] \/ &#039;annotations\/person_keypoints_val2017.json&#039;  # \u6ce8\u91ca\u6587\u4ef6\u8def\u5f84<br \/>\n            pred_json &#061; self.save_dir \/ &#039;predictions.json&#039;  # \u9884\u6d4b\u7ed3\u679c\u6587\u4ef6\u8def\u5f84<br \/>\n            LOGGER.info(f&#039;\\\\nEvaluating pycocotools mAP using {pred_json} and {anno_json}&#8230;&#039;)<br \/>\n            try:<br \/>\n                check_requirements(&#039;pycocotools&gt;&#061;2.0.6&#039;)  # \u68c0\u67e5pycocotools\u7684\u7248\u672c<br \/>\n                from pycocotools.coco import COCO  # \u5bfc\u5165COCO API<br \/>\n                from pycocotools.cocoeval import COCOeval  # \u5bfc\u5165COCO\u8bc4\u4f30API<\/p>\n<p>                for x in anno_json, pred_json:<br \/>\n                    assert x.is_file(), f&#039;{x} file not found&#039;  # \u786e\u4fdd\u6587\u4ef6\u5b58\u5728<br \/>\n                anno &#061; COCO(str(anno_json))  # \u521d\u59cb\u5316\u6ce8\u91caAPI<br \/>\n                pred &#061; anno.loadRes(str(pred_json))  # \u521d\u59cb\u5316\u9884\u6d4bAPI<br \/>\n                for i, eval in enumerate([COCOeval(anno, pred, &#039;bbox&#039;), COCOeval(anno, pred, &#039;keypoints&#039;)]):<br \/>\n                    if self.is_coco:<br \/>\n                        eval.params.imgIds &#061; [int(Path(x).stem) for x in self.dataloader.dataset.im_files]  # \u8bbe\u7f6e\u8bc4\u4f30\u56fe\u50cfID<br \/>\n                    eval.evaluate()  # \u8bc4\u4f30<br \/>\n                    eval.accumulate()  # \u7d2f\u79ef\u7ed3\u679c<br \/>\n                    eval.summarize()  # \u603b\u7ed3\u7ed3\u679c<br \/>\n                    idx &#061; i * 4 &#043; 2<br \/>\n                    stats[self.metrics.keys[idx &#043; 1]], stats[self.metrics.keys[idx]] &#061; eval.stats[:2]  # \u66f4\u65b0mAP<br \/>\n            except Exception as e:<br \/>\n                LOGGER.warning(f&#039;pycocotools unable to run: {e}&#039;)  # \u6355\u83b7\u5f02\u5e38\u5e76\u8bb0\u5f55\u8b66\u544a<br \/>\n        return stats  # \u8fd4\u56de\u7edf\u8ba1\u4fe1\u606f<\/p>\n<h4>\u4ee3\u7801\u6838\u5fc3\u90e8\u5206\u5206\u6790<\/h4>\n<li>PoseValidator\u7c7b: \u8be5\u7c7b\u7ee7\u627f\u81eaDetectionValidator&#xff0c;\u7528\u4e8e\u5904\u7406\u59ff\u6001\u4f30\u8ba1\u7684\u9a8c\u8bc1\u3002<\/li>\n<li>\u521d\u59cb\u5316\u65b9\u6cd5: \u5728\u521d\u59cb\u5316\u4e2d\u8bbe\u7f6e\u4e86\u4e00\u4e9b\u91cd\u8981\u7684\u53c2\u6570&#xff0c;\u5982task\u7c7b\u578b\u3001metrics\u7b49&#xff0c;\u5e76\u68c0\u67e5\u8bbe\u5907\u7c7b\u578b\u3002<\/li>\n<li>\u9884\u5904\u7406\u548c\u540e\u5904\u7406: preprocess\u65b9\u6cd5\u7528\u4e8e\u5904\u7406\u8f93\u5165\u6570\u636e&#xff0c;postprocess\u65b9\u6cd5\u7528\u4e8e\u5e94\u7528\u975e\u6700\u5927\u6291\u5236\u4ee5\u8fc7\u6ee4\u4f4e\u7f6e\u4fe1\u5ea6\u7684\u68c0\u6d4b\u7ed3\u679c\u3002<\/li>\n<li>\u5ea6\u91cf\u66f4\u65b0: update_metrics\u65b9\u6cd5\u8d1f\u8d23\u66f4\u65b0\u68c0\u6d4b\u7684\u5ea6\u91cf\u6307\u6807&#xff0c;\u5305\u62ec\u8fb9\u754c\u6846\u548c\u5173\u952e\u70b9\u7684\u5339\u914d\u3002<\/li>\n<li>\u7ed8\u56fe\u65b9\u6cd5: plot_val_samples\u548cplot_predictions\u65b9\u6cd5\u7528\u4e8e\u53ef\u89c6\u5316\u9a8c\u8bc1\u96c6\u6837\u672c\u548c\u6a21\u578b\u9884\u6d4b\u7ed3\u679c\u3002<\/li>\n<li>JSON\u8f6c\u6362: pred_to_json\u548ceval_json\u65b9\u6cd5\u7528\u4e8e\u5c06\u9884\u6d4b\u7ed3\u679c\u8f6c\u6362\u4e3aCOCO\u683c\u5f0f&#xff0c;\u5e76\u8bc4\u4f30\u6a21\u578b\u6027\u80fd\u3002<\/li>\n<p>\u8fd9\u4e9b\u6838\u5fc3\u90e8\u5206\u5171\u540c\u6784\u6210\u4e86\u59ff\u6001\u4f30\u8ba1\u6a21\u578b\u9a8c\u8bc1\u7684\u4e3b\u8981\u6d41\u7a0b&#xff0c;\u6db5\u76d6\u4e86\u6570\u636e\u5904\u7406\u3001\u6a21\u578b\u8bc4\u4f30\u548c\u7ed3\u679c\u53ef\u89c6\u5316\u7b49\u5173\u952e\u73af\u8282\u3002&#096;&#096;&#096;<br \/>\n\u8be5\u6587\u4ef6\u662f\u4e00\u4e2a\u7528\u4e8eYOLOv8\u6a21\u578b\u59ff\u6001\u4f30\u8ba1\u7684\u9a8c\u8bc1\u5668\u7c7bPoseValidator\u7684\u5b9e\u73b0&#xff0c;\u7ee7\u627f\u81eaDetectionValidator\u7c7b\u3002\u8be5\u7c7b\u4e3b\u8981\u7528\u4e8e\u5728\u59ff\u6001\u4f30\u8ba1\u4efb\u52a1\u4e2d\u8bc4\u4f30\u6a21\u578b\u7684\u6027\u80fd\u3002\u4ee3\u7801\u4e2d\u5305\u542b\u4e86\u591a\u4e2a\u65b9\u6cd5\u548c\u5c5e\u6027&#xff0c;\u4e0b\u9762\u662f\u5bf9\u5176\u529f\u80fd\u7684\u9010\u6b65\u5206\u6790\u3002<\/p>\n<p>\u9996\u5148&#xff0c;\u7c7b\u7684\u6784\u9020\u51fd\u6570__init__\u521d\u59cb\u5316\u4e86\u4e00\u4e9b\u57fa\u672c\u53c2\u6570&#xff0c;\u5305\u62ec\u6570\u636e\u52a0\u8f7d\u5668\u3001\u4fdd\u5b58\u76ee\u5f55\u3001\u8fdb\u5ea6\u6761\u3001\u53c2\u6570\u548c\u56de\u8c03\u51fd\u6570\u3002\u5b83\u8fd8\u8bbe\u7f6e\u4e86\u4efb\u52a1\u7c7b\u578b\u4e3a\u201cpose\u201d&#xff0c;\u5e76\u521d\u59cb\u5316\u4e86\u59ff\u6001\u4f30\u8ba1\u7684\u5ea6\u91cf\u6307\u6807\u3002\u82e5\u8bbe\u5907\u4e3aApple\u7684MPS&#xff0c;\u7cfb\u7edf\u4f1a\u53d1\u51fa\u8b66\u544a&#xff0c;\u5efa\u8bae\u4f7f\u7528CPU\u8fdb\u884c\u59ff\u6001\u6a21\u578b\u7684\u8bad\u7ec3\u3002<\/p>\n<p>\u5728preprocess\u65b9\u6cd5\u4e2d&#xff0c;\u8f93\u5165\u7684\u6279\u6b21\u6570\u636e\u88ab\u5904\u7406&#xff0c;\u5c06\u5173\u952e\u70b9\u6570\u636e\u8f6c\u6362\u4e3a\u6d6e\u70b9\u6570\u5e76\u79fb\u52a8\u5230\u6307\u5b9a\u8bbe\u5907\u4e0a\u3002get_desc\u65b9\u6cd5\u8fd4\u56de\u4e00\u4e2a\u5b57\u7b26\u4e32&#xff0c;\u63cf\u8ff0\u4e86\u8bc4\u4f30\u6307\u6807\u7684\u683c\u5f0f\u3002<\/p>\n<p>postprocess\u65b9\u6cd5\u5e94\u7528\u975e\u6781\u5927\u503c\u6291\u5236&#xff0c;\u8fd4\u56de\u5177\u6709\u9ad8\u7f6e\u4fe1\u5ea6\u5206\u6570\u7684\u68c0\u6d4b\u7ed3\u679c\u3002init_metrics\u65b9\u6cd5\u521d\u59cb\u5316\u59ff\u6001\u4f30\u8ba1\u7684\u5ea6\u91cf\u6307\u6807&#xff0c;\u68c0\u67e5\u5173\u952e\u70b9\u7684\u5f62\u72b6\u5e76\u8bbe\u7f6e\u76f8\u5e94\u7684sigma\u503c\u3002<\/p>\n<p>update_metrics\u65b9\u6cd5\u7528\u4e8e\u66f4\u65b0\u6a21\u578b\u7684\u8bc4\u4f30\u6307\u6807\u3002\u5b83\u5904\u7406\u6bcf\u4e2a\u9884\u6d4b\u7ed3\u679c&#xff0c;\u8ba1\u7b97\u6b63\u786e\u7684\u5173\u952e\u70b9\u548c\u8fb9\u754c\u6846&#xff0c;\u5e76\u5c06\u7ed3\u679c\u6dfb\u52a0\u5230\u7edf\u8ba1\u4fe1\u606f\u4e2d\u3002\u5982\u679c\u9700\u8981&#xff0c;\u8fd8\u53ef\u4ee5\u5c06\u9884\u6d4b\u7ed3\u679c\u4fdd\u5b58\u4e3aJSON\u683c\u5f0f\u3002<\/p>\n<p>_process_batch\u65b9\u6cd5\u7528\u4e8e\u5904\u7406\u68c0\u6d4b\u548c\u6807\u7b7e&#xff0c;\u8ba1\u7b97IoU&#xff08;\u4ea4\u5e76\u6bd4&#xff09;\u5e76\u8fd4\u56de\u6b63\u786e\u7684\u9884\u6d4b\u77e9\u9635\u3002\u8be5\u65b9\u6cd5\u652f\u6301\u5173\u952e\u70b9\u548c\u8fb9\u754c\u6846\u7684\u5904\u7406\u3002<\/p>\n<p>plot_val_samples\u548cplot_predictions\u65b9\u6cd5\u7528\u4e8e\u7ed8\u5236\u9a8c\u8bc1\u96c6\u6837\u672c\u548c\u6a21\u578b\u7684\u9884\u6d4b\u7ed3\u679c&#xff0c;\u4fdd\u5b58\u4e3a\u56fe\u50cf\u6587\u4ef6\u3002pred_to_json\u65b9\u6cd5\u5c06YOLO\u7684\u9884\u6d4b\u7ed3\u679c\u8f6c\u6362\u4e3aCOCO\u683c\u5f0f\u7684JSON&#xff0c;\u4ee5\u4fbf\u540e\u7eed\u8bc4\u4f30\u3002<\/p>\n<p>\u6700\u540e&#xff0c;eval_json\u65b9\u6cd5\u4f7f\u7528COCO\u683c\u5f0f\u7684JSON\u8bc4\u4f30\u5bf9\u8c61\u68c0\u6d4b\u6a21\u578b\u7684\u6027\u80fd&#xff0c;\u8ba1\u7b97mAP&#xff08;\u5e73\u5747\u7cbe\u5ea6\u5747\u503c&#xff09;\u7b49\u6307\u6807&#xff0c;\u5e76\u8f93\u51fa\u8bc4\u4f30\u7ed3\u679c\u3002<\/p>\n<p>\u6574\u4f53\u6765\u770b&#xff0c;\u8be5\u6587\u4ef6\u5b9e\u73b0\u4e86YOLOv8\u59ff\u6001\u4f30\u8ba1\u6a21\u578b\u7684\u9a8c\u8bc1\u8fc7\u7a0b&#xff0c;\u6db5\u76d6\u4e86\u6570\u636e\u9884\u5904\u7406\u3001\u6307\u6807\u8ba1\u7b97\u3001\u7ed3\u679c\u53ef\u89c6\u5316\u548c\u8bc4\u4f30\u7b49\u591a\u4e2a\u65b9\u9762&#xff0c;\u9002\u7528\u4e8e\u59ff\u6001\u4f30\u8ba1\u4efb\u52a1\u7684\u6a21\u578b\u6027\u80fd\u8bc4\u4f30\u3002<\/p>\n<p>&#096;&#096;&#096;python<br \/>\nimport torch<br \/>\nimport torch.nn as nn<br \/>\nimport torch.nn.functional as F<br \/>\nimport numpy as np<\/p>\n<p># \u5b9a\u4e49\u4e00\u4e2a\u540d\u4e3aOREPA\u7684\u5377\u79ef\u6a21\u5757<br \/>\nclass OREPA(nn.Module):<br \/>\n    def __init__(self, in_channels, out_channels, kernel_size&#061;3, stride&#061;1, padding&#061;None, groups&#061;1, dilation&#061;1, act&#061;True):<br \/>\n        super(OREPA, self).__init__()<\/p>\n<p>        # \u521d\u59cb\u5316\u8f93\u5165\u8f93\u51fa\u901a\u9053\u3001\u5377\u79ef\u6838\u5927\u5c0f\u3001\u6b65\u5e45\u3001\u586b\u5145\u3001\u5206\u7ec4\u548c\u6269\u5f20<br \/>\n        self.in_channels &#061; in_channels<br \/>\n        self.out_channels &#061; out_channels<br \/>\n        self.kernel_size &#061; kernel_size<br \/>\n        self.stride &#061; stride<br \/>\n        self.padding &#061; padding if padding is not None else (kernel_size \/\/ 2)<br \/>\n        self.groups &#061; groups<br \/>\n        self.dilation &#061; dilation<\/p>\n<p>        # \u6fc0\u6d3b\u51fd\u6570\u7684\u9009\u62e9<br \/>\n        self.nonlinear &#061; nn.ReLU() if act else nn.Identity()<\/p>\n<p>        # \u5b9a\u4e49\u5377\u79ef\u5c42\u7684\u6743\u91cd\u53c2\u6570<br \/>\n        self.weight_orepa_origin &#061; nn.Parameter(torch.Tensor(out_channels, in_channels \/\/ groups, kernel_size, kernel_size))<br \/>\n        nn.init.kaiming_uniform_(self.weight_orepa_origin)  # \u4f7f\u7528He\u521d\u59cb\u5316<\/p>\n<p>        # \u5b9a\u4e49\u5176\u4ed6\u5377\u79ef\u5c42\u7684\u6743\u91cd\u53c2\u6570<br \/>\n        self.weight_orepa_avg_conv &#061; nn.Parameter(torch.Tensor(out_channels, in_channels \/\/ groups, 1, 1))<br \/>\n        nn.init.kaiming_uniform_(self.weight_orepa_avg_conv)<\/p>\n<p>        self.weight_orepa_1x1 &#061; nn.Parameter(torch.Tensor(out_channels, in_channels \/\/ groups, 1, 1))<br \/>\n        nn.init.kaiming_uniform_(self.weight_orepa_1x1)<\/p>\n<p>        # \u5176\u4ed6\u521d\u59cb\u5316\u4ee3\u7801\u7701\u7565&#8230;<\/p>\n<p>    def weight_gen(self):<br \/>\n        # \u751f\u6210\u6700\u7ec8\u7684\u5377\u79ef\u6743\u91cd<br \/>\n        weight_orepa_origin &#061; self.weight_orepa_origin  # \u539f\u59cb\u5377\u79ef\u6743\u91cd<br \/>\n        weight_orepa_avg &#061; self.weight_orepa_avg_conv  # \u5e73\u5747\u5377\u79ef\u6743\u91cd<br \/>\n        weight_orepa_1x1 &#061; self.weight_orepa_1x1  # 1&#215;1\u5377\u79ef\u6743\u91cd<\/p>\n<p>        # \u5c06\u6240\u6709\u6743\u91cd\u7ed3\u5408<br \/>\n        weight &#061; weight_orepa_origin &#043; weight_orepa_avg &#043; weight_orepa_1x1<br \/>\n        return weight<\/p>\n<p>    def forward(self, inputs):<br \/>\n        # \u524d\u5411\u4f20\u64ad<br \/>\n        weight &#061; self.weight_gen()  # \u751f\u6210\u6743\u91cd<br \/>\n        out &#061; F.conv2d(inputs, weight, stride&#061;self.stride, padding&#061;self.padding, dilation&#061;self.dilation, groups&#061;self.groups)  # \u5377\u79ef\u64cd\u4f5c<br \/>\n        return self.nonlinear(out)  # \u6fc0\u6d3b\u51fd\u6570<\/p>\n<p># \u5176\u4ed6\u7c7b\u7684\u5b9a\u4e49\u7701\u7565&#8230;<\/p>\n<h4>\u4ee3\u7801\u8bf4\u660e&#xff1a;<\/h4>\n<li>OREPA\u7c7b&#xff1a;\u8fd9\u662f\u4e00\u4e2a\u81ea\u5b9a\u4e49\u7684\u5377\u79ef\u6a21\u5757&#xff0c;\u7ee7\u627f\u81eann.Module\u3002\u5b83\u5305\u542b\u591a\u4e2a\u5377\u79ef\u5c42\u7684\u6743\u91cd\u53c2\u6570&#xff0c;\u4f7f\u7528\u4e0d\u540c\u7684\u521d\u59cb\u5316\u65b9\u6cd5\u3002<\/li>\n<li>\u521d\u59cb\u5316\u65b9\u6cd5&#xff1a;\u5728__init__\u4e2d&#xff0c;\u5b9a\u4e49\u4e86\u8f93\u5165\u8f93\u51fa\u901a\u9053\u3001\u5377\u79ef\u6838\u5927\u5c0f\u3001\u6b65\u5e45\u3001\u586b\u5145\u3001\u5206\u7ec4\u548c\u6269\u5f20\u7b49\u53c2\u6570&#xff0c;\u5e76\u521d\u59cb\u5316\u5377\u79ef\u5c42\u7684\u6743\u91cd\u3002<\/li>\n<li>\u6743\u91cd\u751f\u6210&#xff1a;weight_gen\u65b9\u6cd5\u7528\u4e8e\u751f\u6210\u6700\u7ec8\u7684\u5377\u79ef\u6743\u91cd&#xff0c;\u5c06\u4e0d\u540c\u6765\u6e90\u7684\u6743\u91cd\u7ed3\u5408\u8d77\u6765\u3002<\/li>\n<li>\u524d\u5411\u4f20\u64ad&#xff1a;forward\u65b9\u6cd5\u5b9e\u73b0\u4e86\u524d\u5411\u4f20\u64ad\u8fc7\u7a0b&#xff0c;\u8c03\u7528\u751f\u6210\u7684\u6743\u91cd\u8fdb\u884c\u5377\u79ef\u64cd\u4f5c&#xff0c;\u5e76\u5e94\u7528\u6fc0\u6d3b\u51fd\u6570\u3002<\/li>\n<p>\u4ee5\u4e0a\u662f\u4ee3\u7801\u7684\u6838\u5fc3\u90e8\u5206\u53ca\u5176\u8be6\u7ec6\u6ce8\u91ca&#xff0c;\u5e2e\u52a9\u7406\u89e3\u8be5\u6a21\u5757\u7684\u7ed3\u6784\u548c\u529f\u80fd\u3002&#096;&#096;&#096;<br \/>\n\u8fd9\u4e2a\u7a0b\u5e8f\u6587\u4ef6\u5305\u542b\u4e86\u591a\u4e2a\u7c7b\u548c\u51fd\u6570&#xff0c;\u4e3b\u8981\u7528\u4e8e\u5b9e\u73b0\u4e00\u79cd\u540d\u4e3aOREPA&#xff08;Optimized Reparameterization for Efficient Convolution&#xff09;\u7684\u5377\u79ef\u6a21\u5757&#xff0c;\u65e8\u5728\u63d0\u9ad8\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u7684\u6027\u80fd\u548c\u6548\u7387\u3002\u4ee5\u4e0b\u662f\u5bf9\u4ee3\u7801\u7684\u8be6\u7ec6\u8bf4\u660e\u3002<\/p>\n<p>\u9996\u5148&#xff0c;\u5bfc\u5165\u4e86\u5fc5\u8981\u7684\u5e93&#xff0c;\u5305\u62ecPyTorch\u7684\u6838\u5fc3\u5e93\u3001\u6570\u5b66\u5e93\u3001NumPy\u4ee5\u53ca\u4e00\u4e9b\u81ea\u5b9a\u4e49\u7684\u6a21\u5757\u3002transI_fusebn\u548ctransVI_multiscale\u662f\u4e24\u4e2a\u8f85\u52a9\u51fd\u6570&#xff0c;\u524d\u8005\u7528\u4e8e\u5c06\u5377\u79ef\u6838\u548c\u6279\u5f52\u4e00\u5316\u5c42\u7684\u53c2\u6570\u878d\u5408&#xff0c;\u540e\u8005\u7528\u4e8e\u5bf9\u5377\u79ef\u6838\u8fdb\u884c\u591a\u5c3a\u5ea6\u586b\u5145\u3002<\/p>\n<p>OREPA\u7c7b\u662f\u6838\u5fc3\u7c7b\u4e4b\u4e00&#xff0c;\u7ee7\u627f\u81eann.Module\u3002\u5728\u521d\u59cb\u5316\u65b9\u6cd5\u4e2d&#xff0c;\u5b9a\u4e49\u4e86\u8f93\u5165\u548c\u8f93\u51fa\u901a\u9053\u3001\u5377\u79ef\u6838\u5927\u5c0f\u3001\u6b65\u5e45\u3001\u586b\u5145\u3001\u5206\u7ec4\u3001\u6269\u5f20\u7b49\u53c2\u6570\u3002\u6839\u636e\u662f\u5426\u5904\u4e8e\u90e8\u7f72\u6a21\u5f0f&#xff0c;\u521d\u59cb\u5316\u4e0d\u540c\u7684\u5377\u79ef\u5c42\u548c\u53c2\u6570\u3002\u8be5\u7c7b\u7684\u8bbe\u8ba1\u5141\u8bb8\u901a\u8fc7\u4e0d\u540c\u7684\u5206\u652f\u7ec4\u5408\u751f\u6210\u5377\u79ef\u6743\u91cd&#xff0c;\u5229\u7528\u4e86\u591a\u4e2a\u5377\u79ef\u6838\u548c\u6279\u5f52\u4e00\u5316\u7684\u7ec4\u5408&#xff0c;\u4ee5\u63d0\u9ad8\u6a21\u578b\u7684\u8868\u8fbe\u80fd\u529b\u3002<\/p>\n<p>weight_gen\u65b9\u6cd5\u7528\u4e8e\u751f\u6210\u6700\u7ec8\u7684\u5377\u79ef\u6743\u91cd&#xff0c;\u901a\u8fc7\u5bf9\u4e0d\u540c\u5206\u652f\u7684\u6743\u91cd\u8fdb\u884c\u52a0\u6743\u6c42\u548c&#xff0c;\u5f62\u6210\u6700\u7ec8\u7684\u5377\u79ef\u6838\u3002forward\u65b9\u6cd5\u5b9e\u73b0\u4e86\u524d\u5411\u4f20\u64ad&#xff0c;\u8ba1\u7b97\u8f93\u5165\u6570\u636e\u7684\u5377\u79ef\u7ed3\u679c&#xff0c;\u5e76\u901a\u8fc7\u975e\u7ebf\u6027\u6fc0\u6d3b\u51fd\u6570\u548c\u6279\u5f52\u4e00\u5316\u5c42\u8fdb\u884c\u5904\u7406\u3002<\/p>\n<p>OREPA_LargeConv\u7c7b\u5b9e\u73b0\u4e86\u4e00\u4e2a\u5927\u578b\u5377\u79ef\u6a21\u5757&#xff0c;\u652f\u6301\u66f4\u5927\u7684\u5377\u79ef\u6838\u3002\u5b83\u7684\u7ed3\u6784\u4e0eOREPA\u7c7b\u4f3c&#xff0c;\u4f46\u589e\u52a0\u4e86\u591a\u4e2a\u5377\u79ef\u5c42\u7684\u7ec4\u5408&#xff0c;\u80fd\u591f\u5904\u7406\u66f4\u590d\u6742\u7684\u7279\u5f81\u63d0\u53d6\u4efb\u52a1\u3002<\/p>\n<p>ConvBN\u7c7b\u5219\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u5377\u79ef\u52a0\u6279\u5f52\u4e00\u5316\u6a21\u5757&#xff0c;\u652f\u6301\u5728\u90e8\u7f72\u6a21\u5f0f\u4e0b\u76f4\u63a5\u4f7f\u7528\u878d\u5408\u540e\u7684\u5377\u79ef\u6838\u3002<\/p>\n<p>OREPA_3x3_RepVGG\u7c7b\u662f\u4e00\u4e2a\u7279\u5b9a\u7684OREPA\u6a21\u5757&#xff0c;\u4e13\u95e8\u7528\u4e8e3&#215;3\u5377\u79ef\u6838\u7684\u60c5\u51b5&#xff0c;\u652f\u6301\u4e0d\u540c\u7684\u5206\u652f\u7ec4\u5408\u4ee5\u751f\u6210\u5377\u79ef\u6743\u91cd\u3002<\/p>\n<p>\u6700\u540e&#xff0c;RepVGGBlock_OREPA\u7c7b\u5b9e\u73b0\u4e86\u4e00\u4e2a\u5b8c\u6574\u7684\u5757\u7ed3\u6784&#xff0c;\u7ed3\u5408\u4e86OREPA\u6a21\u5757\u548c1&#215;1\u5377\u79ef\u5c42&#xff0c;\u80fd\u591f\u5904\u7406\u8f93\u5165\u6570\u636e\u5e76\u8f93\u51fa\u7279\u5f81\u56fe\u3002\u8be5\u7c7b\u8fd8\u652f\u6301SE&#xff08;Squeeze-and-Excitation&#xff09;\u6ce8\u610f\u529b\u673a\u5236\u7684\u96c6\u6210&#xff0c;\u4ee5\u8fdb\u4e00\u6b65\u589e\u5f3a\u7279\u5f81\u8868\u793a\u80fd\u529b\u3002<\/p>\n<p>\u603b\u4f53\u6765\u8bf4&#xff0c;\u8fd9\u4e2a\u6587\u4ef6\u5b9e\u73b0\u4e86\u4e00\u79cd\u9ad8\u6548\u7684\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u6a21\u5757&#xff0c;\u80fd\u591f\u901a\u8fc7\u4e0d\u540c\u7684\u53c2\u6570\u7ec4\u5408\u548c\u7ed3\u6784\u8bbe\u8ba1&#xff0c;\u63d0\u5347\u6a21\u578b\u7684\u6027\u80fd\u548c\u7075\u6d3b\u6027&#xff0c;\u9002\u7528\u4e8e\u5404\u79cd\u8ba1\u7b97\u673a\u89c6\u89c9\u4efb\u52a1\u3002<\/p>\n<p>&#096;&#096;&#096;python<br \/>\nimport sys<br \/>\nimport subprocess<\/p>\n<p>def run_script(script_path):<br \/>\n    &#034;&#034;&#034;<br \/>\n    \u4f7f\u7528\u5f53\u524d Python \u73af\u5883\u8fd0\u884c\u6307\u5b9a\u7684\u811a\u672c\u3002<\/p>\n<p>    Args:<br \/>\n        script_path (str): \u8981\u8fd0\u884c\u7684\u811a\u672c\u8def\u5f84<\/p>\n<p>    Returns:<br \/>\n        None<br \/>\n    &#034;&#034;&#034;<br \/>\n    # \u83b7\u53d6\u5f53\u524d Python \u89e3\u91ca\u5668\u7684\u8def\u5f84<br \/>\n    python_path &#061; sys.executable<\/p>\n<p>    # \u6784\u5efa\u8fd0\u884c\u547d\u4ee4&#xff0c;\u4f7f\u7528 streamlit \u8fd0\u884c\u6307\u5b9a\u7684\u811a\u672c<br \/>\n    command &#061; f&#039;&#034;{python_path}&#034; -m streamlit run &#034;{script_path}&#034;&#039;<\/p>\n<p>    # \u6267\u884c\u547d\u4ee4<br \/>\n    result &#061; subprocess.run(command, shell&#061;True)<br \/>\n    # \u68c0\u67e5\u547d\u4ee4\u6267\u884c\u7684\u8fd4\u56de\u7801&#xff0c;\u5982\u679c\u4e0d\u4e3a0&#xff0c;\u8868\u793a\u6267\u884c\u51fa\u9519<br \/>\n    if result.returncode !&#061; 0:<br \/>\n        print(&#034;\u811a\u672c\u8fd0\u884c\u51fa\u9519\u3002&#034;)<\/p>\n<p># \u5b9e\u4f8b\u5316\u5e76\u8fd0\u884c\u5e94\u7528<br \/>\nif __name__ &#061;&#061; &#034;__main__&#034;:<br \/>\n    # \u6307\u5b9a\u8981\u8fd0\u884c\u7684\u811a\u672c\u8def\u5f84<br \/>\n    script_path &#061; &#034;web.py&#034;  # \u5047\u8bbe\u811a\u672c\u5728\u5f53\u524d\u76ee\u5f55\u4e0b<\/p>\n<p>    # \u8c03\u7528\u51fd\u6570\u8fd0\u884c\u811a\u672c<br \/>\n    run_script(script_path)<\/p>\n<h4>\u4ee3\u7801\u6ce8\u91ca\u8bf4\u660e&#xff1a;<\/h4>\n<li>\n<p>\u5bfc\u5165\u6a21\u5757&#xff1a;<\/p>\n<ul>\n<li>sys&#xff1a;\u7528\u4e8e\u8bbf\u95ee\u4e0e Python \u89e3\u91ca\u5668\u7d27\u5bc6\u76f8\u5173\u7684\u53d8\u91cf\u548c\u51fd\u6570\u3002<\/li>\n<li>subprocess&#xff1a;\u7528\u4e8e\u6267\u884c\u5916\u90e8\u547d\u4ee4\u548c\u4e0e\u5176\u4ea4\u4e92\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>run_script \u51fd\u6570&#xff1a;<\/p>\n<ul>\n<li>\u5b9a\u4e49\u4e00\u4e2a\u51fd\u6570&#xff0c;\u63a5\u53d7\u4e00\u4e2a\u53c2\u6570 script_path&#xff0c;\u8868\u793a\u8981\u8fd0\u884c\u7684 Python \u811a\u672c\u7684\u8def\u5f84\u3002<\/li>\n<li>\u4f7f\u7528 sys.executable \u83b7\u53d6\u5f53\u524d Python \u89e3\u91ca\u5668\u7684\u8def\u5f84&#xff0c;\u4ee5\u786e\u4fdd\u4f7f\u7528\u76f8\u540c\u7684\u73af\u5883\u6765\u8fd0\u884c\u811a\u672c\u3002<\/li>\n<li>\u6784\u5efa\u4e00\u4e2a\u547d\u4ee4\u5b57\u7b26\u4e32&#xff0c;\u4f7f\u7528 streamlit \u6a21\u5757\u8fd0\u884c\u6307\u5b9a\u7684\u811a\u672c\u3002<\/li>\n<li>\u4f7f\u7528 subprocess.run \u6267\u884c\u6784\u5efa\u7684\u547d\u4ee4&#xff0c;\u5e76\u901a\u8fc7 shell&#061;True \u5141\u8bb8\u5728 shell \u4e2d\u6267\u884c\u547d\u4ee4\u3002<\/li>\n<li>\u68c0\u67e5\u547d\u4ee4\u7684\u8fd4\u56de\u7801&#xff0c;\u5982\u679c\u8fd4\u56de\u7801\u4e0d\u4e3a0&#xff0c;\u8868\u793a\u6267\u884c\u8fc7\u7a0b\u4e2d\u51fa\u73b0\u9519\u8bef&#xff0c;\u6253\u5370\u9519\u8bef\u4fe1\u606f\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4e3b\u7a0b\u5e8f\u5757&#xff1a;<\/p>\n<ul>\n<li>\u5728 if __name__ &#061;&#061; &#034;__main__&#034;: \u5757\u4e2d&#xff0c;\u786e\u4fdd\u53ea\u6709\u5728\u76f4\u63a5\u8fd0\u884c\u8be5\u811a\u672c\u65f6\u624d\u4f1a\u6267\u884c\u4ee5\u4e0b\u4ee3\u7801\u3002<\/li>\n<li>\u6307\u5b9a\u8981\u8fd0\u884c\u7684\u811a\u672c\u8def\u5f84\u4e3a web.py&#xff0c;\u5e76\u8c03\u7528 run_script \u51fd\u6570\u6765\u6267\u884c\u8be5\u811a\u672c\u3002&#096;&#096;&#096;<br \/>\n\u8fd9\u4e2a\u7a0b\u5e8f\u6587\u4ef6\u540d\u4e3a ui.py&#xff0c;\u5176\u4e3b\u8981\u529f\u80fd\u662f\u901a\u8fc7\u5f53\u524d\u7684 Python \u73af\u5883\u8fd0\u884c\u4e00\u4e2a\u6307\u5b9a\u7684\u811a\u672c&#xff0c;\u5177\u4f53\u662f\u4e00\u4e2a\u540d\u4e3a web.py \u7684\u6587\u4ef6\u3002\u7a0b\u5e8f\u9996\u5148\u5bfc\u5165\u4e86\u5fc5\u8981\u7684\u6a21\u5757&#xff0c;\u5305\u62ec sys\u3001os \u548c subprocess&#xff0c;\u4ee5\u53ca\u4e00\u4e2a\u81ea\u5b9a\u4e49\u7684\u8def\u5f84\u5904\u7406\u6a21\u5757 abs_path\u3002<\/li>\n<\/ul>\n<\/li>\n<p>\u5728 run_script \u51fd\u6570\u4e2d&#xff0c;\u7a0b\u5e8f\u63a5\u53d7\u4e00\u4e2a\u53c2\u6570 script_path&#xff0c;\u8be5\u53c2\u6570\u662f\u8981\u8fd0\u884c\u7684\u811a\u672c\u7684\u8def\u5f84\u3002\u51fd\u6570\u9996\u5148\u83b7\u53d6\u5f53\u524d Python \u89e3\u91ca\u5668\u7684\u8def\u5f84&#xff0c;\u8fd9\u901a\u8fc7 sys.executable \u5b9e\u73b0\u3002\u63a5\u7740&#xff0c;\u7a0b\u5e8f\u6784\u5efa\u4e86\u4e00\u4e2a\u547d\u4ee4\u5b57\u7b26\u4e32&#xff0c;\u8be5\u547d\u4ee4\u7528\u4e8e\u8fd0\u884c streamlit&#xff0c;\u8fd9\u662f\u4e00\u4e2a\u7528\u4e8e\u6784\u5efa\u6570\u636e\u5e94\u7528\u7684\u5e93\u3002\u547d\u4ee4\u7684\u683c\u5f0f\u662f\u5c06 Python \u89e3\u91ca\u5668\u4e0e -m streamlit run \u7ed3\u5408\u4f7f\u7528&#xff0c;\u5e76\u4f20\u5165\u8981\u8fd0\u884c\u7684\u811a\u672c\u8def\u5f84\u3002<\/p>\n<p>\u968f\u540e&#xff0c;\u7a0b\u5e8f\u4f7f\u7528 subprocess.run \u65b9\u6cd5\u6267\u884c\u6784\u5efa\u597d\u7684\u547d\u4ee4\u3002\u8fd9\u4e2a\u65b9\u6cd5\u4f1a\u5728\u65b0\u7684\u5b50\u8fdb\u7a0b\u4e2d\u8fd0\u884c\u547d\u4ee4&#xff0c;\u5e76\u7b49\u5f85\u5176\u5b8c\u6210\u3002\u5982\u679c\u547d\u4ee4\u6267\u884c\u7684\u8fd4\u56de\u7801\u4e0d\u4e3a\u96f6&#xff0c;\u8868\u793a\u811a\u672c\u8fd0\u884c\u51fa\u9519&#xff0c;\u7a0b\u5e8f\u4f1a\u8f93\u51fa\u4e00\u6761\u9519\u8bef\u4fe1\u606f\u3002<\/p>\n<p>\u5728\u6587\u4ef6\u7684\u6700\u540e\u90e8\u5206&#xff0c;\u7a0b\u5e8f\u901a\u8fc7 if __name__ &#061;&#061; &#034;__main__&#034;: \u8bed\u53e5\u6765\u786e\u4fdd\u53ea\u6709\u5728\u76f4\u63a5\u8fd0\u884c\u8be5\u6587\u4ef6\u65f6\u624d\u4f1a\u6267\u884c\u4ee5\u4e0b\u4ee3\u7801\u3002\u5b83\u6307\u5b9a\u4e86\u8981\u8fd0\u884c\u7684\u811a\u672c\u8def\u5f84\u4e3a web.py&#xff0c;\u5e76\u8c03\u7528 run_script \u51fd\u6570\u6765\u6267\u884c\u8fd9\u4e2a\u811a\u672c\u3002<\/p>\n<p>\u603b\u4f53\u6765\u8bf4&#xff0c;\u8fd9\u4e2a\u7a0b\u5e8f\u7684\u76ee\u7684\u662f\u63d0\u4f9b\u4e00\u4e2a\u7b80\u5355\u7684\u63a5\u53e3\u6765\u8fd0\u884c\u4e00\u4e2a\u7279\u5b9a\u7684 Python \u811a\u672c&#xff0c;\u5e76\u5728\u8fd0\u884c\u8fc7\u7a0b\u4e2d\u5904\u7406\u53ef\u80fd\u51fa\u73b0\u7684\u9519\u8bef\u3002<\/p>\n<p>&#096;&#096;&#096;python<br \/>\nimport random<br \/>\nimport numpy as np<br \/>\nimport torch.nn as nn<br \/>\nfrom ultralytics.data import build_dataloader, build_yolo_dataset<br \/>\nfrom ultralytics.engine.trainer import BaseTrainer<br \/>\nfrom ultralytics.models import yolo<br \/>\nfrom ultralytics.nn.tasks import DetectionModel<br \/>\nfrom ultralytics.utils import LOGGER, RANK<br \/>\nfrom ultralytics.utils.torch_utils import de_parallel, torch_distributed_zero_first<\/p>\n<p>class DetectionTrainer(BaseTrainer):<br \/>\n    &#034;&#034;&#034;<br \/>\n    \u6269\u5c55\u81ea BaseTrainer \u7c7b&#xff0c;\u7528\u4e8e\u57fa\u4e8e\u68c0\u6d4b\u6a21\u578b\u7684\u8bad\u7ec3\u3002<br \/>\n    &#034;&#034;&#034;<\/p>\n<p>    def build_dataset(self, img_path, mode&#061;&#034;train&#034;, batch&#061;None):<br \/>\n        &#034;&#034;&#034;<br \/>\n        \u6784\u5efa YOLO \u6570\u636e\u96c6\u3002<\/p>\n<p>        \u53c2\u6570:<br \/>\n            img_path (str): \u5305\u542b\u56fe\u50cf\u7684\u6587\u4ef6\u5939\u8def\u5f84\u3002<br \/>\n            mode (str): \u6a21\u5f0f\u4e3a &#096;train&#096; \u6216 &#096;val&#096;&#xff0c;\u7528\u6237\u53ef\u4ee5\u4e3a\u6bcf\u79cd\u6a21\u5f0f\u81ea\u5b9a\u4e49\u4e0d\u540c\u7684\u589e\u5f3a\u3002<br \/>\n            batch (int, optional): \u6279\u6b21\u5927\u5c0f&#xff0c;\u4ec5\u7528\u4e8e &#096;rect&#096; \u6a21\u5f0f\u3002\u9ed8\u8ba4\u4e3a None\u3002<br \/>\n        &#034;&#034;&#034;<br \/>\n        gs &#061; max(int(de_parallel(self.model).stride.max() if self.model else 0), 32)  # \u83b7\u53d6\u6a21\u578b\u7684\u6700\u5927\u6b65\u5e45<br \/>\n        return build_yolo_dataset(self.args, img_path, batch, self.data, mode&#061;mode, rect&#061;mode &#061;&#061; &#034;val&#034;, stride&#061;gs)<\/p>\n<p>    def get_dataloader(self, dataset_path, batch_size&#061;16, rank&#061;0, mode&#061;&#034;train&#034;):<br \/>\n        &#034;&#034;&#034;\u6784\u9020\u5e76\u8fd4\u56de\u6570\u636e\u52a0\u8f7d\u5668\u3002&#034;&#034;&#034;<br \/>\n        assert mode in [&#034;train&#034;, &#034;val&#034;]  # \u786e\u4fdd\u6a21\u5f0f\u6709\u6548<br \/>\n        with torch_distributed_zero_first(rank):  # \u4ec5\u5728 DDP \u65f6\u521d\u59cb\u5316\u6570\u636e\u96c6 *.cache \u4e00\u6b21<br \/>\n            dataset &#061; self.build_dataset(dataset_path, mode, batch_size)  # \u6784\u5efa\u6570\u636e\u96c6<br \/>\n        shuffle &#061; mode &#061;&#061; &#034;train&#034;  # \u8bad\u7ec3\u6a21\u5f0f\u4e0b\u6253\u4e71\u6570\u636e<br \/>\n        workers &#061; self.args.workers if mode &#061;&#061; &#034;train&#034; else self.args.workers * 2  # \u6839\u636e\u6a21\u5f0f\u8bbe\u7f6e\u5de5\u4f5c\u7ebf\u7a0b\u6570<br \/>\n        return build_dataloader(dataset, batch_size, workers, shuffle, rank)  # \u8fd4\u56de\u6570\u636e\u52a0\u8f7d\u5668<\/p>\n<p>    def preprocess_batch(self, batch):<br \/>\n        &#034;&#034;&#034;\u5bf9\u4e00\u6279\u56fe\u50cf\u8fdb\u884c\u9884\u5904\u7406&#xff0c;\u5305\u62ec\u7f29\u653e\u548c\u8f6c\u6362\u4e3a\u6d6e\u70b9\u6570\u3002&#034;&#034;&#034;<br \/>\n        batch[&#034;img&#034;] &#061; batch[&#034;img&#034;].to(self.device, non_blocking&#061;True).float() \/ 255  # \u8f6c\u6362\u4e3a\u6d6e\u70b9\u6570\u5e76\u5f52\u4e00\u5316<br \/>\n        if self.args.multi_scale:  # \u5982\u679c\u542f\u7528\u591a\u5c3a\u5ea6<br \/>\n            imgs &#061; batch[&#034;img&#034;]<br \/>\n            sz &#061; (<br \/>\n                random.randrange(self.args.imgsz * 0.5, self.args.imgsz * 1.5 &#043; self.stride)<br \/>\n                \/\/ self.stride<br \/>\n                * self.stride<br \/>\n            )  # \u968f\u673a\u9009\u62e9\u56fe\u50cf\u5927\u5c0f<br \/>\n            sf &#061; sz \/ max(imgs.shape[2:])  # \u8ba1\u7b97\u7f29\u653e\u56e0\u5b50<br \/>\n            if sf !&#061; 1:<br \/>\n                ns &#061; [<br \/>\n                    math.ceil(x * sf \/ self.stride) * self.stride for x in imgs.shape[2:]<br \/>\n                ]  # \u8ba1\u7b97\u65b0\u7684\u5f62\u72b6<br \/>\n                imgs &#061; nn.functional.interpolate(imgs, size&#061;ns, mode&#061;&#034;bilinear&#034;, align_corners&#061;False)  # \u8fdb\u884c\u63d2\u503c\u7f29\u653e<br \/>\n            batch[&#034;img&#034;] &#061; imgs  # \u66f4\u65b0\u56fe\u50cf<br \/>\n        return batch<\/p>\n<p>    def get_model(self, cfg&#061;None, weights&#061;None, verbose&#061;True):<br \/>\n        &#034;&#034;&#034;\u8fd4\u56de YOLO \u68c0\u6d4b\u6a21\u578b\u3002&#034;&#034;&#034;<br \/>\n        model &#061; DetectionModel(cfg, nc&#061;self.data[&#034;nc&#034;], verbose&#061;verbose and RANK &#061;&#061; -1)  # \u521b\u5efa\u68c0\u6d4b\u6a21\u578b<br \/>\n        if weights:<br \/>\n            model.load(weights)  # \u52a0\u8f7d\u6743\u91cd<br \/>\n        return model<\/p>\n<p>    def plot_training_samples(self, batch, ni):<br \/>\n        &#034;&#034;&#034;\u7ed8\u5236\u5e26\u6709\u6ce8\u91ca\u7684\u8bad\u7ec3\u6837\u672c\u3002&#034;&#034;&#034;<br \/>\n        plot_images(<br \/>\n            images&#061;batch[&#034;img&#034;],<br \/>\n            batch_idx&#061;batch[&#034;batch_idx&#034;],<br \/>\n            cls&#061;batch[&#034;cls&#034;].squeeze(-1),<br \/>\n            bboxes&#061;batch[&#034;bboxes&#034;],<br \/>\n            paths&#061;batch[&#034;im_file&#034;],<br \/>\n            fname&#061;self.save_dir \/ f&#034;train_batch{ni}.jpg&#034;,<br \/>\n            on_plot&#061;self.on_plot,<br \/>\n        )<\/p>\n<p>    def plot_metrics(self):<br \/>\n        &#034;&#034;&#034;\u4ece CSV \u6587\u4ef6\u4e2d\u7ed8\u5236\u6307\u6807\u3002&#034;&#034;&#034;<br \/>\n        plot_results(file&#061;self.csv, on_plot&#061;self.on_plot)  # \u4fdd\u5b58\u7ed3\u679c\u56fe<\/p>\n<h4>\u4ee3\u7801\u8bf4\u660e&#xff1a;<\/h4>\n<li>DetectionTrainer \u7c7b&#xff1a;\u7ee7\u627f\u81ea BaseTrainer&#xff0c;\u7528\u4e8e\u5b9e\u73b0 YOLO \u6a21\u578b\u7684\u8bad\u7ec3\u3002<\/li>\n<li>build_dataset \u65b9\u6cd5&#xff1a;\u6839\u636e\u7ed9\u5b9a\u7684\u56fe\u50cf\u8def\u5f84\u548c\u6a21\u5f0f\u6784\u5efa\u6570\u636e\u96c6&#xff0c;\u652f\u6301\u8bad\u7ec3\u548c\u9a8c\u8bc1\u6a21\u5f0f\u3002<\/li>\n<li>get_dataloader \u65b9\u6cd5&#xff1a;\u6784\u9020\u6570\u636e\u52a0\u8f7d\u5668&#xff0c;\u786e\u4fdd\u5728\u5206\u5e03\u5f0f\u8bad\u7ec3\u65f6\u53ea\u521d\u59cb\u5316\u4e00\u6b21\u6570\u636e\u96c6\u3002<\/li>\n<li>preprocess_batch \u65b9\u6cd5&#xff1a;\u5bf9\u8f93\u5165\u7684\u56fe\u50cf\u6279\u6b21\u8fdb\u884c\u9884\u5904\u7406&#xff0c;\u5305\u62ec\u5f52\u4e00\u5316\u548c\u591a\u5c3a\u5ea6\u8c03\u6574\u3002<\/li>\n<li>get_model \u65b9\u6cd5&#xff1a;\u8fd4\u56de\u4e00\u4e2a YOLO \u68c0\u6d4b\u6a21\u578b&#xff0c;\u53ef\u4ee5\u9009\u62e9\u52a0\u8f7d\u9884\u8bad\u7ec3\u6743\u91cd\u3002<\/li>\n<li>plot_training_samples \u65b9\u6cd5&#xff1a;\u7ed8\u5236\u8bad\u7ec3\u6837\u672c\u53ca\u5176\u6ce8\u91ca&#xff0c;\u4fbf\u4e8e\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b\u3002<\/li>\n<li>plot_metrics \u65b9\u6cd5&#xff1a;\u4ece CSV \u6587\u4ef6\u4e2d\u7ed8\u5236\u8bad\u7ec3\u6307\u6807&#xff0c;\u4fbf\u4e8e\u76d1\u63a7\u8bad\u7ec3\u6548\u679c\u3002&#096;&#096;&#096;<br \/>\n\u8fd9\u4e2a\u7a0b\u5e8f\u6587\u4ef6 train.py \u662f\u4e00\u4e2a\u7528\u4e8e\u8bad\u7ec3\u76ee\u6807\u68c0\u6d4b\u6a21\u578b\u7684\u811a\u672c&#xff0c;\u4e3b\u8981\u57fa\u4e8e YOLO&#xff08;You Only Look Once&#xff09;\u67b6\u6784\u3002\u5b83\u7ee7\u627f\u81ea BaseTrainer \u7c7b&#xff0c;\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u65b9\u6cd5\u6765\u6784\u5efa\u6570\u636e\u96c6\u3001\u52a0\u8f7d\u6570\u636e\u3001\u9884\u5904\u7406\u56fe\u50cf\u3001\u8bbe\u7f6e\u6a21\u578b\u5c5e\u6027\u3001\u83b7\u53d6\u6a21\u578b\u3001\u9a8c\u8bc1\u6a21\u578b\u3001\u8bb0\u5f55\u635f\u5931\u3001\u663e\u793a\u8bad\u7ec3\u8fdb\u5ea6\u4ee5\u53ca\u7ed8\u5236\u8bad\u7ec3\u6837\u672c\u548c\u6307\u6807\u3002<\/li>\n<p>\u9996\u5148&#xff0c;\u6587\u4ef6\u4e2d\u5bfc\u5165\u4e86\u4e00\u4e9b\u5fc5\u8981\u7684\u5e93\u548c\u6a21\u5757&#xff0c;\u5305\u62ec\u6570\u5b66\u8fd0\u7b97\u3001\u968f\u673a\u6570\u751f\u6210\u3001\u6df1\u5ea6\u5b66\u4e60\u76f8\u5173\u7684\u5e93&#xff08;\u5982 PyTorch&#xff09;&#xff0c;\u4ee5\u53ca\u4e00\u4e9b\u6765\u81ea ultralytics \u7684\u6a21\u5757&#xff0c;\u8fd9\u4e9b\u6a21\u5757\u63d0\u4f9b\u4e86\u6570\u636e\u5904\u7406\u3001\u6a21\u578b\u6784\u5efa\u548c\u8bad\u7ec3\u7684\u529f\u80fd\u3002<\/p>\n<p>DetectionTrainer \u7c7b\u662f\u8be5\u6587\u4ef6\u7684\u6838\u5fc3&#xff0c;\u8d1f\u8d23\u7ba1\u7406\u8bad\u7ec3\u8fc7\u7a0b\u3002\u5b83\u5305\u542b\u591a\u4e2a\u65b9\u6cd5&#xff0c;\u5176\u4e2d build_dataset \u65b9\u6cd5\u7528\u4e8e\u6784\u5efa YOLO \u6570\u636e\u96c6&#xff0c;\u652f\u6301\u8bad\u7ec3\u548c\u9a8c\u8bc1\u6a21\u5f0f&#xff0c;\u5e76\u5141\u8bb8\u7528\u6237\u81ea\u5b9a\u4e49\u4e0d\u540c\u7684\u589e\u5f3a\u65b9\u5f0f\u3002get_dataloader \u65b9\u6cd5\u5219\u6784\u5efa\u5e76\u8fd4\u56de\u6570\u636e\u52a0\u8f7d\u5668&#xff0c;\u786e\u4fdd\u5728\u5206\u5e03\u5f0f\u8bad\u7ec3\u65f6\u53ea\u521d\u59cb\u5316\u4e00\u6b21\u6570\u636e\u96c6&#xff0c;\u5e76\u6839\u636e\u6a21\u5f0f\u9009\u62e9\u662f\u5426\u6253\u4e71\u6570\u636e\u3002<\/p>\n<p>\u5728\u56fe\u50cf\u9884\u5904\u7406\u65b9\u9762&#xff0c;preprocess_batch \u65b9\u6cd5\u8d1f\u8d23\u5c06\u56fe\u50cf\u7f29\u653e\u5e76\u8f6c\u6362\u4e3a\u6d6e\u70b9\u6570\u683c\u5f0f&#xff0c;\u652f\u6301\u591a\u5c3a\u5ea6\u8bad\u7ec3&#xff0c;\u786e\u4fdd\u8f93\u5165\u56fe\u50cf\u7684\u5c3a\u5bf8\u9002\u5408\u6a21\u578b\u3002set_model_attributes \u65b9\u6cd5\u5219\u7528\u4e8e\u8bbe\u7f6e\u6a21\u578b\u7684\u5c5e\u6027&#xff0c;\u5982\u7c7b\u522b\u6570\u91cf\u548c\u7c7b\u522b\u540d\u79f0\u3002<\/p>\n<p>get_model \u65b9\u6cd5\u8fd4\u56de\u4e00\u4e2a YOLO \u68c0\u6d4b\u6a21\u578b&#xff0c;\u5e76\u53ef\u9009\u62e9\u52a0\u8f7d\u9884\u8bad\u7ec3\u6743\u91cd\u3002get_validator \u65b9\u6cd5\u8fd4\u56de\u4e00\u4e2a\u7528\u4e8e\u6a21\u578b\u9a8c\u8bc1\u7684\u5bf9\u8c61&#xff0c;\u5e2e\u52a9\u8bc4\u4f30\u6a21\u578b\u6027\u80fd\u3002<\/p>\n<p>\u5728\u8bad\u7ec3\u8fc7\u7a0b\u4e2d&#xff0c;label_loss_items \u65b9\u6cd5\u7528\u4e8e\u8fd4\u56de\u5e26\u6807\u7b7e\u7684\u635f\u5931\u5b57\u5178&#xff0c;progress_string \u65b9\u6cd5\u683c\u5f0f\u5316\u8bad\u7ec3\u8fdb\u5ea6\u4fe1\u606f&#xff0c;\u4fbf\u4e8e\u76d1\u63a7\u8bad\u7ec3\u72b6\u6001\u3002plot_training_samples \u548c plot_training_labels \u65b9\u6cd5\u5219\u7528\u4e8e\u53ef\u89c6\u5316\u8bad\u7ec3\u6837\u672c\u53ca\u5176\u6807\u6ce8&#xff0c;\u5e2e\u52a9\u7528\u6237\u76f4\u89c2\u4e86\u89e3\u8bad\u7ec3\u6570\u636e\u7684\u60c5\u51b5\u3002<\/p>\n<p>\u6700\u540e&#xff0c;plot_metrics \u65b9\u6cd5\u4ece CSV \u6587\u4ef6\u4e2d\u7ed8\u5236\u8bad\u7ec3\u6307\u6807&#xff0c;\u63d0\u4f9b\u4e86\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\u7684\u6027\u80fd\u53cd\u9988\u3002\u6574\u4f53\u6765\u770b&#xff0c;\u8fd9\u4e2a\u6587\u4ef6\u5b9e\u73b0\u4e86\u4e00\u4e2a\u5b8c\u6574\u7684\u76ee\u6807\u68c0\u6d4b\u6a21\u578b\u8bad\u7ec3\u6846\u67b6&#xff0c;\u6db5\u76d6\u4e86\u6570\u636e\u5904\u7406\u3001\u6a21\u578b\u8bad\u7ec3\u548c\u7ed3\u679c\u53ef\u89c6\u5316\u7b49\u591a\u4e2a\u65b9\u9762\u3002<\/p>\n<p>&#096;&#096;&#096;python<br \/>\nimport torch.nn as nn<br \/>\nimport torch<\/p>\n<p>class Conv2d_BN(torch.nn.Sequential):<br \/>\n    &#034;&#034;&#034;<br \/>\n    \u5b9a\u4e49\u4e00\u4e2a\u5305\u542b\u5377\u79ef\u5c42\u548c\u6279\u5f52\u4e00\u5316\u5c42\u7684\u6a21\u5757<br \/>\n    &#034;&#034;&#034;<br \/>\n    def __init__(self, a, b, ks&#061;1, stride&#061;1, pad&#061;0, dilation&#061;1,<br \/>\n                 groups&#061;1, bn_weight_init&#061;1):<br \/>\n        super().__init__()<br \/>\n        # \u6dfb\u52a0\u5377\u79ef\u5c42<br \/>\n        self.add_module(&#039;c&#039;, torch.nn.Conv2d(<br \/>\n            a, b, ks, stride, pad, dilation, groups, bias&#061;False))<br \/>\n        # \u6dfb\u52a0\u6279\u5f52\u4e00\u5316\u5c42<br \/>\n        self.add_module(&#039;bn&#039;, torch.nn.BatchNorm2d(b))<br \/>\n        # \u521d\u59cb\u5316\u6279\u5f52\u4e00\u5316\u5c42\u7684\u6743\u91cd<br \/>\n        torch.nn.init.constant_(self.bn.weight, bn_weight_init)<br \/>\n        torch.nn.init.constant_(self.bn.bias, 0)<\/p>\n<p>    &#064;torch.no_grad()<br \/>\n    def fuse_self(self):<br \/>\n        &#034;&#034;&#034;<br \/>\n        \u5c06\u5377\u79ef\u5c42\u548c\u6279\u5f52\u4e00\u5316\u5c42\u878d\u5408\u4e3a\u4e00\u4e2a\u5377\u79ef\u5c42<br \/>\n        &#034;&#034;&#034;<br \/>\n        c, bn &#061; self._modules.values()  # \u83b7\u53d6\u5377\u79ef\u5c42\u548c\u6279\u5f52\u4e00\u5316\u5c42<br \/>\n        # \u8ba1\u7b97\u878d\u5408\u540e\u7684\u6743\u91cd\u548c\u504f\u7f6e<br \/>\n        w &#061; bn.weight \/ (bn.running_var &#043; bn.eps)**0.5<br \/>\n        w &#061; c.weight * w[:, None, None, None]<br \/>\n        b &#061; bn.bias &#8211; bn.running_mean * bn.weight \/ (bn.running_var &#043; bn.eps)**0.5<br \/>\n        # \u521b\u5efa\u65b0\u7684\u5377\u79ef\u5c42<br \/>\n        m &#061; torch.nn.Conv2d(w.size(1) * self.c.groups, w.size(0), w.shape[2:],<br \/>\n                             stride&#061;self.c.stride, padding&#061;self.c.padding,<br \/>\n                             dilation&#061;self.c.dilation, groups&#061;self.c.groups,<br \/>\n                             device&#061;c.weight.device)<br \/>\n        m.weight.data.copy_(w)  # \u590d\u5236\u6743\u91cd<br \/>\n        m.bias.data.copy_(b)    # \u590d\u5236\u504f\u7f6e<br \/>\n        return m  # \u8fd4\u56de\u878d\u5408\u540e\u7684\u5377\u79ef\u5c42<\/p>\n<p>class RepViTBlock(nn.Module):<br \/>\n    &#034;&#034;&#034;<br \/>\n    \u5b9a\u4e49RepViT\u7684\u57fa\u672c\u5757<br \/>\n    &#034;&#034;&#034;<br \/>\n    def __init__(self, inp, hidden_dim, oup, kernel_size, stride, use_se, use_hs):<br \/>\n        super(RepViTBlock, self).__init__()<br \/>\n        assert stride in [1, 2]  # \u786e\u4fdd\u6b65\u5e45\u4e3a1\u62162<br \/>\n        self.identity &#061; stride &#061;&#061; 1 and inp &#061;&#061; oup  # \u5224\u65ad\u662f\u5426\u9700\u8981\u8df3\u8dc3\u8fde\u63a5<br \/>\n        assert(hidden_dim &#061;&#061; 2 * inp)  # \u9690\u85cf\u5c42\u7ef4\u5ea6\u4e3a\u8f93\u5165\u7ef4\u5ea6\u7684\u4e24\u500d<\/p>\n<p>        if stride &#061;&#061; 2:<br \/>\n            # \u5982\u679c\u6b65\u5e45\u4e3a2&#xff0c;\u5b9a\u4e49token\u6df7\u5408\u548c\u901a\u9053\u6df7\u5408<br \/>\n            self.token_mixer &#061; nn.Sequential(<br \/>\n                Conv2d_BN(inp, inp, kernel_size, stride, (kernel_size &#8211; 1) \/\/ 2, groups&#061;inp),<br \/>\n                nn.Identity() if not use_se else SqueezeExcite(inp, 0.25),<br \/>\n                Conv2d_BN(inp, oup, ks&#061;1, stride&#061;1, pad&#061;0)<br \/>\n            )<br \/>\n            self.channel_mixer &#061; nn.Sequential(<br \/>\n                Conv2d_BN(oup, 2 * oup, 1, 1, 0),<br \/>\n                nn.GELU() if use_hs else nn.GELU(),<br \/>\n                Conv2d_BN(2 * oup, oup, 1, 1, 0, bn_weight_init&#061;0),<br \/>\n            )<br \/>\n        else:<br \/>\n            assert(self.identity)  # \u5982\u679c\u6b65\u5e45\u4e3a1&#xff0c;\u786e\u4fdd\u8f93\u5165\u548c\u8f93\u51fa\u901a\u9053\u76f8\u540c<br \/>\n            self.token_mixer &#061; nn.Sequential(<br \/>\n                Conv2d_BN(inp, inp, 3, 1, 1, groups&#061;inp),<br \/>\n                nn.Identity() if not use_se else SqueezeExcite(inp, 0.25),<br \/>\n            )<br \/>\n            self.channel_mixer &#061; nn.Sequential(<br \/>\n                Conv2d_BN(inp, hidden_dim, 1, 1, 0),<br \/>\n                nn.GELU() if use_hs else nn.GELU(),<br \/>\n                Conv2d_BN(hidden_dim, oup, 1, 1, 0, bn_weight_init&#061;0),<br \/>\n            )<\/p>\n<p>    def forward(self, x):<br \/>\n        &#034;&#034;&#034;<br \/>\n        \u524d\u5411\u4f20\u64ad<br \/>\n        &#034;&#034;&#034;<br \/>\n        return self.channel_mixer(self.token_mixer(x))  # \u5148\u8fdb\u884ctoken\u6df7\u5408&#xff0c;\u518d\u8fdb\u884c\u901a\u9053\u6df7\u5408<\/p>\n<p>class RepViT(nn.Module):<br \/>\n    &#034;&#034;&#034;<br \/>\n    \u5b9a\u4e49RepViT\u6a21\u578b<br \/>\n    &#034;&#034;&#034;<br \/>\n    def __init__(self, cfgs):<br \/>\n        super(RepViT, self).__init__()<br \/>\n        self.cfgs &#061; cfgs  # \u914d\u7f6e\u53cd\u5411\u6b8b\u5dee\u5757<br \/>\n        input_channel &#061; self.cfgs[0][2]  # \u83b7\u53d6\u8f93\u5165\u901a\u9053\u6570<br \/>\n        # \u6784\u5efa\u7b2c\u4e00\u4e2a\u5c42<br \/>\n        patch_embed &#061; nn.Sequential(<br \/>\n            Conv2d_BN(3, input_channel \/\/ 2, 3, 2, 1),<br \/>\n            nn.GELU(),<br \/>\n            Conv2d_BN(input_channel \/\/ 2, input_channel, 3, 2, 1)<br \/>\n        )<br \/>\n        layers &#061; [patch_embed]  # \u5b58\u50a8\u6240\u6709\u5c42<br \/>\n        # \u6784\u5efa\u53cd\u5411\u6b8b\u5dee\u5757<br \/>\n        for k, t, c, use_se, use_hs, s in self.cfgs:<br \/>\n            output_channel &#061; _make_divisible(c, 8)  # \u786e\u4fdd\u8f93\u51fa\u901a\u9053\u6570\u53ef\u88ab8\u6574\u9664<br \/>\n            exp_size &#061; _make_divisible(input_channel * t, 8)  # \u786e\u4fdd\u6269\u5c55\u901a\u9053\u6570\u53ef\u88ab8\u6574\u9664<br \/>\n            layers.append(RepViTBlock(input_channel, exp_size, output_channel, k, s, use_se, use_hs))<br \/>\n            input_channel &#061; output_channel  # \u66f4\u65b0\u8f93\u5165\u901a\u9053\u6570<br \/>\n        self.features &#061; nn.ModuleList(layers)  # \u5c06\u6240\u6709\u5c42\u5b58\u50a8\u4e3aModuleList<\/p>\n<p>    def forward(self, x):<br \/>\n        &#034;&#034;&#034;<br \/>\n        \u524d\u5411\u4f20\u64ad<br \/>\n        &#034;&#034;&#034;<br \/>\n        features &#061; [None, None, None, None]  # \u5b58\u50a8\u7279\u5f81\u56fe<br \/>\n        for f in self.features:<br \/>\n            x &#061; f(x)  # \u901a\u8fc7\u6bcf\u4e00\u5c42<br \/>\n            # \u6839\u636e\u8f93\u5165\u5927\u5c0f\u8bb0\u5f55\u7279\u5f81\u56fe<br \/>\n            if x.size(2) in [x.size(2) \/\/ 4, x.size(2) \/\/ 8, x.size(2) \/\/ 16, x.size(2) \/\/ 32]:<br \/>\n                features[x.size(2) \/\/ x.size(2)] &#061; x<br \/>\n        return features  # \u8fd4\u56de\u7279\u5f81\u56fe<\/p>\n<p>def repvit_m0_9(weights&#061;&#039;&#039;):<br \/>\n    &#034;&#034;&#034;<br \/>\n    \u6784\u5efaRepViT\u6a21\u578b\u7684\u4e00\u4e2a\u53d8\u4f53<br \/>\n    &#034;&#034;&#034;<br \/>\n    cfgs &#061; [<br \/>\n        # k, t, c, SE, HS, s<br \/>\n        [3, 2, 48, 1, 0, 1],<br \/>\n        # \u5176\u4ed6\u914d\u7f6e&#8230;<br \/>\n    ]<br \/>\n    model &#061; RepViT(cfgs)  # \u521b\u5efa\u6a21\u578b<br \/>\n    if weights:<br \/>\n        model.load_state_dict(update_weight(model.state_dict(), torch.load(weights)[&#039;model&#039;]))  # \u52a0\u8f7d\u6743\u91cd<br \/>\n    return model  # \u8fd4\u56de\u6a21\u578b<\/p>\n<h4>\u4ee3\u7801\u8bf4\u660e&#xff1a;<\/h4>\n<li>Conv2d_BN\u7c7b&#xff1a;\u5b9a\u4e49\u4e86\u4e00\u4e2a\u5305\u542b\u5377\u79ef\u5c42\u548c\u6279\u5f52\u4e00\u5316\u5c42\u7684\u7ec4\u5408&#xff0c;\u63d0\u4f9b\u4e86\u878d\u5408\u529f\u80fd\u4ee5\u63d0\u9ad8\u63a8\u7406\u901f\u5ea6\u3002<\/li>\n<li>RepViTBlock\u7c7b&#xff1a;\u5b9e\u73b0\u4e86RepViT\u7684\u57fa\u672c\u5757&#xff0c;\u652f\u6301\u4e0d\u540c\u7684\u6b65\u5e45\u548c\u901a\u9053\u6df7\u5408\u65b9\u5f0f\u3002<\/li>\n<li>RepViT\u7c7b&#xff1a;\u6784\u5efa\u4e86\u6574\u4e2aRepViT\u6a21\u578b&#xff0c;\u4f7f\u7528\u914d\u7f6e\u53c2\u6570\u6765\u5b9a\u4e49\u5404\u4e2a\u5c42\u7684\u7ed3\u6784\u3002<\/li>\n<li>repvit_m0_9\u51fd\u6570&#xff1a;\u7528\u4e8e\u521b\u5efaRepViT\u6a21\u578b\u7684\u7279\u5b9a\u53d8\u4f53&#xff0c;\u5e76\u53ef\u9009\u62e9\u52a0\u8f7d\u9884\u8bad\u7ec3\u6743\u91cd\u3002<\/li>\n<p>\u8fd9\u4e9b\u6838\u5fc3\u90e8\u5206\u662f\u6784\u5efaRepViT\u6a21\u578b\u7684\u57fa\u7840&#xff0c;\u8d1f\u8d23\u5b9a\u4e49\u7f51\u7edc\u7ed3\u6784\u548c\u524d\u5411\u4f20\u64ad\u8fc7\u7a0b\u3002&#096;&#096;&#096;<br \/>\n\u8fd9\u4e2a\u7a0b\u5e8f\u6587\u4ef6\u5b9a\u4e49\u4e86\u4e00\u4e2a\u57fa\u4e8eRepVGG\u67b6\u6784\u7684\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b&#xff0c;\u4e3b\u8981\u7528\u4e8e\u8ba1\u7b97\u673a\u89c6\u89c9\u4efb\u52a1\u3002\u6587\u4ef6\u4e2d\u5305\u542b\u4e86\u591a\u4e2a\u7c7b\u548c\u51fd\u6570&#xff0c;\u6784\u5efa\u4e86\u4e00\u4e2a\u53ef\u914d\u7f6e\u7684\u795e\u7ecf\u7f51\u7edc\u6a21\u578b&#xff0c;\u5177\u4f53\u5b9e\u73b0\u4e86RepViT&#xff08;\u4ee3\u8868\u6027\u89c6\u89c9\u53d8\u6362\u5668&#xff09;\u6a21\u578b\u3002<\/p>\n<p>\u9996\u5148&#xff0c;\u6587\u4ef6\u5f15\u5165\u4e86\u5fc5\u8981\u7684\u5e93&#xff0c;\u5305\u62ecPyTorch\u548c\u4e00\u4e9b\u7528\u4e8e\u6784\u5efa\u6a21\u578b\u7684\u6a21\u5757\u3002__all__\u5b9a\u4e49\u4e86\u53ef\u4ee5\u88ab\u5916\u90e8\u8c03\u7528\u7684\u6a21\u578b\u7248\u672c&#xff0c;\u5305\u62ec\u4e0d\u540c\u7684RepViT\u6a21\u578b\u3002<\/p>\n<p>replace_batchnorm\u51fd\u6570\u7528\u4e8e\u66ff\u6362\u7f51\u7edc\u4e2d\u7684BatchNorm\u5c42&#xff0c;\u5c06\u5176\u8f6c\u6362\u4e3aIdentity\u5c42&#xff0c;\u4ee5\u4fbf\u5728\u63a8\u7406\u65f6\u52a0\u901f\u8ba1\u7b97\u3002_make_divisible\u51fd\u6570\u786e\u4fdd\u7f51\u7edc\u4e2d\u6240\u6709\u5c42\u7684\u901a\u9053\u6570\u90fd\u662f8\u7684\u500d\u6570&#xff0c;\u8fd9\u662f\u4e3a\u4e86\u517c\u5bb9\u67d0\u4e9b\u786c\u4ef6\u52a0\u901f\u5668\u7684\u8981\u6c42\u3002<\/p>\n<p>Conv2d_BN\u7c7b\u662f\u4e00\u4e2a\u7ec4\u5408\u6a21\u5757&#xff0c;\u5305\u542b\u5377\u79ef\u5c42\u548cBatchNorm\u5c42&#xff0c;\u5e76\u5728\u521d\u59cb\u5316\u65f6\u8bbe\u7f6e\u4e86BatchNorm\u7684\u6743\u91cd\u548c\u504f\u7f6e\u3002\u5b83\u8fd8\u5b9e\u73b0\u4e86fuse_self\u65b9\u6cd5&#xff0c;\u7528\u4e8e\u5c06\u5377\u79ef\u548cBatchNorm\u5c42\u878d\u5408\u4e3a\u4e00\u4e2a\u5377\u79ef\u5c42&#xff0c;\u4ee5\u63d0\u9ad8\u63a8\u7406\u901f\u5ea6\u3002<\/p>\n<p>Residual\u7c7b\u5b9e\u73b0\u4e86\u6b8b\u5dee\u8fde\u63a5&#xff0c;\u5141\u8bb8\u5728\u8bad\u7ec3\u65f6\u968f\u673a\u4e22\u5f03\u4e00\u4e9b\u8f93\u5165&#xff0c;\u4ee5\u589e\u5f3a\u6a21\u578b\u7684\u9c81\u68d2\u6027\u3002\u5b83\u540c\u6837\u652f\u6301\u5c42\u7684\u878d\u5408\u3002<\/p>\n<p>RepVGGDW\u7c7b\u5b9e\u73b0\u4e86\u4e00\u4e2a\u6df1\u5ea6\u53ef\u5206\u79bb\u5377\u79ef\u6a21\u5757&#xff0c;\u7ed3\u5408\u4e86\u5377\u79ef\u548cBatchNorm&#xff0c;\u5e76\u652f\u6301\u878d\u5408\u64cd\u4f5c\u3002<\/p>\n<p>RepViTBlock\u7c7b\u662fRepViT\u6a21\u578b\u7684\u57fa\u672c\u6784\u5efa\u5757&#xff0c;\u5305\u542b\u4e86\u901a\u9053\u6df7\u5408\u548c\u4ee4\u724c\u6df7\u5408\u7684\u64cd\u4f5c\u3002\u6839\u636e\u6b65\u5e45\u7684\u4e0d\u540c&#xff0c;\u6784\u5efa\u4e86\u4e0d\u540c\u7684\u7f51\u7edc\u7ed3\u6784\u3002<\/p>\n<p>RepViT\u7c7b\u662f\u6574\u4e2a\u6a21\u578b\u7684\u4e3b\u4f53&#xff0c;\u63a5\u6536\u914d\u7f6e\u53c2\u6570\u5e76\u6784\u5efa\u7f51\u7edc\u3002\u5b83\u7684forward\u65b9\u6cd5\u5b9a\u4e49\u4e86\u524d\u5411\u4f20\u64ad\u7684\u8fc7\u7a0b&#xff0c;\u5e76\u5728\u8f93\u5165\u5c3a\u5bf8\u53d8\u5316\u65f6\u63d0\u53d6\u7279\u5f81\u3002<\/p>\n<p>update_weight\u51fd\u6570\u7528\u4e8e\u66f4\u65b0\u6a21\u578b\u7684\u6743\u91cd&#xff0c;\u5c06\u9884\u8bad\u7ec3\u6a21\u578b\u7684\u6743\u91cd\u52a0\u8f7d\u5230\u5f53\u524d\u6a21\u578b\u4e2d\u3002<\/p>\n<p>\u6700\u540e&#xff0c;\u5b9a\u4e49\u4e86\u591a\u4e2a\u6a21\u578b\u6784\u9020\u51fd\u6570&#xff0c;\u5982repvit_m0_9\u3001repvit_m1_0\u7b49&#xff0c;\u8fd9\u4e9b\u51fd\u6570\u6839\u636e\u4e0d\u540c\u7684\u914d\u7f6e\u53c2\u6570\u6784\u5efa\u4e0d\u540c\u7248\u672c\u7684RepViT\u6a21\u578b&#xff0c;\u5e76\u53ef\u9009\u62e9\u6027\u5730\u52a0\u8f7d\u9884\u8bad\u7ec3\u6743\u91cd\u3002<\/p>\n<p>\u5728\u6587\u4ef6\u7684\u6700\u540e\u90e8\u5206&#xff0c;\u63d0\u4f9b\u4e86\u4e00\u4e2a\u793a\u4f8b\u4ee3\u7801&#xff0c;\u521b\u5efa\u4e86\u4e00\u4e2aRepViT\u6a21\u578b\u5b9e\u4f8b&#xff0c;\u5e76\u5bf9\u968f\u673a\u8f93\u5165\u8fdb\u884c\u4e86\u524d\u5411\u4f20\u64ad&#xff0c;\u8f93\u51fa\u4e86\u5404\u5c42\u7684\u7279\u5f81\u56fe\u5c3a\u5bf8\u3002<\/p>\n<p>\u6574\u4f53\u800c\u8a00&#xff0c;\u8fd9\u4e2a\u6587\u4ef6\u5b9e\u73b0\u4e86\u4e00\u4e2a\u7075\u6d3b\u4e14\u9ad8\u6548\u7684\u89c6\u89c9\u6a21\u578b&#xff0c;\u9002\u7528\u4e8e\u5404\u79cd\u8ba1\u7b97\u673a\u89c6\u89c9\u4efb\u52a1&#xff0c;\u5e76\u63d0\u4f9b\u4e86\u826f\u597d\u7684\u6269\u5c55\u6027\u548c\u53ef\u914d\u7f6e\u6027\u3002<\/p>\n<p>&#096;&#096;&#096;python<br \/>\nimport torch<br \/>\nimport torch.nn.functional as F<br \/>\nfrom torch.autograd import Function<br \/>\nfrom torch.cuda.amp import custom_bwd, custom_fwd<\/p>\n<p>class DCNv3Function(Function):<br \/>\n    &#064;staticmethod<br \/>\n    &#064;custom_fwd<br \/>\n    def forward(ctx, input, offset, mask, kernel_h, kernel_w, stride_h, stride_w, pad_h, pad_w, dilation_h, dilation_w, group, group_channels, offset_scale, im2col_step, remove_center):<br \/>\n        # \u4fdd\u5b58\u5377\u79ef\u53c2\u6570\u5230\u4e0a\u4e0b\u6587\u4e2d&#xff0c;\u4ee5\u4fbf\u5728\u53cd\u5411\u4f20\u64ad\u65f6\u4f7f\u7528<br \/>\n        ctx.kernel_h &#061; kernel_h<br \/>\n        ctx.kernel_w &#061; kernel_w<br \/>\n        ctx.stride_h &#061; stride_h<br \/>\n        ctx.stride_w &#061; stride_w<br \/>\n        ctx.pad_h &#061; pad_h<br \/>\n        ctx.pad_w &#061; pad_w<br \/>\n        ctx.dilation_h &#061; dilation_h<br \/>\n        ctx.dilation_w &#061; dilation_w<br \/>\n        ctx.group &#061; group<br \/>\n        ctx.group_channels &#061; group_channels<br \/>\n        ctx.offset_scale &#061; offset_scale<br \/>\n        ctx.im2col_step &#061; im2col_step<br \/>\n        ctx.remove_center &#061; remove_center<\/p>\n<p>        # \u8c03\u7528DCNv3\u7684\u524d\u5411\u8ba1\u7b97\u51fd\u6570<br \/>\n        output &#061; DCNv3.dcnv3_forward(input, offset, mask, kernel_h, kernel_w, stride_h, stride_w, pad_h, pad_w, dilation_h, dilation_w, group, group_channels, offset_scale, ctx.im2col_step)<br \/>\n        ctx.save_for_backward(input, offset, mask)  # \u4fdd\u5b58\u8f93\u5165\u5f20\u91cf\u4ee5\u4fbf\u53cd\u5411\u4f20\u64ad\u4f7f\u7528<\/p>\n<p>        return output<\/p>\n<p>    &#064;staticmethod<br \/>\n    &#064;once_differentiable<br \/>\n    &#064;custom_bwd<br \/>\n    def backward(ctx, grad_output):<br \/>\n        # \u4ece\u4e0a\u4e0b\u6587\u4e2d\u6062\u590d\u4fdd\u5b58\u7684\u5f20\u91cf<br \/>\n        input, offset, mask &#061; ctx.saved_tensors<\/p>\n<p>        # \u8c03\u7528DCNv3\u7684\u53cd\u5411\u8ba1\u7b97\u51fd\u6570<br \/>\n        grad_input, grad_offset, grad_mask &#061; DCNv3.dcnv3_backward(input, offset, mask, ctx.kernel_h, ctx.kernel_w, ctx.stride_h, ctx.stride_w, ctx.pad_h, ctx.pad_w, ctx.dilation_h, ctx.dilation_w, ctx.group, ctx.group_channels, ctx.offset_scale, grad_output.contiguous(), ctx.im2col_step)<\/p>\n<p>        return grad_input, grad_offset, grad_mask, None, None, None, None, None, None, None, None, None, None, None, None, None<\/p>\n<p>def dcnv3_core_pytorch(input, offset, mask, kernel_h, kernel_w, stride_h, stride_w, pad_h, pad_w, dilation_h, dilation_w, group, group_channels, offset_scale, remove_center):<br \/>\n    # \u8f93\u5165\u5f20\u91cf\u8fdb\u884c\u586b\u5145<br \/>\n    input &#061; F.pad(input, [0, 0, pad_h, pad_h, pad_w, pad_w])<br \/>\n    N_, H_in, W_in, _ &#061; input.shape  # \u83b7\u53d6\u8f93\u5165\u7684\u5f62\u72b6<br \/>\n    _, H_out, W_out, _ &#061; offset.shape  # \u83b7\u53d6\u504f\u79fb\u91cf\u7684\u5f62\u72b6<\/p>\n<p>    # \u8ba1\u7b97\u53c2\u8003\u70b9\u548c\u7f51\u683c<br \/>\n    ref &#061; _get_reference_points(input.shape, input.device, kernel_h, kernel_w, dilation_h, dilation_w, pad_h, pad_w, stride_h, stride_w)<br \/>\n    grid &#061; _generate_dilation_grids(input.shape, kernel_h, kernel_w, dilation_h, dilation_w, group, input.device)<\/p>\n<p>    # \u8ba1\u7b97\u91c7\u6837\u4f4d\u7f6e<br \/>\n    sampling_locations &#061; (ref &#043; grid * offset_scale).repeat(N_, 1, 1, 1, 1)<br \/>\n    if remove_center:<br \/>\n        sampling_locations &#061; remove_center_sampling_locations(sampling_locations, kernel_w&#061;kernel_w, kernel_h&#061;kernel_h)<br \/>\n    sampling_locations &#061; sampling_locations.flatten(3, 4) &#043; offset * offset_scale \/ torch.tensor([W_in, H_in]).reshape(1, 1, 1, 2).to(input.device)<\/p>\n<p>    # \u4f7f\u7528grid_sample\u8fdb\u884c\u91c7\u6837<br \/>\n    sampling_input_ &#061; F.grid_sample(input.view(N_, H_in * W_in, group * group_channels).transpose(1, 2).reshape(N_ * group, group_channels, H_in, W_in), sampling_locations, mode&#061;&#039;bilinear&#039;, padding_mode&#061;&#039;zeros&#039;, align_corners&#061;False)<\/p>\n<p>    # \u8ba1\u7b97\u8f93\u51fa<br \/>\n    output &#061; (sampling_input_ * mask.view(N_, H_out * W_out, group, -1).transpose(1, 2).reshape(N_ * group, 1, H_out * W_out, -1)).sum(-1).view(N_, group * group_channels, H_out * W_out)<\/p>\n<p>    return output.transpose(1, 2).reshape(N_, H_out, W_out, -1).contiguous()<\/p>\n<h4>\u4ee3\u7801\u6ce8\u91ca\u8bf4\u660e&#xff1a;<\/h4>\n<li>\n<p>DCNv3Function\u7c7b&#xff1a;\u8fd9\u662f\u4e00\u4e2a\u81ea\u5b9a\u4e49\u7684PyTorch\u51fd\u6570&#xff0c;\u5305\u542b\u524d\u5411\u548c\u53cd\u5411\u4f20\u64ad\u7684\u5b9e\u73b0\u3002<\/p>\n<ul>\n<li>forward\u65b9\u6cd5&#xff1a;\u8d1f\u8d23\u8ba1\u7b97\u524d\u5411\u4f20\u64ad&#xff0c;\u4fdd\u5b58\u5fc5\u8981\u7684\u53c2\u6570\u548c\u8f93\u5165\u4ee5\u4fbf\u540e\u7eed\u53cd\u5411\u4f20\u64ad\u4f7f\u7528\u3002<\/li>\n<li>backward\u65b9\u6cd5&#xff1a;\u8d1f\u8d23\u8ba1\u7b97\u53cd\u5411\u4f20\u64ad&#xff0c;\u4f7f\u7528\u4fdd\u5b58\u7684\u8f93\u5165\u548c\u53c2\u6570\u6765\u8ba1\u7b97\u68af\u5ea6\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>dcnv3_core_pytorch\u51fd\u6570&#xff1a;\u5b9e\u73b0\u4e86DCNv3\u7684\u6838\u5fc3\u8ba1\u7b97\u903b\u8f91\u3002<\/p>\n<ul>\n<li>\u9996\u5148\u5bf9\u8f93\u5165\u8fdb\u884c\u586b\u5145\u3002<\/li>\n<li>\u8ba1\u7b97\u53c2\u8003\u70b9\u548c\u91c7\u6837\u7f51\u683c\u3002<\/li>\n<li>\u8ba1\u7b97\u91c7\u6837\u4f4d\u7f6e\u5e76\u8fdb\u884c\u91c7\u6837\u3002<\/li>\n<li>\u6700\u540e\u8ba1\u7b97\u8f93\u51fa\u7ed3\u679c\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u8f85\u52a9\u51fd\u6570&#xff1a;\u5982_get_reference_points\u548c_generate_dilation_grids\u7b49&#xff0c;\u8d1f\u8d23\u751f\u6210\u53c2\u8003\u70b9\u548c\u81a8\u80c0\u7f51\u683c&#xff0c;\u8fd9\u4e9b\u90fd\u662f\u5b9e\u73b0DCNv3\u6240\u9700\u7684\u5173\u952e\u6b65\u9aa4\u3002&#096;&#096;&#096;<br \/>\n\u8fd9\u4e2a\u7a0b\u5e8f\u6587\u4ef6\u662f\u4e00\u4e2a\u5b9e\u73b0\u6df1\u5ea6\u5b66\u4e60\u4e2d\u53ef\u53d8\u5f62\u5377\u79ef&#xff08;Deformable Convolution&#xff09;V3\u7248\u672c\u7684PyTorch\u51fd\u6570\u7684\u4ee3\u7801\u3002\u8be5\u5b9e\u73b0\u4e3b\u8981\u4f9d\u8d56\u4e8e\u4e00\u4e2a\u540d\u4e3aDCNv3\u7684\u5916\u90e8\u5e93&#xff0c;\u5e76\u63d0\u4f9b\u4e86\u524d\u5411\u548c\u53cd\u5411\u4f20\u64ad\u7684\u529f\u80fd\u3002<\/p>\n<\/li>\n<p>\u9996\u5148&#xff0c;\u6587\u4ef6\u4e2d\u5bfc\u5165\u4e86\u4e00\u4e9b\u5fc5\u8981\u7684\u5e93&#xff0c;\u5305\u62ecPyTorch\u548c\u76f8\u5173\u7684\u529f\u80fd\u6a21\u5757\u3002\u63a5\u7740&#xff0c;\u5c1d\u8bd5\u5bfc\u5165DCNv3\u5e93\u5e76\u83b7\u53d6\u5176\u7248\u672c\u4fe1\u606f&#xff0c;\u4ee5\u4fbf\u5728\u540e\u7eed\u7684\u64cd\u4f5c\u4e2d\u4f7f\u7528\u3002<\/p>\n<p>\u6838\u5fc3\u7c7b\u662fDCNv3Function&#xff0c;\u5b83\u7ee7\u627f\u81eatorch.autograd.Function&#xff0c;\u5e76\u5b9e\u73b0\u4e86\u4e09\u4e2a\u9759\u6001\u65b9\u6cd5&#xff1a;forward\u3001backward\u548csymbolic\u3002forward\u65b9\u6cd5\u7528\u4e8e\u6267\u884c\u524d\u5411\u4f20\u64ad&#xff0c;\u63a5\u6536\u8f93\u5165\u5f20\u91cf\u3001\u504f\u79fb\u91cf\u3001\u63a9\u7801\u4ee5\u53ca\u5377\u79ef\u7684\u5404\u79cd\u53c2\u6570&#xff08;\u5982\u6838\u7684\u5927\u5c0f\u3001\u6b65\u5e45\u3001\u586b\u5145\u7b49&#xff09;&#xff0c;\u5e76\u8c03\u7528DCNv3\u5e93\u4e2d\u7684\u524d\u5411\u51fd\u6570\u6765\u8ba1\u7b97\u8f93\u51fa\u3002\u8be5\u65b9\u6cd5\u8fd8\u4f1a\u4fdd\u5b58\u8f93\u5165\u3001\u504f\u79fb\u91cf\u548c\u63a9\u7801&#xff0c;\u4ee5\u4fbf\u5728\u53cd\u5411\u4f20\u64ad\u65f6\u4f7f\u7528\u3002<\/p>\n<p>backward\u65b9\u6cd5\u5b9e\u73b0\u4e86\u53cd\u5411\u4f20\u64ad\u7684\u529f\u80fd&#xff0c;\u8ba1\u7b97\u8f93\u5165\u3001\u504f\u79fb\u91cf\u548c\u63a9\u7801\u7684\u68af\u5ea6\u3002\u5b83\u4f7f\u7528\u4e86\u4fdd\u5b58\u7684\u5f20\u91cf\u548c\u4e4b\u524d\u4f20\u5165\u7684\u53c2\u6570\u6765\u8c03\u7528DCNv3\u5e93\u4e2d\u7684\u53cd\u5411\u51fd\u6570\u3002<\/p>\n<p>symbolic\u65b9\u6cd5\u7528\u4e8eONNX&#xff08;\u5f00\u653e\u795e\u7ecf\u7f51\u7edc\u4ea4\u6362&#xff09;\u6a21\u578b\u7684\u7b26\u53f7\u8868\u793a&#xff0c;\u5141\u8bb8\u5c06\u8fd9\u4e2a\u81ea\u5b9a\u4e49\u64cd\u4f5c\u5bfc\u51fa\u4e3aONNX\u683c\u5f0f\u3002<\/p>\n<p>\u63a5\u4e0b\u6765&#xff0c;\u6587\u4ef6\u4e2d\u5b9a\u4e49\u4e86\u4e00\u4e9b\u8f85\u52a9\u51fd\u6570&#xff0c;\u5305\u62ec_get_reference_points\u3001_generate_dilation_grids\u3001remove_center_sampling_locations\u548cdcnv3_core_pytorch\u3002\u8fd9\u4e9b\u51fd\u6570\u5206\u522b\u7528\u4e8e\u8ba1\u7b97\u53c2\u8003\u70b9\u3001\u751f\u6210\u81a8\u80c0\u7f51\u683c\u3001\u79fb\u9664\u4e2d\u5fc3\u91c7\u6837\u4f4d\u7f6e\u4ee5\u53ca\u5b9e\u73b0\u53ef\u53d8\u5f62\u5377\u79ef\u7684\u6838\u5fc3\u903b\u8f91\u3002<\/p>\n<p>\u5728dcnv3_core_pytorch\u51fd\u6570\u4e2d&#xff0c;\u9996\u5148\u5bf9\u8f93\u5165\u8fdb\u884c\u586b\u5145&#xff0c;\u7136\u540e\u8ba1\u7b97\u53c2\u8003\u70b9\u548c\u81a8\u80c0\u7f51\u683c\u3002\u63a5\u7740&#xff0c;\u6839\u636e\u7ed9\u5b9a\u7684\u504f\u79fb\u91cf\u548c\u63a9\u7801\u8fdb\u884c\u91c7\u6837&#xff0c;\u6700\u540e\u5c06\u7ed3\u679c\u8fdb\u884c\u5904\u7406\u5e76\u8fd4\u56de\u3002<\/p>\n<p>\u603b\u4f53\u6765\u8bf4&#xff0c;\u8fd9\u6bb5\u4ee3\u7801\u5b9e\u73b0\u4e86\u53ef\u53d8\u5f62\u5377\u79ef\u7684\u524d\u5411\u548c\u53cd\u5411\u4f20\u64ad\u8fc7\u7a0b&#xff0c;\u80fd\u591f\u5728\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\u4e2d\u7075\u6d3b\u5730\u5904\u7406\u4e0d\u540c\u5f62\u72b6\u548c\u5c3a\u5bf8\u7684\u8f93\u5165\u6570\u636e&#xff0c;\u63d0\u5347\u6a21\u578b\u7684\u8868\u8fbe\u80fd\u529b\u3002<\/p>\n<h2>\u6e90\u7801\u6587\u4ef6<\/h2>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260202054933-69803aedaf499.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h2>\u6e90\u7801\u83b7\u53d6<\/h2>\n<p>\u6b22\u8fce\u5927\u5bb6\u70b9\u8d5e\u3001\u6536\u85cf\u3001\u5173\u6ce8\u3001\u8bc4\u8bba\u5566 \u3001\u67e5\u770b&#x1f447;&#x1f3fb;\u83b7\u53d6\u8054\u7cfb\u65b9\u5f0f&#x1f447;&#x1f3fb;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u80cc\u666f\u610f\u4e49<br \/>\n\u968f\u7740\u7535\u5b50\u5546\u52a1\u7684\u8fc5\u731b\u53d1\u5c55&#xff0c;\u5feb\u9012\u884c\u4e1a\u4e5f\u968f\u4e4b\u84ec\u52c3\u5174\u8d77&#xff0c;\u5feb\u9012\u5305\u88f9\u7684\u6570\u91cf\u65e5\u76ca\u589e\u52a0\u3002\u6839\u636e\u7edf\u8ba1\u6570\u636e&#xff0c;\u5168\u7403\u5feb\u9012\u5e02\u573a\u7684\u5e74\u589e\u957f\u7387\u5df2\u8d85\u8fc710%&#xff0c;\u9884\u8ba1\u5728\u672a\u6765\u51e0\u5e74\u5185\u5c06\u7ee7\u7eed\u4fdd\u6301\u8fd9\u4e00\u589e\u957f\u8d8b\u52bf\u3002\u5728\u8fd9\u4e00\u80cc\u666f\u4e0b&#xff0c;\u5feb\u9012\u5305\u88f9\u7684\u7ba1\u7406\u548c\u5904\u7406\u6548\u7387\u6210\u4e3a\u4e86\u884c\u4e1a\u5185\u4e9f\u5f85\u89e3\u51b3\u7684\u91cd\u8981\u95ee\u9898\u3002\u4f20\u7edf\u7684\u5feb\u9012\u5305\u88f9\u68c0\u6d4b\u65b9\u6cd5\u5f80\u5f80\u4f9d\u8d56\u4eba\u5de5\u64cd\u4f5c&#xff0c;\u4e0d\u4ec5\u6548\u7387\u4f4e\u4e0b&#xff0c;\u800c\u4e14\u5bb9\u6613\u53d7\u5230\u4eba\u4e3a\u56e0\u7d20\u7684\u5f71\u54cd&#xff0c;\u5bfc\u81f4\u9519\u8bef\u7387\u8f83\u9ad8\u3002\u56e0\u6b64&#xff0c;\u57fa\u4e8e\u8ba1\u7b97<\/p>\n","protected":false},"author":2,"featured_media":70830,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[7445,156,87,5134,5281,523],"topic":[],"class_list":["post-70839","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-7445","tag-yolo","tag-87","tag-5134","tag-5281","tag-523"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u3010\u5b8c\u6574\u6e90\u7801+\u6570\u636e\u96c6+\u90e8\u7f72\u6559\u7a0b\u3011\u5feb\u9012\u76d2\u68c0\u6d4b\u68c0\u6d4b\u7cfb\u7edf\u6e90\u7801 [\u4e00\u6761\u9f99\u6559\u5b66YOLOV8\u6807\u6ce8\u597d\u7684\u6570\u636e\u96c6\u4e00\u952e\u8bad\u7ec3_70+\u5168\u5957\u6539\u8fdb\u521b\u65b0\u70b9\u53d1\u520a_Web\u524d\u7aef\u5c55\u793a] - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/70839.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u3010\u5b8c\u6574\u6e90\u7801+\u6570\u636e\u96c6+\u90e8\u7f72\u6559\u7a0b\u3011\u5feb\u9012\u76d2\u68c0\u6d4b\u68c0\u6d4b\u7cfb\u7edf\u6e90\u7801 [\u4e00\u6761\u9f99\u6559\u5b66YOLOV8\u6807\u6ce8\u597d\u7684\u6570\u636e\u96c6\u4e00\u952e\u8bad\u7ec3_70+\u5168\u5957\u6539\u8fdb\u521b\u65b0\u70b9\u53d1\u520a_Web\u524d\u7aef\u5c55\u793a] - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u80cc\u666f\u610f\u4e49 \u968f\u7740\u7535\u5b50\u5546\u52a1\u7684\u8fc5\u731b\u53d1\u5c55&#xff0c;\u5feb\u9012\u884c\u4e1a\u4e5f\u968f\u4e4b\u84ec\u52c3\u5174\u8d77&#xff0c;\u5feb\u9012\u5305\u88f9\u7684\u6570\u91cf\u65e5\u76ca\u589e\u52a0\u3002\u6839\u636e\u7edf\u8ba1\u6570\u636e&#xff0c;\u5168\u7403\u5feb\u9012\u5e02\u573a\u7684\u5e74\u589e\u957f\u7387\u5df2\u8d85\u8fc710%&#xff0c;\u9884\u8ba1\u5728\u672a\u6765\u51e0\u5e74\u5185\u5c06\u7ee7\u7eed\u4fdd\u6301\u8fd9\u4e00\u589e\u957f\u8d8b\u52bf\u3002\u5728\u8fd9\u4e00\u80cc\u666f\u4e0b&#xff0c;\u5feb\u9012\u5305\u88f9\u7684\u7ba1\u7406\u548c\u5904\u7406\u6548\u7387\u6210\u4e3a\u4e86\u884c\u4e1a\u5185\u4e9f\u5f85\u89e3\u51b3\u7684\u91cd\u8981\u95ee\u9898\u3002\u4f20\u7edf\u7684\u5feb\u9012\u5305\u88f9\u68c0\u6d4b\u65b9\u6cd5\u5f80\u5f80\u4f9d\u8d56\u4eba\u5de5\u64cd\u4f5c&#xff0c;\u4e0d\u4ec5\u6548\u7387\u4f4e\u4e0b&#xff0c;\u800c\u4e14\u5bb9\u6613\u53d7\u5230\u4eba\u4e3a\u56e0\u7d20\u7684\u5f71\u54cd&#xff0c;\u5bfc\u81f4\u9519\u8bef\u7387\u8f83\u9ad8\u3002\u56e0\u6b64&#xff0c;\u57fa\u4e8e\u8ba1\u7b97\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/70839.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-02-02T05:49:34+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260202054924-69803ae457a04.jpg\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"17 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/70839.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/70839.html\",\"name\":\"\u3010\u5b8c\u6574\u6e90\u7801+\u6570\u636e\u96c6+\u90e8\u7f72\u6559\u7a0b\u3011\u5feb\u9012\u76d2\u68c0\u6d4b\u68c0\u6d4b\u7cfb\u7edf\u6e90\u7801 [\u4e00\u6761\u9f99\u6559\u5b66YOLOV8\u6807\u6ce8\u597d\u7684\u6570\u636e\u96c6\u4e00\u952e\u8bad\u7ec3_70+\u5168\u5957\u6539\u8fdb\u521b\u65b0\u70b9\u53d1\u520a_Web\u524d\u7aef\u5c55\u793a] - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-02-02T05:49:34+00:00\",\"dateModified\":\"2026-02-02T05:49:34+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/70839.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/70839.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/70839.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u3010\u5b8c\u6574\u6e90\u7801+\u6570\u636e\u96c6+\u90e8\u7f72\u6559\u7a0b\u3011\u5feb\u9012\u76d2\u68c0\u6d4b\u68c0\u6d4b\u7cfb\u7edf\u6e90\u7801 [\u4e00\u6761\u9f99\u6559\u5b66YOLOV8\u6807\u6ce8\u597d\u7684\u6570\u636e\u96c6\u4e00\u952e\u8bad\u7ec3_70+\u5168\u5957\u6539\u8fdb\u521b\u65b0\u70b9\u53d1\u520a_Web\u524d\u7aef\u5c55\u793a]\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u3010\u5b8c\u6574\u6e90\u7801+\u6570\u636e\u96c6+\u90e8\u7f72\u6559\u7a0b\u3011\u5feb\u9012\u76d2\u68c0\u6d4b\u68c0\u6d4b\u7cfb\u7edf\u6e90\u7801 [\u4e00\u6761\u9f99\u6559\u5b66YOLOV8\u6807\u6ce8\u597d\u7684\u6570\u636e\u96c6\u4e00\u952e\u8bad\u7ec3_70+\u5168\u5957\u6539\u8fdb\u521b\u65b0\u70b9\u53d1\u520a_Web\u524d\u7aef\u5c55\u793a] - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/70839.html","og_locale":"zh_CN","og_type":"article","og_title":"\u3010\u5b8c\u6574\u6e90\u7801+\u6570\u636e\u96c6+\u90e8\u7f72\u6559\u7a0b\u3011\u5feb\u9012\u76d2\u68c0\u6d4b\u68c0\u6d4b\u7cfb\u7edf\u6e90\u7801 [\u4e00\u6761\u9f99\u6559\u5b66YOLOV8\u6807\u6ce8\u597d\u7684\u6570\u636e\u96c6\u4e00\u952e\u8bad\u7ec3_70+\u5168\u5957\u6539\u8fdb\u521b\u65b0\u70b9\u53d1\u520a_Web\u524d\u7aef\u5c55\u793a] - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u80cc\u666f\u610f\u4e49 \u968f\u7740\u7535\u5b50\u5546\u52a1\u7684\u8fc5\u731b\u53d1\u5c55&#xff0c;\u5feb\u9012\u884c\u4e1a\u4e5f\u968f\u4e4b\u84ec\u52c3\u5174\u8d77&#xff0c;\u5feb\u9012\u5305\u88f9\u7684\u6570\u91cf\u65e5\u76ca\u589e\u52a0\u3002\u6839\u636e\u7edf\u8ba1\u6570\u636e&#xff0c;\u5168\u7403\u5feb\u9012\u5e02\u573a\u7684\u5e74\u589e\u957f\u7387\u5df2\u8d85\u8fc710%&#xff0c;\u9884\u8ba1\u5728\u672a\u6765\u51e0\u5e74\u5185\u5c06\u7ee7\u7eed\u4fdd\u6301\u8fd9\u4e00\u589e\u957f\u8d8b\u52bf\u3002\u5728\u8fd9\u4e00\u80cc\u666f\u4e0b&#xff0c;\u5feb\u9012\u5305\u88f9\u7684\u7ba1\u7406\u548c\u5904\u7406\u6548\u7387\u6210\u4e3a\u4e86\u884c\u4e1a\u5185\u4e9f\u5f85\u89e3\u51b3\u7684\u91cd\u8981\u95ee\u9898\u3002\u4f20\u7edf\u7684\u5feb\u9012\u5305\u88f9\u68c0\u6d4b\u65b9\u6cd5\u5f80\u5f80\u4f9d\u8d56\u4eba\u5de5\u64cd\u4f5c&#xff0c;\u4e0d\u4ec5\u6548\u7387\u4f4e\u4e0b&#xff0c;\u800c\u4e14\u5bb9\u6613\u53d7\u5230\u4eba\u4e3a\u56e0\u7d20\u7684\u5f71\u54cd&#xff0c;\u5bfc\u81f4\u9519\u8bef\u7387\u8f83\u9ad8\u3002\u56e0\u6b64&#xff0c;\u57fa\u4e8e\u8ba1\u7b97","og_url":"https:\/\/www.wsisp.com\/helps\/70839.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-02-02T05:49:34+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260202054924-69803ae457a04.jpg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"17 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/70839.html","url":"https:\/\/www.wsisp.com\/helps\/70839.html","name":"\u3010\u5b8c\u6574\u6e90\u7801+\u6570\u636e\u96c6+\u90e8\u7f72\u6559\u7a0b\u3011\u5feb\u9012\u76d2\u68c0\u6d4b\u68c0\u6d4b\u7cfb\u7edf\u6e90\u7801 [\u4e00\u6761\u9f99\u6559\u5b66YOLOV8\u6807\u6ce8\u597d\u7684\u6570\u636e\u96c6\u4e00\u952e\u8bad\u7ec3_70+\u5168\u5957\u6539\u8fdb\u521b\u65b0\u70b9\u53d1\u520a_Web\u524d\u7aef\u5c55\u793a] - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-02-02T05:49:34+00:00","dateModified":"2026-02-02T05:49:34+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/70839.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/70839.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/70839.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u3010\u5b8c\u6574\u6e90\u7801+\u6570\u636e\u96c6+\u90e8\u7f72\u6559\u7a0b\u3011\u5feb\u9012\u76d2\u68c0\u6d4b\u68c0\u6d4b\u7cfb\u7edf\u6e90\u7801 [\u4e00\u6761\u9f99\u6559\u5b66YOLOV8\u6807\u6ce8\u597d\u7684\u6570\u636e\u96c6\u4e00\u952e\u8bad\u7ec3_70+\u5168\u5957\u6539\u8fdb\u521b\u65b0\u70b9\u53d1\u520a_Web\u524d\u7aef\u5c55\u793a]"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/70839","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=70839"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/70839\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/70830"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=70839"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=70839"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=70839"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=70839"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}