{"id":124508,"date":"2026-11-19T02:48:45","date_gmt":"2026-11-18T18:48:45","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/124508.html"},"modified":"2026-11-19T02:48:45","modified_gmt":"2026-11-18T18:48:45","slug":"%e4%bb%8e%e9%9b%b6%e6%8b%86%e8%a7%a3%e4%b8%80%e4%b8%aa-yolov8-%e5%ae%89%e5%85%a8%e5%b8%bd%e6%a3%80%e6%b5%8b%e7%b3%bb%e7%bb%9f%ef%bc%9a%e6%a8%a1%e5%9e%8b%e8%ae%ad%e7%bb%83-pyqt5-%e6%a1%8c%e9%9d%a2","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/124508.html","title":{"rendered":"\u4ece\u96f6\u62c6\u89e3\u4e00\u4e2a YOLOv8 \u5b89\u5168\u5e3d\u68c0\u6d4b\u7cfb\u7edf\uff1a\u6a21\u578b\u8bad\u7ec3 + PyQt5 \u684c\u9762\u7aef\u7684\u5b8c\u6574\u5de5\u7a0b\u7ed3\u6784"},"content":{"rendered":"<hr \/>\n<p>\u00a0\n<\/p>\n<p>\u505a\u5b89\u5168\u5e3d\u68c0\u6d4b\u7684\u7ec3\u624b\u9879\u76ee\u5f88\u591a&#xff0c;\u4f46\u5927\u591a\u6570\u53ea\u7ed9\u4e00\u4e2a train.py \u548c\u4e00\u4e2a detect.py&#xff0c;\u771f\u6b63\u628a\u5b83\u505a\u6210\u300c\u80fd\u70b9\u3001\u80fd\u5b58\u3001\u80fd\u770b\u300d\u7684\u684c\u9762\u8f6f\u4ef6\u7684\u8d44\u6599\u5e76\u4e0d\u591a\u3002\u8fd9\u7bc7\u6587\u7ae0\u6309\u5de5\u7a0b\u771f\u5b9e\u7684\u6587\u4ef6\u987a\u5e8f\u5f80\u4e0b\u62c6&#xff1a;\u5148\u8bb2\u6e05\u695a\u8fd9\u4e2a\u4efb\u52a1\u5230\u5e95\u96be\u5728\u54ea\u3001\u65b9\u6848\u4e3a\u4ec0\u4e48\u8fd9\u4e48\u5206\u5c42&#xff0c;\u518d\u628a YOLOv8 \u7684\u7f51\u7edc\u7ed3\u6784\u4e0e\u635f\u5931\u8bb2\u900f&#xff0c;\u7136\u540e\u662f\u6570\u636e\u96c6\u7ec4\u7ec7\u3001\u8bad\u7ec3\u8d85\u53c2\u3001\u8bad\u7ec3\u65e5\u5fd7\u91cc\u90a3\u6761\u66f2\u7ebf\u5230\u5e95\u8bf4\u660e\u4e86\u4ec0\u4e48&#xff0c;\u63a5\u7740\u9010\u6bb5\u8bfb\u6838\u5fc3\u4ee3\u7801&#xff0c;\u6700\u540e\u7ed9\u51fa\u90e8\u7f72\u6b65\u9aa4\u3001\u5e38\u89c1\u62a5\u9519\u6392\u67e5\u8868\u548c\u4e00\u4efd\u8001\u5b9e\u7684\u6548\u679c\u5206\u6790\u3002\u8bfb\u5b8c\u4f60\u5e94\u8be5\u80fd\u72ec\u7acb\u590d\u73b0\u8fd9\u5957\u6d41\u7a0b&#xff0c;\u4e5f\u80fd\u5224\u65ad\u522b\u4eba\u535a\u5ba2\u91cc\u90a3\u4e9b\u300c\u51c6\u786e\u7387 98%\u300d\u5230\u5e95\u9760\u4e0d\u9760\u8c31\u3002<\/p>\n<hr \/>\n<h3 id=\"_1\">\u4e00\u3001\u9879\u76ee\u80cc\u666f<\/h3>\n<p>\u65bd\u5de5\u73b0\u573a\u7684\u5b89\u5168\u5e3d\u4f69\u6234\u68c0\u67e5&#xff0c;\u672c\u8d28\u662f\u4e00\u4e2a\u53cc\u7c7b\u522b\u68c0\u6d4b\u95ee\u9898&#xff1a;\u65e2\u8981\u627e\u5230\u300c\u4eba\u300d&#xff0c;\u4e5f\u8981\u5224\u65ad\u300c\u4eba\u5934\u4e0a\u6709\u6ca1\u6709\u5b89\u5168\u5e3d\u300d\u3002\u6ce8\u610f\u8fd9\u91cc\u4e0d\u662f\u5206\u7c7b\u4efb\u52a1\u2014\u2014\u5206\u7c7b\u53ea\u80fd\u56de\u7b54\u300c\u8fd9\u5f20\u56fe\u91cc\u6709\u6ca1\u6709\u4eba\u6ca1\u6234\u5e3d\u5b50\u300d&#xff0c;\u4e00\u65e6\u753b\u9762\u91cc\u6709\u4e94\u4e2a\u4eba\u3001\u4e09\u4e2a\u6234\u4e86\u3001\u4e24\u4e2a\u6ca1\u6234&#xff0c;\u5206\u7c7b\u5c31\u5f7b\u5e95\u5931\u6548\u3002\u68c0\u6d4b\u624d\u80fd\u7ed9\u51fa\u300c\u54ea\u4e00\u4e2a\u4eba\u6ca1\u6234\u3001\u5728\u753b\u9762\u54ea\u4e2a\u4f4d\u7f6e\u300d&#xff0c;\u8fd9\u4e5f\u662f\u540e\u7eed\u8981\u8f93\u51fa\u5750\u6807\u3001\u8981\u8054\u52a8\u62a5\u8b66\u3001\u8981\u7ed9\u5de1\u68c0\u7559\u8bc1\u636e\u7684\u524d\u63d0\u3002<\/p>\n<p>\u8fd9\u4e2a\u9879\u76ee\u628a\u5b83\u843d\u6210\u4e00\u5957\u684c\u9762\u5de5\u5177&#xff1a;<\/p>\n<ul>\n<li>\u8f93\u5165&#xff1a;\u5355\u5f20\u56fe\u7247\u3001\u56fe\u7247\u6587\u4ef6\u5939\u3001\u89c6\u9891\u6587\u4ef6\u3001USB \u6444\u50cf\u5934<\/li>\n<li>\u8f93\u51fa&#xff1a;\u5e26\u6846\u7684\u7ed3\u679c\u56fe\/\u7ed3\u679c\u89c6\u9891\u3001\u9010\u76ee\u6807\u7684\u7c7b\u522b\/\u7f6e\u4fe1\u5ea6\/\u5750\u6807\u8868\u683c<\/li>\n<li>\u4ea4\u4e92&#xff1a;\u4e0b\u62c9\u6846\u9009\u4e2d\u67d0\u4e2a\u76ee\u6807\u540e&#xff0c;\u53f3\u4fa7\u9762\u677f\u56de\u586b\u5b83\u7684\u5177\u4f53\u5750\u6807\u4e0e\u7f6e\u4fe1\u5ea6<\/li>\n<\/ul>\n<p>\u754c\u9762\u6807\u9898\u5c31\u662f\u300c\u57fa\u4e8eYolov8\u5b89\u5168\u5e3d\u68c0\u6d4b\u4e0e\u8bc6\u522b\u7cfb\u7edf\u300d&#xff0c;\u68c0\u6d4b\u7c7b\u522b\u53ea\u6709\u4e24\u7c7b&#xff1a;<\/p>\n<table>\n<tr>\u7c7b\u522b iddata.yaml\u754c\u9762\u663e\u793a<\/tr>\n<tbody>\n<tr>\n<td>0<\/td>\n<td>hat<\/td>\n<td>\u5b89\u5168\u5e3d<\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>person<\/td>\n<td>\u4eba<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4ece\u4e1a\u52a1\u89d2\u5ea6\u770b&#xff0c;\u8fd9\u4e24\u4e2a\u7c7b\u522b\u5176\u5b9e\u662f\u914d\u5957\u5173\u7cfb&#xff1a;\u53ea\u68c0\u6d4b\u300c\u4eba\u300d&#xff0c;\u4f60\u4e0d\u77e5\u9053\u4ed6\u6234\u6ca1\u6234&#xff1b;\u53ea\u68c0\u6d4b\u300c\u5b89\u5168\u5e3d\u300d&#xff0c;\u753b\u9762\u91cc\u6ca1\u4eba\u65f6\u4f60\u65e0\u6cd5\u5224\u65ad\u662f\u300c\u6ca1\u4eba\u300d\u8fd8\u662f\u300c\u6709\u4eba\u6ca1\u6234\u300d\u3002\u6240\u4ee5\u6b63\u786e\u7528\u6cd5\u662f\u628a person \u6846\u548c hat \u6846\u505a\u7a7a\u95f4\u6bd4\u5bf9\u2014\u2014\u5982\u679c\u67d0\u4e2a person \u6846\u7684\u5934\u90e8\u533a\u57df\u5185\u4e0d\u5b58\u5728 hat \u6846&#xff0c;\u5c31\u5224\u5b9a\u4e3a\u672a\u4f69\u6234\u3002\u8fd9\u4e2a\u6bd4\u5bf9\u903b\u8f91\u5de5\u7a0b\u91cc\u6ca1\u6709\u5b9e\u73b0&#xff08;\u5c5e\u4e8e\u529f\u80fd\u7f3a\u53e3&#xff09;&#xff0c;\u4f46\u5b83\u6070\u6070\u662f\u8fd9\u7c7b\u7cfb\u7edf\u6700\u6709\u4ef7\u503c\u7684\u5ef6\u4f38\u65b9\u5411&#xff0c;\u540e\u9762\u300c\u53ef\u4f18\u5316\u65b9\u5411\u300d\u91cc\u4f1a\u5c55\u5f00\u3002<\/p>\n<p>\u5751\u70b9\u63d0\u9192 1&#xff1a;Config.py \u91cc\u53c8\u628a 0 \u7c7b\u5199\u6210 helmet&#xff0c;\u548c data.yaml \u7684 hat \u4e0d\u4e00\u81f4\u3002\u754c\u9762\u663e\u793a\u7edf\u4e00\u7528 CH_names &#061; [&#039;\u5b89\u5168\u5e3d&#039;, &#039;\u4eba&#039;]&#xff0c;\u6240\u4ee5\u4e0d\u5f71\u54cd\u4f7f\u7528&#xff0c;\u4f46\u4f60\u91cd\u65b0\u8bad\u7ec3\u540e\u4e00\u5b9a\u8981\u628a\u4e09\u5904&#xff08;data.yaml \u7684 names\u3001Config.names\u3001Config.CH_names&#xff09;\u5bf9\u9f50&#xff0c;\u5426\u5219 yaml \u91cc\u6539\u7c7b\u540d\u3001\u754c\u9762\u8fd8\u5728\u6309\u65e7\u7d22\u5f15\u53d6\u4e2d\u6587\u540d&#xff0c;\u5c31\u4f1a\u51fa\u73b0\u300c\u68c0\u6d4b\u51fa person \u5374\u663e\u793a\u6210\u5b89\u5168\u5e3d\u300d\u7684\u7ecf\u5178\u9519\u4f4d\u3002<\/p>\n<hr \/>\n<h3 id=\"_2\">\u4e8c\u3001\u6574\u4f53\u6280\u672f\u65b9\u6848<\/h3>\n<p>\u6574\u4e2a\u5de5\u7a0b\u53ef\u4ee5\u5206\u6210\u4e09\u5c42&#xff0c;\u804c\u8d23\u975e\u5e38\u6e05\u6670&#xff1a;<\/p>\n<table>\n<tr>\u5c42\u6587\u4ef6\u804c\u8d23<\/tr>\n<tbody>\n<tr>\n<td>\u6a21\u578b\u5c42<\/td>\n<td>train.py\u3001yolov8n.pt\u3001models\/best.pt<\/td>\n<td>\u8bad\u7ec3\u4e0e\u6743\u91cd\u7ba1\u7406&#xff0c;\u63a8\u7406\u7edf\u4e00\u8d70 Ultralytics \u7684 YOLO.predict<\/td>\n<\/tr>\n<tr>\n<td>\u63a8\u7406\/\u5de5\u5177\u5c42<\/td>\n<td>MainProgram.py\u3001detect_tools.py<\/td>\n<td>\u56fe\u7247\/\u89c6\u9891\/\u6444\u50cf\u5934\u7edf\u4e00\u8c03\u5ea6&#xff0c;\u753b\u6846\u3001\u4e2d\u6587\u6e32\u67d3\u3001\u5750\u6807\u8f6c\u6362\u3001\u89c6\u9891\u5199\u51fa<\/td>\n<\/tr>\n<tr>\n<td>\u754c\u9762\u5c42<\/td>\n<td>UIProgram\/UiMain.py\u3001style.css\u3001QssLoader.py<\/td>\n<td>Qt Designer \u751f\u6210\u7684\u754c\u9762 &#043; QSS \u76ae\u80a4 &#043; \u4fe1\u53f7\u69fd\u7ed1\u5b9a<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u51e0\u4e2a\u5173\u952e\u8bbe\u8ba1\u9009\u62e9&#xff0c;\u90fd\u662f\u8e29\u8fc7\u5751\u4e4b\u540e\u624d\u4f1a\u8fd9\u4e48\u5199\u7684&#xff1a;<\/p>\n<li>\u6a21\u578b\u53ea\u52a0\u8f7d\u4e00\u6b21&#xff1a;initMain() \u91cc YOLO(Config.model_path, task&#061;&#039;detect&#039;) \u4e4b\u540e&#xff0c;\u7acb\u523b\u7528 np.zeros((48,48,3)) \u8dd1\u4e00\u6b21\u7a7a\u63a8\u7406\u505a\u9884\u70ed\u3002\u7b2c\u4e00\u6b21\u63a8\u7406\u8981\u5efa\u56fe\u3001\u52a0\u8f7d cuDNN kernel&#xff0c;\u754c\u9762\u4f1a\u300c\u5047\u6b7b\u300d\u4e24\u4e09\u79d2&#xff1b;\u628a\u8fd9\u4efd\u4ee3\u4ef7\u63d0\u524d\u5230\u542f\u52a8\u9636\u6bb5&#xff0c;\u7528\u6237\u70b9\u68c0\u6d4b\u65f6\u624d\u662f\u5373\u65f6\u54cd\u5e94\u3002\u8fd9\u4e2a\u6280\u5de7\u5728\u4efb\u4f55\u300c\u6a21\u578b &#043; GUI\u300d\u7ec4\u5408\u91cc\u90fd\u503c\u5f97\u6284\u3002<\/li>\n<li>\u8bbe\u5907\u81ea\u9002\u5e94&#xff1a;self.device &#061; 0 if torch.cuda.is_available() else &#039;cpu&#039;&#xff0c;\u6ca1\u6709 GPU \u4e5f\u80fd\u8dd1&#xff0c;\u53ea\u662f\u6162\u3002\u6ce8\u610f&#xff1a;\u8fd9\u884c\u8d4b\u503c\u5728\u5de5\u7a0b\u91cc\u53ea\u5199\u8fdb\u4e86\u5b9e\u4f8b\u5c5e\u6027&#xff0c;model.predict \u5e76\u6ca1\u6709\u663e\u5f0f\u4f20 device&#xff0c;\u6240\u4ee5\u5b9e\u9645\u8bbe\u5907\u7531 Ultralytics \u5185\u90e8\u81ea\u52a8\u5224\u65ad\u51b3\u5b9a\u2014\u2014\u60f3\u5f3a\u5236\u6307\u5b9a\u8bbe\u5907&#xff0c;\u5f97\u5728\u63a8\u7406\u65f6\u663e\u5f0f\u4f20 device&#061;self.device\u3002\u8fd9\u7b97\u4e00\u5904\u300c\u5199\u4e86\u4f46\u6ca1\u63a5\u4e0a\u300d\u7684\u534a\u6210\u54c1\u4ee3\u7801\u3002<\/li>\n<li>\u914d\u7f6e\u4e0e\u4ee3\u7801\u5206\u79bb&#xff1a;\u6a21\u578b\u8def\u5f84\u3001\u4fdd\u5b58\u76ee\u5f55\u3001\u4e2d\u82f1\u6587\u7c7b\u540d\u5168\u5728 Config.py&#xff0c;\u6362\u6a21\u578b\u4e0d\u7528\u6539\u4e3b\u7a0b\u5e8f\u3002<\/li>\n<li>\u4e2d\u6587\u7ed8\u5236&#xff1a;OpenCV \u7684 cv2.putText \u53ea\u652f\u6301 ASCII&#xff0c;\u753b\u4e2d\u6587\u4f1a\u53d8\u6210\u4e00\u6392\u95ee\u53f7\u3002\u5de5\u7a0b\u91cc\u7528 ImageFont.truetype(&#034;Font\/platech.ttf&#034;, 25, 0) \u914d\u5408 PIL \u6e32\u67d3\u4e2d\u6587\u6807\u7b7e&#xff0c;\u518d\u628a PIL \u56fe\u8f6c\u56de numpy \u6570\u7ec4&#xff0c;\u5b57\u4f53\u6587\u4ef6\u968f\u9879\u76ee\u9644\u5e26\u3002<\/li>\n<p>\u5148\u770b\u4e00\u5f20\u8fd9\u4e2a\u5de5\u7a0b\u7684\u771f\u5b9e\u8f93\u51fa&#xff0c;\u540e\u9762\u6240\u6709\u7684\u4ee3\u7801\u90fd\u662f\u4e3a\u4e86\u590d\u73b0\u8fd9\u5f20\u56fe&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1421\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261118184839-6afdf30716b16.jpg\" width=\"947\" \/><\/p>\n<p>\u56fe 9 \u5355\u56fe\u68c0\u6d4b\u6548\u679c 1<\/p>\n<p>\u4ee5\u4e0a\u4e3a\u5de5\u7a0b save_data \u76ee\u5f55\u4e2d\u4fdd\u5b58\u7684\u5b9e\u9645\u68c0\u6d4b\u7ed3\u679c&#xff08;\u7531 MainProgram.py \u7684\u56fe\u7247\u68c0\u6d4b\u6d41\u7a0b\u8f93\u51fa&#xff0c;\u5e26\u7c7b\u522b\u4e0e\u7f6e\u4fe1\u5ea6\u6807\u7b7e&#xff09;\u3002<\/p>\n<hr \/>\n<h3 id=\"yolov8\">\u4e09\u3001\u7b97\u6cd5\u539f\u7406&#xff1a;YOLOv8 \u662f\u600e\u4e48\u628a&#034;\u627e\u6846&#034;\u548c&#034;\u5206\u7c7b&#034;\u4e00\u6b21\u505a\u5b8c\u7684<\/h3>\n<p>\u5f88\u591a\u4eba\u4f1a\u7528 model.train()&#xff0c;\u4f46\u8bf4\u4e0d\u6e05 backbone \u91cc\u5230\u5e95\u53d1\u751f\u4e86\u4ec0\u4e48\u3002\u8fd9\u4e00\u8282\u628a\u4e0e\u672c\u9879\u76ee\u76f4\u63a5\u76f8\u5173\u7684\u90e8\u5206\u8bb2\u6e05\u695a&#xff0c;\u4e0d\u6d89\u53ca\u8bba\u6587\u91cc\u90a3\u4e9b\u4e0e\u672c\u4efb\u52a1\u65e0\u5173\u7684\u6d88\u878d\u7ec6\u8282\u3002<\/p>\n<h4 id=\"31-backbone-neck-head\">3.1 \u6574\u4f53\u7ed3\u6784&#xff1a;Backbone &#043; Neck &#043; Head<\/h4>\n<p>YOLOv8 \u662f\u5178\u578b\u7684\u5355\u9636\u6bb5&#xff08;one-stage&#xff09;\u3001Anchor-Free \u68c0\u6d4b\u5668&#xff0c;\u4e00\u6b21\u524d\u5411\u5c31\u540c\u65f6\u8f93\u51fa\u300c\u6846\u7684\u4f4d\u7f6e\u300d\u548c\u300c\u6846\u7684\u7c7b\u522b\u300d&#xff0c;\u4e0d\u50cf Faster R-CNN \u90a3\u6837\u5148\u51fa\u5019\u9009\u533a\u57df\u518d\u9010\u4e2a\u5206\u7c7b&#xff0c;\u6240\u4ee5\u5ef6\u8fdf\u4f4e\u3001\u9002\u5408\u89c6\u9891\u4e0e\u6444\u50cf\u5934\u8fd9\u79cd\u8fde\u7eed\u63a8\u7406\u573a\u666f\u3002<\/p>\n<ul>\n<li>Backbone&#xff08;\u4e3b\u5e72&#xff09;&#xff1a;\u7531\u82e5\u5e72 Conv \u4e0e C2f \u6a21\u5757\u5806\u53e0&#xff0c;\u518d\u52a0\u4e00\u4e2a SPPF\u3002C2f \u662f YOLOv8 \u76f8\u5bf9 YOLOv5 \u7684\u4e3b\u8981\u6539\u52a8\u4e4b\u4e00&#xff1a;\u5b83\u5728\u8de8\u5c42\u8fde\u63a5\u4e0a\u505a\u4e86\u66f4\u5145\u5206\u7684\u5206\u652f\u4e0e\u62fc\u63a5&#xff0c;\u8ba9\u68af\u5ea6\u6d41\u52a8\u66f4\u987a\u3001\u7279\u5f81\u590d\u7528\u66f4\u5145\u5206&#xff1b;SPPF \u7528\u4e32\u8054\u7684\u591a\u4e2a\u6700\u5927\u6c60\u5316\u7b49\u6548\u6269\u5927\u611f\u53d7\u91ce&#xff0c;\u4ee3\u4ef7\u8fdc\u4f4e\u4e8e\u5927\u6838\u5377\u79ef\u3002\u8fd9\u4e24\u4e2a\u6a21\u5757\u5171\u540c\u51b3\u5b9a\u4e86\u300c\u7279\u5f81\u63d0\u5f97\u51c6\u4e0d\u51c6\u300d\u3002<\/li>\n<li>Neck&#xff08;\u9888\u90e8&#xff09;&#xff1a;PAN-FPN \u7ed3\u6784&#xff0c;\u81ea\u9876\u5411\u4e0b\u4f20\u8bed\u4e49\u3001\u81ea\u5e95\u5411\u4e0a\u4f20\u5b9a\u4f4d\u7ec6\u8282\u3002\u5bf9\u5b89\u5168\u5e3d\u8fd9\u79cd\u300c\u5c0f\u76ee\u6807 &#043; \u5bc6\u96c6\u906e\u6321\u300d\u7684\u573a\u666f&#xff0c;Neck \u91cc\u7684\u9ad8\u5206\u8fa8\u7387\u652f\u8def\u5c24\u5176\u5173\u952e\u2014\u2014\u5b89\u5168\u5e3d\u5728\u8fdc\u666f\u56fe\u91cc\u53ef\u80fd\u53ea\u6709 20\u00d715 \u50cf\u7d20&#xff0c;\u5168\u9760 P3 \u8fd9\u7c7b\u6d45\u5c42\u9ad8\u5206\u8fa8\u7387\u7279\u5f81\u56fe\u624d\u6293\u5f97\u4f4f\u3002<\/li>\n<li>Head&#xff08;\u5934\u90e8&#xff09;&#xff1a;\u89e3\u8026\u5934&#xff08;decoupled head&#xff09;&#xff0c;\u5206\u7c7b\u5206\u652f\u548c\u56de\u5f52\u5206\u652f\u5206\u6210\u4e24\u6761\u72ec\u7acb\u7684\u5c0f\u5377\u79ef\u901a\u8def&#xff0c;\u5404\u81ea\u5b66\u5404\u81ea\u7684&#xff0c;\u907f\u514d\u300c\u5206\u7c7b\u4e0e\u5b9a\u4f4d\u76ee\u6807\u4e0d\u4e00\u81f4\u300d\u7684\u76f8\u4e92\u5e72\u6270\u3002\u8f93\u51fa\u662f anchor-free \u7684&#xff0c;\u76f4\u63a5\u56de\u5f52\u5230\u7f51\u683c\u4e2d\u5fc3\u5230\u6846\u8fb9\u7684\u8ddd\u79bb&#xff0c;\u518d\u7528 DFL&#xff08;Distribution Focal Loss&#xff09; \u628a\u8ddd\u79bb\u5efa\u6a21\u6210\u4e00\u4e2a\u79bb\u6563\u5206\u5e03\u53d6\u671f\u671b&#xff0c;\u8fd9\u6837\u8fb9\u754c\u56de\u5f52\u66f4\u5e73\u6ed1&#xff0c;\u5bf9\u5c0f\u76ee\u6807\u7684\u4e9a\u50cf\u7d20\u7ea7\u504f\u5dee\u66f4\u53cb\u597d\u3002<\/li>\n<\/ul>\n<h4 id=\"32\">3.2 \u635f\u5931\u51fd\u6570&#xff1a;\u4e09\u4e2a\u90e8\u5206\u5404\u7ba1\u4e00\u4ef6\u4e8b<\/h4>\n<p>\u8bad\u7ec3\u65f6\u603b\u635f\u5931\u7531\u4e09\u9879\u52a0\u6743\u6784\u6210&#xff0c;results.csv \u91cc\u4e5f\u6b63\u597d\u5bf9\u5e94\u4e09\u5217&#xff0c;\u8bfb\u65e5\u5fd7\u65f6\u5fc5\u987b\u5206\u6e05\u695a&#xff1a;<\/p>\n<table>\n<tr>\u635f\u5931\u9879\u65e5\u5fd7\u5217\u540d\u7ba1\u4ec0\u4e48\u5f02\u5e38\u8868\u73b0<\/tr>\n<tbody>\n<tr>\n<td>\u6846\u56de\u5f52\u635f\u5931<\/td>\n<td>train\/box_loss\u3001val\/box_loss<\/td>\n<td>\u9884\u6d4b\u6846\u4e0e\u771f\u503c\u6846\u7684\u4f4d\u7f6e\u504f\u5dee&#xff08;CIoU \u4e00\u7c7b&#xff09;<\/td>\n<td>\u4e00\u76f4\u9ad8 \u2192 \u5b9a\u4f4d\u5b66\u4e0d\u52a8&#xff0c;\u68c0\u67e5\u6807\u6ce8\u6846\u662f\u5426\u9519\u4f4d\/\u5f52\u4e00\u5316\u9519\u8bef<\/td>\n<\/tr>\n<tr>\n<td>\u5206\u7c7b\u635f\u5931<\/td>\n<td>train\/cls_loss\u3001val\/cls_loss<\/td>\n<td>\u7c7b\u522b\u5224\u5bf9\u6ca1\u6709&#xff08;BCE&#xff09;<\/td>\n<td>\u9ad8\u4e14\u4e0d\u964d \u2192 \u7c7b\u540d\u6620\u5c04\u9519\u3001\u7c7b\u522b\u4e0d\u5e73\u8861<\/td>\n<\/tr>\n<tr>\n<td>\u5206\u5e03\u7126\u70b9\u635f\u5931<\/td>\n<td>train\/dfl_loss\u3001val\/dfl_loss<\/td>\n<td>\u8fb9\u754c\u8ddd\u79bb\u5206\u5e03\u7684\u7cbe\u7ec6\u7a0b\u5ea6<\/td>\n<td>\u9ad8 \u2192 \u5c0f\u76ee\u6807\u591a\u3001\u8fb9\u754c\u6a21\u7cca<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u7406\u89e3\u8fd9\u4e09\u9879\u7684\u610f\u4e49\u5728\u4e8e&#xff1a;\u5f53\u4f60\u7684 mAP \u5361\u4f4f\u4e0d\u52a8\u65f6&#xff0c;\u5148\u770b\u662f\u54ea\u4e00\u9879\u5728\u62d6\u540e\u817f&#xff0c;\u800c\u4e0d\u662f\u76f2\u76ee\u52a0\u8f6e\u6570\u3002\u672c\u9879\u76ee\u7684\u65e5\u5fd7\u91cc train\/box_loss \u4ece 1.5328 \u4e00\u8def\u964d\u5230 1.255&#xff0c;\u800c val\/box_loss \u5728 1.38&#xff5e;1.47 \u4e4b\u95f4\u53cd\u590d\u6a2a\u8df3&#xff0c;\u8fd9\u4e2a\u300c\u8bad\u7ec3\u964d\u3001\u9a8c\u8bc1\u4e0d\u964d\u300d\u7684\u526a\u5200\u5dee\u5c31\u662f\u5178\u578b\u7684\u8f7b\u5fae\u8fc7\u62df\u5408\u4fe1\u53f7&#xff0c;\u540e\u9762\u7b2c\u516d\u8282\u4f1a\u7528\u771f\u5b9e\u6570\u5b57\u5c55\u5f00\u3002<\/p>\n<h4 id=\"33-nms\">3.3 \u63a8\u7406\u540e\u5904\u7406&#xff1a;\u7f6e\u4fe1\u5ea6\u9608\u503c &#043; NMS<\/h4>\n<p>\u6a21\u578b\u539f\u59cb\u8f93\u51fa\u662f\u6210\u5343\u4e0a\u4e07\u4e2a\u5019\u9009\u6846&#xff0c;\u771f\u6b63\u53d8\u6210\u6211\u4eec\u80fd\u770b\u5230\u7684\u51e0\u4e2a\u6846&#xff0c;\u9760\u4e24\u6b65&#xff1a;<\/p>\n<li>\u7f6e\u4fe1\u5ea6\u8fc7\u6ee4&#xff1a;\u4f4e\u4e8e\u9608\u503c&#xff08;Ultralytics \u9ed8\u8ba4 conf&#061;0.25&#xff09;\u7684\u6846\u76f4\u63a5\u4e22\u5f03\u3002\u5de5\u7a0b\u91cc\u6ca1\u6709\u628a conf \u66b4\u9732\u5230\u754c\u9762\u4e0a&#xff0c;\u7528\u7684\u662f\u5e93\u9ed8\u8ba4\u503c\u2014\u2014\u8fd9\u4e5f\u662f\u4e2a\u53ef\u4f18\u5316\u70b9&#xff0c;\u5de5\u4e1a\u573a\u666f\u901a\u5e38\u4f1a\u628a conf \u63d0\u5230 0.4&#xff5e;0.5 \u4ee5\u51cf\u5c11\u8bef\u62a5\u3002<\/li>\n<li>NMS&#xff08;\u975e\u6781\u5927\u503c\u6291\u5236&#xff09;&#xff1a;\u540c\u4e00\u76ee\u6807\u88ab\u91cd\u590d\u9884\u6d4b\u51fa\u591a\u4e2a\u6846\u65f6&#xff0c;\u6309\u7f6e\u4fe1\u5ea6\u6392\u5e8f\u540e\u6291\u5236\u91cd\u53e0\u5ea6&#xff08;IoU&#xff09;\u8d85\u8fc7\u9608\u503c\u7684\u4f4e\u5206\u6846\u3002\u4eba\u7fa4\u5bc6\u96c6\u573a\u666f\u91cc NMS \u9608\u503c\u8c03\u592a\u9ad8\u4f1a\u300c\u4e00\u4e2a\u6846\u541e\u6389\u4e24\u4e2a\u4eba\u300d&#xff0c;\u8c03\u592a\u4f4e\u4f1a\u300c\u540c\u4e00\u4e2a\u4eba\u51fa\u4e09\u4e2a\u6846\u300d&#xff0c;\u8fd9\u662f\u8c03\u53c2\u65f6\u6700\u9700\u8981\u8089\u773c\u9a8c\u8bc1\u7684\u4e00\u6b65\u3002<\/li>\n<p>\u53e6\u5916&#xff0c;\u8f93\u5165\u56fe\u4f1a\u5148\u7ecf\u8fc7 letterbox \u7f29\u653e\u5230 imgsz&#061;640&#xff08;\u4fdd\u6301\u957f\u5bbd\u6bd4\u3001\u7070\u8fb9\u586b\u5145&#xff09;&#xff0c;\u63a8\u7406\u5b8c\u518d\u628a\u6846\u5750\u6807\u53cd\u5411\u6620\u5c04\u56de\u539f\u56fe\u5c3a\u5bf8\u3002\u8fd9\u4e00\u5c42\u5728\u5de5\u7a0b\u91cc\u7531 results.plot() \u81ea\u52a8\u5b8c\u6210&#xff0c;\u4e0d\u9700\u8981\u624b\u5199&#xff0c;\u4f46\u4f60\u8981\u77e5\u9053\u6846\u5750\u6807\u4e3a\u4ec0\u4e48\u548c\u539f\u56fe\u5c3a\u5bf8\u5bf9\u5f97\u4e0a\u3002<\/p>\n<hr \/>\n<h3 id=\"_3\">\u56db\u3001\u6570\u636e\u96c6\u6784\u5efa\u4e0e\u6807\u6ce8\u7ec6\u8282<\/h3>\n<p>\u6570\u636e\u96c6\u653e\u5728 datasets\/helmetData&#xff0c;\u6807\u51c6 YOLO \u7ed3\u6784&#xff08;\u56fe\u7247\u4e0e\u540c\u540d txt \u6807\u7b7e\u5206\u76ee\u5f55&#xff09;&#xff1a;<\/p>\n<p>datasets\/helmetData\/<br \/>\n\u251c\u2500\u2500 data.yaml<br \/>\n\u251c\u2500\u2500 train\/{images, labels}<br \/>\n\u251c\u2500\u2500 valid\/{images, labels}<br \/>\n\u2514\u2500\u2500 test\/{images, labels}<\/p>\n<p>\u5b9e\u9645\u89c4\u6a21&#xff08;\u9010\u6587\u4ef6\u7edf\u8ba1&#xff09;&#xff1a;<\/p>\n<table>\n<tr>\u5212\u5206\u56fe\u7247\u6570\u6807\u7b7e\u6570<\/tr>\n<tbody>\n<tr>\n<td>train<\/td>\n<td>6026<\/td>\n<td>6017<\/td>\n<\/tr>\n<tr>\n<td>valid<\/td>\n<td>763<\/td>\n<td>762<\/td>\n<\/tr>\n<tr>\n<td>test<\/td>\n<td>792<\/td>\n<td>792<\/td>\n<\/tr>\n<tr>\n<td>\u5408\u8ba1<\/td>\n<td>7581<\/td>\n<td>7571<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>train\/valid \u91cc\u6709\u5c11\u91cf\u300c\u6709\u56fe\u65e0\u6807\u7b7e\u300d\u7684\u6837\u672c&#xff08;train \u5dee 9\u3001valid \u5dee 1&#xff09;&#xff0c;\u8fd9\u901a\u5e38\u662f\u8d1f\u6837\u672c&#xff08;\u753b\u9762\u91cc\u65e2\u6ca1\u5e3d\u5b50\u4e5f\u6ca1\u4eba&#xff09;&#xff0c;YOLO \u5141\u8bb8\u8fd9\u79cd\u7a7a\u6807\u7b7e\u6587\u4ef6\u7f3a\u5931\u6216\u4e3a\u7a7a&#xff0c;\u5c5e\u4e8e\u6b63\u5e38\u73b0\u8c61&#xff0c;\u4e0d\u8981\u624b\u8d31\u53bb\u8865\u3002<\/p>\n<p>data.yaml \u539f\u6587&#xff1a;<\/p>\n<p>train: F:\\\\Mlwork\\\\YOLOv8hat-helmet\\\\datasets\\\\helmetData\\\\train<br \/>\nval:   F:\\\\Mlwork\\\\YOLOv8hat-helmet\\\\datasets\\\\helmetData\\\\valid<br \/>\ntest:  F:\\\\Mlwork\\\\YOLOv8hat-helmet\\\\datasets\\\\helmetData\\\\test<br \/>\nnc: 2<br \/>\nnames: [&#039;hat&#039;, &#039;person&#039;]<\/p>\n<p>\u4e24\u4e2a\u5fc5\u987b\u6ce8\u610f\u7684\u70b9&#xff1a;<\/p>\n<ul>\n<li>\u7edd\u5bf9\u8def\u5f84&#xff1a;\u8fd9\u662f\u539f\u4f5c\u8005\u672c\u673a\u8def\u5f84&#xff0c;\u4f60\u642c\u5230\u81ea\u5df1\u673a\u5668\u4e0a\u5fc5\u987b\u6539&#xff0c;\u5426\u5219\u4e00\u542f\u52a8\u8bad\u7ec3\u5c31\u62a5 Dataset not found\u3002\u5efa\u8bae\u6539\u6210\u76f8\u5bf9 path &#043; train\/val \u7ec4\u5408&#xff0c;\u53ef\u79fb\u690d\u6027\u66f4\u597d\u3002<\/li>\n<li>\u6587\u6863\u6ede\u540e&#xff1a;\u9879\u76ee\u91cc\u7684 \u7a0b\u5e8f\u8fd0\u884c\u8bf4\u660e\u6587\u6863.txt \u5728\u300c\u6a21\u578b\u8bad\u7ec3\u300d\u7ae0\u8282\u8fd8\u5199\u7740\u53e6\u4e00\u4e2a\u9879\u76ee FireSmokeData \u7684\u793a\u4f8b\u8def\u5f84&#xff0c;\u90a3\u662f\u4f5c\u8005\u590d\u5236\u6a21\u677f\u65f6\u6f0f\u6539\u7684\u3002\u4ee5 data.yaml \u4e3a\u51c6\u3002<\/li>\n<\/ul>\n<h4 id=\"41\">4.1 \u6807\u6ce8\u683c\u5f0f\u4e0e\u5750\u6807\u6362\u7b97<\/h4>\n<p>YOLO \u7684\u6807\u7b7e\u662f\u300c\u4e00\u884c\u4e00\u4e2a\u76ee\u6807\u300d&#xff0c;\u683c\u5f0f\u4e3a class cx cy w h&#xff0c;\u540e\u56db\u4e2a\u90fd\u662f\u76f8\u5bf9\u56fe\u50cf\u5bbd\u9ad8\u7684\u5f52\u4e00\u5316\u503c&#xff08;0~1&#xff09;\u3002\u8fd9\u79cd\u5199\u6cd5\u7684\u597d\u5904\u662f\u6807\u7b7e\u4e0e\u5206\u8fa8\u7387\u65e0\u5173&#xff0c;\u56fe\u7247\u968f\u4fbf\u7f29\u653e\u90fd\u4e0d\u7528\u91cd\u6807&#xff1b;\u574f\u5904\u662f\u4eba\u773c\u4e0d\u53ef\u8bfb&#xff0c;\u753b\u56fe\u9a8c\u8bc1\u65f6\u5fc5\u987b\u6362\u7b97\u3002<\/p>\n<p>\u5de5\u7a0b\u5728 detect_tools.py \u91cc\u5c31\u5185\u7f6e\u4e86\u8fd9\u4e00\u5bf9\u4e92\u9006\u51fd\u6570&#xff0c;\u662f\u6392\u67e5\u6807\u6ce8\u95ee\u9898\u6700\u5b9e\u7528\u7684\u5de5\u5177&#xff1a;<\/p>\n<p>def yolo_to_location(w, h, yolo_data):<br \/>\n    # yolo\u6587\u4ef6\u8f6c\u4e24\u70b9\u5750\u6807&#xff0c;\u6ce8\u610f\u753b\u56fe\u5750\u6807\u8981\u8f6c\u6362\u6210int\u683c\u5f0f<br \/>\n    x_, y_, w_, h_ &#061; yolo_data<br \/>\n    x1 &#061; int(w * x_ &#8211; 0.5 * w * w_)<br \/>\n    x2 &#061; int(w * x_ &#043; 0.5 * w * w_)<br \/>\n    y1 &#061; int(h * y_ &#8211; 0.5 * h * h_)<br \/>\n    y2 &#061; int(h * y_ &#043; 0.5 * h * h_)<br \/>\n    return [x1, y1, x2, y2]<\/p>\n<p>def location_to_yolo(w, h, locations):<br \/>\n    x1, y1, x2, y2 &#061; locations<br \/>\n    x_ &#061; float(&#039;%.5f&#039; % ((x1 &#043; x2) \/ 2 \/ w))<br \/>\n    y_ &#061; float(&#039;%.5f&#039; % ((y1 &#043; y2) \/ 2 \/ h))<br \/>\n    w_ &#061; float(&#039;%.5f&#039; % ((x2 &#8211; x1) \/ w))<br \/>\n    h_ &#061; float(&#039;%.5f&#039; % ((y2 &#8211; y1) \/ h))<br \/>\n    return [x_, y_, w_, h_]<\/p>\n<p>\u914d\u5957\u7684 draw_yolo_data(img_path, yolo_file_path) \u4f1a\u628a\u67d0\u5f20\u56fe\u7684 txt \u6807\u6ce8\u753b\u6210\u7ea2\u6846\u5e76 imshow&#xff0c;\u6807\u6ce8\u9519\u4f4d\u3001\u6f0f\u6807\u3001\u7c7b\u6807\u53cd\u4e86\u8fd9\u4e09\u7c7b\u95ee\u9898&#xff0c;\u7528\u5b83\u8dd1\u4e00\u904d 20 \u5f20\u5c31\u80fd\u53d1\u73b0\u3002<\/p>\n<p>\u5751\u70b9\u63d0\u9192 2&#xff1a;location_to_yolo \u4fdd\u7559 5 \u4f4d\u5c0f\u6570\u662f\u591f\u7528\u7684&#xff08;1\/100000 \u7684\u56fe\u50cf\u5bbd\u5ea6&#xff0c;\u8fdc\u5c0f\u4e8e\u89c6\u89c9\u53ef\u8fa8\u5dee\u5f02&#xff09;&#xff0c;\u4f46\u5343\u4e07\u522b\u81ea\u5df1\u6539\u6210 2 \u4f4d\u2014\u2014\u5f52\u4e00\u5316\u503c 0.37 \u4e0e 0.375 \u5dee\u7684\u662f\u6574\u5f20\u56fe 0.5% \u7684\u5bbd\u5ea6&#xff0c;\u5bc6\u96c6\u5c0f\u76ee\u6807\u573a\u666f\u4f1a\u76f4\u63a5\u628a\u6846\u63a8\u5230\u9694\u58c1\u76ee\u6807\u8eab\u4e0a\u3002<\/p>\n<h4 id=\"42\">4.2 \u6570\u636e\u5206\u5e03\u4e0e\u589e\u5f3a\u7b56\u7565<\/h4>\n<p>\u8bad\u7ec3\u524d\u5fc5\u770b\u7684\u4e00\u5f20\u56fe\u662f Ultralytics \u81ea\u52a8\u751f\u6210\u7684\u6570\u636e\u96c6\u7edf\u8ba1\u56fe&#xff0c;\u5b83\u628a\u6807\u6ce8\u6846\u7684\u5c3a\u5bf8\u5206\u5e03\u3001\u4e2d\u5fc3\u70b9\u5206\u5e03\u3001\u957f\u5bbd\u6bd4\u5206\u5e03\u753b\u5728\u4e00\u8d77&#xff0c;\u80fd\u4e00\u6b21\u6027\u66b4\u9732\u300c\u5c0f\u76ee\u6807\u5360\u6bd4\u591a\u5c11\u300d\u300c\u6846\u90fd\u6324\u5728\u753b\u9762\u4e2d\u95f4\u300d\u8fd9\u7c7b\u95ee\u9898&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1400\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261118184839-6afdf30790877.jpg\" width=\"1400\" \/><\/p>\n<p>\u56fe 2 \u6570\u636e\u96c6\u6807\u6ce8\u5206\u5e03\u7edf\u8ba1<\/p>\n<p>\u4ece\u8fd9\u5f20\u56fe\u53ef\u4ee5\u76f4\u63a5\u8bfb\u51fa\u4e24\u4ef6\u4e8b&#xff1a;\u4e00\u662f\u6807\u6ce8\u6846\u5c3a\u5bf8\u5206\u5e03\u8f83\u5bbd&#xff08;\u8bf4\u660e\u6570\u636e\u91cc\u65e2\u6709\u8fd1\u666f\u5927\u76ee\u6807\u4e5f\u6709\u8fdc\u666f\u5c0f\u76ee\u6807&#xff09;&#xff0c;\u4e8c\u662f\u4e2d\u5fc3\u70b9\u5206\u5e03\u96c6\u4e2d\u5728\u753b\u9762\u4e2d\u90e8&#xff08;\u7b26\u5408\u5de5\u5730\u4e0a\u300c\u4eba\u7ad9\u5728\u753b\u9762\u4e2d\u300d\u7684\u62cd\u6444\u4e60\u60ef&#xff09;\u3002\u8fd9\u7c7b\u5206\u5e03\u5982\u679c\u4e25\u91cd\u504f\u79bb\u8bad\u7ec3\u573a\u666f&#xff0c;\u5c31\u8be5\u8865\u6570\u636e\u800c\u4e0d\u662f\u8c03\u8d85\u53c2\u3002<\/p>\n<p>YOLOv8 \u9ed8\u8ba4\u5f00\u542f\u7684\u8bad\u7ec3\u589e\u5f3a\u91cc&#xff0c;\u5bf9\u672c\u9879\u76ee\u5f71\u54cd\u6700\u5927\u7684\u662f Mosaic&#xff1a;\u628a 4 \u5f20\u56fe\u968f\u673a\u7f29\u653e\u3001\u88c1\u526a\u3001\u62fc\u63a5\u6210\u4e00\u5f20&#xff0c;\u76f8\u5f53\u4e8e\u5728\u4e0d\u589e\u52a0\u663e\u5b58\u7684\u524d\u63d0\u4e0b\u628a batch \u5185\u6837\u672c\u6570\u7ffb\u4e86 4 \u500d&#xff0c;\u8fd8\u987a\u5e26\u9020\u51fa\u5927\u91cf\u300c\u5c0f\u76ee\u6807 &#043; \u65b0\u80cc\u666f\u7ec4\u5408\u300d\u3002\u5de5\u7a0b args.yaml \u91cc mosaic&#061;1.0&#xff08;\u59cb\u7ec8\u5f00\u542f&#xff09;\u3001close_mosaic&#061;10&#xff08;\u6700\u540e 10 \u8f6e\u5173\u95ed&#xff09;\u3002\u6700\u540e 10 \u8f6e\u5173\u6389 Mosaic \u662f\u5fc5\u8981\u7684\u2014\u2014Mosaic \u9020\u51fa\u6765\u7684\u62fc\u63a5\u56fe\u4e0e\u771f\u5b9e\u573a\u666f\u5206\u5e03\u4e0d\u4e00\u81f4&#xff0c;\u5173\u6389\u5b83\u8ba9\u6a21\u578b\u5728\u771f\u5b9e\u5206\u5e03\u4e0a\u6536\u5c3e&#xff0c;\u6307\u6807\u901a\u5e38\u4f1a\u6709\u4e00\u6b21\u660e\u663e\u62ac\u5347\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1400\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261118184840-6afdf3086fc7c.jpg\" width=\"1400\" \/><\/p>\n<p>\u56fe 3 Mosaic \u6570\u636e\u589e\u5f3a\u540e\u7684\u8bad\u7ec3\u6279\u6b21\u6837\u672c<\/p>\n<p>\u4e0a\u56fe\u662f\u8bad\u7ec3\u6279\u6b21\u7b2c 0 \u6279\u7684\u771f\u5b9e\u6837\u672c&#xff0c;\u53ef\u4ee5\u770b\u5230\u56db\u56fe\u62fc\u63a5\u7684\u8fb9\u754c\u3001\u7070\u8fb9\u586b\u5145&#xff0c;\u4ee5\u53ca\u90e8\u5206\u76ee\u6807\u88ab\u88c1\u6389\u53ea\u5269\u534a\u4e2a\u6846\u2014\u2014\u8fd9\u4e9b\u90fd\u662f Mosaic \u7684\u6b63\u5e38\u4ea7\u7269&#xff0c;\u4e0d\u662f\u6807\u6ce8\u9519\u8bef\u3002<\/p>\n<hr \/>\n<h3 id=\"_4\">\u4e94\u3001\u8bad\u7ec3\u8d85\u53c2\u4e0e\u8bad\u7ec3\u73af\u5883<\/h3>\n<p>\u8bad\u7ec3\u811a\u672c\u975e\u5e38\u77ed&#xff0c;\u4f46\u6bcf\u4e00\u884c\u53c2\u6570\u90fd\u503c\u5f97\u9010\u9879\u8bf4&#xff1a;<\/p>\n<p>#coding:utf-8<br \/>\nfrom ultralytics import YOLO<\/p>\n<p>model &#061; YOLO(&#034;yolov8n.pt&#034;)   # \u52a0\u8f7d\u9884\u8bad\u7ec3\u6a21\u578b<\/p>\n<p>if __name__ &#061;&#061; &#039;__main__&#039;:<br \/>\n    results &#061; model.train(data&#061;&#039;datasets\/helmetData\/data.yaml&#039;,<br \/>\n                          epochs&#061;150, batch&#061;4, patience&#061;300)<br \/>\n    # \u5c06\u6a21\u578b\u8f6c\u4e3aonnx\u683c\u5f0f<br \/>\n    # success &#061; model.export(format&#061;&#039;onnx&#039;)<\/p>\n<ul>\n<li>yolov8n.pt&#xff1a;n \u662f\u6700\u5c0f\u7684 YOLOv8&#xff0c;\u53c2\u6570\u91cf\u5c0f\u3001\u63a8\u7406\u5feb&#xff0c;\u9002\u5408\u684c\u9762\u7aef &#043; \u5b9e\u65f6\u89c6\u9891\u8fd9\u79cd\u5bf9\u5ef6\u8fdf\u654f\u611f\u7684\u573a\u666f\u3002\u5de5\u7a0b\u5185\u6ca1\u6709\u8bb0\u5f55\u5177\u4f53\u53c2\u6570\u91cf\u4e0e FLOPs&#xff08;\u5f85\u8865\u5145&#xff09;\u3002<\/li>\n<li>epochs&#061;150\u3001batch&#061;4&#xff1a;batch \u53ea\u6709 4&#xff0c;\u8bf4\u660e\u8bad\u7ec3\u673a\u5668\u663e\u5b58\u5f88\u7d27\u5f20&#xff08;4GB \u7ea7\u522b\u7684\u5361&#xff09;\u3002\u663e\u5b58\u591f\u7684\u8bdd\u5efa\u8bae 16~32&#xff0c;\u8bad\u7ec3\u66f4\u7a33\u3002<\/li>\n<li>patience&#061;300&#xff1a;\u65e9\u505c\u8010\u5fc3\u503c\u8bbe\u5f97\u6bd4\u603b\u8f6e\u6570\u8fd8\u5927&#xff0c;\u7b49\u4e8e\u65e9\u505c\u5b9e\u9645\u6c38\u8fdc\u4e0d\u4f1a\u89e6\u53d1&#xff0c;\u4e00\u5b9a\u4f1a\u8dd1\u6ee1 150 \u8f6e\u3002\u5982\u679c\u4f60\u5e0c\u671b\u65e9\u505c\u751f\u6548&#xff0c;patience \u8981\u660e\u663e\u5c0f\u4e8e epochs\u3002<\/li>\n<li>if __name__ &#061;&#061; &#039;__main__&#039;:&#xff1a;Windows \u4e0a DataLoader \u591a\u8fdb\u7a0b\u5fc5\u987b\u52a0\u8fd9\u4e00\u53e5&#xff0c;\u5426\u5219\u5bb9\u6613\u62a5 freeze_support \u76f8\u5173\u9519\u8bef\u3002<\/li>\n<\/ul>\n<p>\u66f4\u5b8c\u6574\u7684\u8d85\u53c2\u4e0d\u5728 train.py \u91cc&#xff0c;\u800c\u5728\u8bad\u7ec3\u8f93\u51fa\u76ee\u5f55\u81ea\u52a8\u7559\u5b58\u7684 args.yaml\u3002\u5de5\u7a0b\u91cc\u4fdd\u7559\u4e86\u4e09\u8f6e\u8bad\u7ec3\u7684\u75d5\u8ff9&#xff0c;results.csv \u5b9e\u9645\u5b58\u5728\u4e8e train2\u3001train4\u3001train5\u3002\u628a\u4e24\u4efd args.yaml \u644a\u5f00\u5bf9\u6bd4&#xff0c;\u80fd\u770b\u51fa\u4f5c\u8005\u4e24\u6b21\u8bad\u7ec3\u7684\u601d\u8def\u53d8\u5316&#xff1a;<\/p>\n<table>\n<tr>\u8d85\u53c2train2train4\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>model<\/td>\n<td>yolov8n.pt<\/td>\n<td>yolov8n.pt<\/td>\n<td>n \u5c3a\u5ea6\u4e0d\u53d8<\/td>\n<\/tr>\n<tr>\n<td>data<\/td>\n<td>datasets\/helmetData\/data.yaml<\/td>\n<td>\u540c\u5de6<\/td>\n<td>\u540c\u4e00\u4efd\u6570\u636e<\/td>\n<\/tr>\n<tr>\n<td>epochs<\/td>\n<td>200<\/td>\n<td>150<\/td>\n<td>\u628a\u8f6e\u6570\u780d\u4e0b\u6765\u4e86<\/td>\n<\/tr>\n<tr>\n<td>batch<\/td>\n<td>32<\/td>\n<td>4<\/td>\n<td>\u663e\u5b58\u53d7\u9650\u540e\u7684\u59a5\u534f<\/td>\n<\/tr>\n<tr>\n<td>patience<\/td>\n<td>50<\/td>\n<td>300<\/td>\n<td>train2 \u662f\u771f\u7684\u4f1a\u65e9\u505c&#xff0c;train4 \u7b49\u4e8e\u5173\u6389\u65e9\u505c<\/td>\n<\/tr>\n<tr>\n<td>workers<\/td>\n<td>32<\/td>\n<td>8<\/td>\n<td>\u8fdb\u7a0b\u6570\u540c\u6b65\u4e0b\u8c03<\/td>\n<\/tr>\n<tr>\n<td>imgsz<\/td>\n<td>640<\/td>\n<td>640<\/td>\n<td>\u9ed8\u8ba4\u5206\u8fa8\u7387<\/td>\n<\/tr>\n<tr>\n<td>optimizer<\/td>\n<td>auto<\/td>\n<td>auto<\/td>\n<td>\u7531\u6846\u67b6\u81ea\u52a8\u9009&#xff08;SGD\/AdamW \u62e9\u4e00\u5e76\u8c03 lr&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>lr0<\/td>\n<td>0.01<\/td>\n<td>0.01<\/td>\n<td>\u521d\u59cb\u5b66\u4e60\u7387<\/td>\n<\/tr>\n<tr>\n<td>warmup_epochs<\/td>\n<td>3.0<\/td>\n<td>3.0<\/td>\n<td>\u524d\u4e09\u8f6e\u9884\u70ed&#xff0c;\u9632\u65e9\u671f\u68af\u5ea6\u7206\u70b8<\/td>\n<\/tr>\n<tr>\n<td>close_mosaic<\/td>\n<td>10<\/td>\n<td>10<\/td>\n<td>\u672b 10 \u8f6e\u5173 Mosaic<\/td>\n<\/tr>\n<tr>\n<td>mosaic \/ fliplr<\/td>\n<td>1.0 \/ 0.5<\/td>\n<td>1.0 \/ 0.5<\/td>\n<td>\u62fc\u63a5 &#043; \u6c34\u5e73\u7ffb\u8f6c<\/td>\n<\/tr>\n<tr>\n<td>degrees \/ translate \/ scale<\/td>\n<td>0.0 \/ 0.1 \/ 0.5<\/td>\n<td>0.0 \/ 0.1 \/ 0.5<\/td>\n<td>\u4e0d\u65cb\u8f6c&#xff0c;\u5e73\u79fb 10%&#xff0c;\u7f29\u653e 50%<\/td>\n<\/tr>\n<tr>\n<td>mixup<\/td>\n<td>0.0<\/td>\n<td>0.0<\/td>\n<td>\u672a\u542f\u7528<\/td>\n<\/tr>\n<tr>\n<td>device<\/td>\n<td>null<\/td>\n<td>null<\/td>\n<td>\u81ea\u52a8\u9009\u62e9<\/td>\n<\/tr>\n<tr>\n<td>cache<\/td>\n<td>false<\/td>\n<td>false<\/td>\n<td>\u672a\u7f13\u5b58\u5230\u5185\u5b58<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4e00\u4e2a\u5f88\u5bb9\u6613\u88ab\u5ffd\u7565\u7684\u7ec6\u8282&#xff1a;train.py \u91cc\u7684\u53c2\u6570\u548c train4 \u5b8c\u5168\u4e00\u81f4&#xff0c;\u800c train2 \u7684 epochs&#061;200 \/ batch&#061;32 \/ patience&#061;50 \u663e\u7136\u6765\u81ea\u53e6\u4e00\u6b21\u624b\u52a8\u4f20\u5165\u3002\u6240\u4ee5\u4f60\u5728\u535a\u5ba2\u6216\u8bba\u6587\u91cc\u5199\u300c\u672c\u7cfb\u7edf\u8bad\u7ec3\u53c2\u6570\u4e3a epochs&#061;150, batch&#061;4\u300d\u65f6&#xff0c;\u8bf4\u7684\u5176\u5b9e\u53ea\u662f train.py \u5f53\u524d\u7248\u672c &#043; train4 \u90a3\u4e00\u6b21&#xff1b;train2 \u90a3\u6b21\u662f\u7528\u66f4\u5927\u7684 batch \u8dd1\u7684&#xff0c;\u4e24\u8005\u4e0d\u80fd\u6df7\u7740\u5f15\u7528\u3002<\/p>\n<p>\u8bad\u7ec3\u73af\u5883\u65b9\u9762&#xff0c;\u5de5\u7a0b\u6ca1\u6709\u7559\u5b58\u73af\u5883\u5feb\u7167\u6216 nvidia-smi \u8f93\u51fa&#xff0c;\u56e0\u6b64\u663e\u5361\u578b\u53f7\u3001CUDA \u7248\u672c\u3001\u5355\u8f6e\u8017\u65f6\u3001\u603b\u8bad\u7ec3\u65f6\u957f\u5747&#xff08;\u5f85\u8865\u5145&#xff09;\u3002\u4ece batch&#061;4 \u4e0e workers&#061;8 \u8fd9\u7ec4\u504f\u4fdd\u5b88\u7684\u914d\u7f6e\u53cd\u63a8&#xff0c;\u8bad\u7ec3\u673a\u5668\u663e\u5b58\u5927\u6982\u7387\u5728 4~6 GB \u533a\u95f4&#xff0c;\u4f46\u8fd9\u53ea\u662f\u63a8\u65ad&#xff0c;\u4e0d\u80fd\u5f53\u7ed3\u8bba\u5199\u8fdb\u6587\u6863\u3002<\/p>\n<p>\u5751\u70b9\u63d0\u9192 3&#xff1a;requirements.txt \u91cc\u5217\u4e86 31 \u9879\u4f9d\u8d56&#xff0c;\u4f46 pillow \u6ca1\u6709\u5199\u8fdb\u53bb&#xff0c;\u800c\u4e3b\u7a0b\u5e8f\u5728\u5904\u7406\u68c0\u6d4b\u7ed3\u679c\u65f6\u4f1a\u7528\u5230 PIL&#xff1b;\u540c\u65f6 torch&#061;&#061;1.9.0 \u4e0e ultralytics&#061;&#061;8.0.199 \u8fd9\u4e2a\u7ec4\u5408\u504f\u8001&#xff0c;\u65b0\u88c5\u73af\u5883\u65f6\u5efa\u8bae\u76f4\u63a5\u88c5\u65b0\u7248\u672c torch&#xff0c;\u522b\u6309 requirements \u786c\u88c5\u2014\u2014\u65e7\u7248 torch \u5728\u65b0\u9a71\u52a8\u4e0a\u7ecf\u5e38\u62a5 sm_xx is not compatible\u3002\u88c5\u5b8c\u5148\u8dd1\u4e00\u53e5 from ultralytics import YOLO \u9a8c\u8bc1&#xff0c;\u6bd4\u8bad\u7ec3\u5230\u4e00\u534a\u624d\u5d29\u8981\u7701\u65f6\u95f4\u3002<\/p>\n<hr \/>\n<h3 id=\"_5\">\u516d\u3001\u8bad\u7ec3\u8fc7\u7a0b\u4e0e\u6307\u6807\u5206\u6790<\/h3>\n<p>\u5148\u628a\u4e09\u6b21\u8bad\u7ec3\u7684\u771f\u5b9e\u8bb0\u5f55\u6446\u51fa\u6765&#xff08;\u5168\u90e8\u53d6\u81ea runs\/detect\/*\/results.csv \u7684\u672b\u884c\u4e0e\u6700\u4f73\u884c&#xff09;&#xff1a;<\/p>\n<table>\n<tr>\u8bad\u7ec3\u76ee\u5f55\u53c2\u6570\u8bb0\u5f55\u8f6e\u6b21\u6700\u4f73\u8f6e\u6b21PRmAP&#064;0.5mAP&#064;0.5-0.95<\/tr>\n<tbody>\n<tr>\n<td>train2<\/td>\n<td>epochs&#061;200, batch&#061;32<\/td>\n<td>\u5230\u7b2c 177 \u8f6e<\/td>\n<td>\u7b2c 162 \u8f6e<\/td>\n<td>0.90749<\/td>\n<td>0.87476<\/td>\n<td>0.93273<\/td>\n<td>0.60291<\/td>\n<\/tr>\n<tr>\n<td>train4<\/td>\n<td>epochs&#061;150, batch&#061;4<\/td>\n<td>\u8dd1\u6ee1 150 \u8f6e<\/td>\n<td>\u7b2c 82 \u8f6e<\/td>\n<td>0.91713<\/td>\n<td>0.85287<\/td>\n<td>0.92972<\/td>\n<td>0.60259<\/td>\n<\/tr>\n<tr>\n<td>train5<\/td>\n<td>epochs&#061;150, batch&#061;4<\/td>\n<td>\u7b2c 3 \u8f6e\u4e2d\u65ad<\/td>\n<td>\u7b2c 2 \u8f6e<\/td>\n<td>0.83633<\/td>\n<td>0.73238<\/td>\n<td>0.80050<\/td>\n<td>0.47195<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8fd9\u5f20\u8868\u662f\u8bad\u7ec3\u65e5\u5fd7\u7684\u539f\u59cb\u8bb0\u5f55&#xff0c;\u7edf\u4e00\u6807\u6ce8\u4e3a\u300c\u5bf9\u5e94\u8f6e\u6b21\u8bad\u7ec3\u65e5\u5fd7\u8bb0\u5f55\u503c\u300d\u3002models\/best.pt \u5230\u5e95\u6765\u81ea\u54ea\u4e00\u8f6e\u3001\u5728\u9a8c\u8bc1\u96c6\u4e0a\u7684\u771f\u5b9e\u7cbe\u5ea6\u662f\u591a\u5c11&#xff0c;\u5de5\u7a0b\u91cc\u6ca1\u6709\u6807\u6ce8&#xff0c;\u5c5e\u4e8e\u4fe1\u606f\u7f3a\u53e3\u3002\u8981\u5728\u8bba\u6587\u6216\u535a\u5ba2\u91cc\u5199\u51c6\u786e\u7387&#xff0c;\u6b63\u786e\u505a\u6cd5\u662f\u62ff models\/best.pt \u91cd\u65b0\u8dd1\u4e00\u6b21 model.val() \u53d6\u503c&#xff0c;\u800c\u4e0d\u662f\u4ece csv \u91cc\u6311\u4e00\u4e2a\u6700\u597d\u770b\u7684\u6570\u5b57\u3002<\/p>\n<p>\u4e0b\u9762\u8fd9\u6761\u66f2\u7ebf\u662f train2 \u5168\u7a0b 177 \u8f6e\u7684\u53ef\u89c6\u5316&#xff0c;\u4e09\u884c\u5206\u522b\u662f box\/cls\/dfl \u635f\u5931&#xff0c;\u4e24\u5217\u662f\u8bad\u7ec3\u96c6\u4e0e\u9a8c\u8bc1\u96c6&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"800\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261118184841-6afdf30903417.png\" width=\"1600\" \/><\/p>\n<p>\u56fe 1 YOLOv8 \u5b89\u5168\u5e3d\u68c0\u6d4b\u8bad\u7ec3\u66f2\u7ebf&#xff08;train2&#xff0c;\u5171 177 \u8f6e&#xff09;<\/p>\n<p>\u5149\u770b\u56fe\u770b\u4e0d\u51fa\u7cbe\u786e\u6570\u503c&#xff0c;\u6240\u4ee5\u628a\u5173\u952e\u8f6e\u6b21\u4ece csv \u91cc\u62bd\u51fa\u6765\u5bf9\u9f50\u770b&#xff1a;<\/p>\n<table>\n<tr>\u8f6e\u6b21mAP&#064;0.5PrecisionRecalltrain\/box_lossval\/box_loss<\/tr>\n<tbody>\n<tr>\n<td>1<\/td>\n<td>0.66489<\/td>\n<td>\u2014<\/td>\n<td>\u2014<\/td>\n<td>\u2014<\/td>\n<td>\u2014<\/td>\n<\/tr>\n<tr>\n<td>10<\/td>\n<td>0.85001<\/td>\n<td>0.87199<\/td>\n<td>0.79009<\/td>\n<td>1.5328<\/td>\n<td>1.4758<\/td>\n<\/tr>\n<tr>\n<td>25<\/td>\n<td>0.89816<\/td>\n<td>0.89599<\/td>\n<td>0.83095<\/td>\n<td>1.4514<\/td>\n<td>1.4230<\/td>\n<\/tr>\n<tr>\n<td>50<\/td>\n<td>0.91088<\/td>\n<td>0.89627<\/td>\n<td>0.83393<\/td>\n<td>1.4087<\/td>\n<td>1.3982<\/td>\n<\/tr>\n<tr>\n<td>75<\/td>\n<td>0.92608<\/td>\n<td>0.90903<\/td>\n<td>0.85711<\/td>\n<td>1.3861<\/td>\n<td>1.3842<\/td>\n<\/tr>\n<tr>\n<td>100<\/td>\n<td>0.92994<\/td>\n<td>0.89605<\/td>\n<td>0.87355<\/td>\n<td>1.3426<\/td>\n<td>1.3852<\/td>\n<\/tr>\n<tr>\n<td>125<\/td>\n<td>0.93129<\/td>\n<td>0.89625<\/td>\n<td>0.87581<\/td>\n<td>1.3147<\/td>\n<td>1.3834<\/td>\n<\/tr>\n<tr>\n<td>150<\/td>\n<td>0.93066<\/td>\n<td>0.89981<\/td>\n<td>0.87864<\/td>\n<td>1.2883<\/td>\n<td>1.3908<\/td>\n<\/tr>\n<tr>\n<td>175<\/td>\n<td>0.93214<\/td>\n<td>0.90906<\/td>\n<td>0.87593<\/td>\n<td>1.2550<\/td>\n<td>1.3935<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4ece\u8fd9\u5f20\u8868\u80fd\u8bfb\u51fa\u56db\u4e2a\u7ed3\u8bba&#xff0c;\u90fd\u662f\u6570\u5b57\u76f4\u63a5\u652f\u6491\u7684&#xff1a;<\/p>\n<li>\u6536\u655b\u6781\u5feb&#xff1a;\u7b2c 1 \u8f6e mAP&#064;0.5 \u5c31\u6709 0.66489&#xff0c;\u7b2c 10 \u8f6e 0.85001&#xff0c;\u7b2c 25 \u8f6e\u5df2\u7ecf 0.89816\u3002\u8fd9\u4e3b\u8981\u5f52\u529f\u4e8e yolov8n.pt \u7684\u9884\u8bad\u7ec3\u6743\u91cd\u2014\u2014\u5b83\u5df2\u7ecf\u5728 COCO \u4e0a\u5b66\u4f1a\u4e86\u300c\u4ec0\u4e48\u662f\u4eba\u5f62\u300d\u300c\u4ec0\u4e48\u662f\u5706\u5f62\u7269\u4f53\u300d\u8fd9\u7c7b\u901a\u7528\u7279\u5f81&#xff0c;\u5fae\u8c03\u53ea\u9700\u8981\u9002\u914d\u672c\u4efb\u52a1\u7684\u7c7b\u76ee\u4e0e\u573a\u666f\u3002\u8fd9\u4e5f\u662f\u4e3a\u4ec0\u4e48\u8fd9\u7c7b\u9879\u76ee\u300c\u4e0d\u7528\u51e0\u8f6e\u5c31\u80fd\u51fa\u6548\u679c\u300d&#xff0c;\u4f46\u4e0d\u4ee3\u8868\u53ef\u4ee5\u5c11\u8dd1&#xff0c;\u540e\u671f\u90a3\u4e00\u4e24\u4e2a\u70b9\u7684\u63d0\u5347\u624d\u662f\u4ece\u300c\u80fd\u7528\u300d\u5230\u300c\u597d\u7528\u300d\u7684\u5dee\u522b\u3002<\/li>\n<li>50 \u8f6e\u540e\u8fdb\u5165\u5e73\u53f0\u671f&#xff1a;\u7b2c 50 \u8f6e 0.91088&#xff0c;\u7b2c 75 \u8f6e 0.92608&#xff0c;\u7b2c 125 \u8f6e 0.93129&#xff0c;\u7b2c 175 \u8f6e 0.93214\u3002\u540e 100 \u8f6e\u7684\u7d2f\u8ba1\u63d0\u5347\u4e0d\u5230 2 \u4e2a\u767e\u5206\u70b9&#xff0c;\u8bf4\u660e\u6570\u636e\u672c\u8eab\u7684\u4fe1\u606f\u91cf\u5df2\u7ecf\u88ab\u6316\u5f97\u5dee\u4e0d\u591a&#xff0c;\u518d\u52a0\u8f6e\u6570\u6536\u76ca\u6781\u4f4e\u3002\u82e5\u60f3\u628a mAP \u63d0\u5230 0.95 \u4ee5\u4e0a&#xff0c;\u9760\u8bad\u7ec3\u65f6\u95f4\u6ca1\u7528&#xff0c;\u5f97\u9760\u8865\u6570\u636e&#xff08;\u66f4\u591a\u591c\u95f4\u3001\u9006\u5149\u3001\u5bc6\u96c6\u4eba\u7fa4\u6837\u672c&#xff09;\u3002<\/li>\n<li>\u8bad\u7ec3\u635f\u5931\u4e0e\u9a8c\u8bc1\u635f\u5931\u51fa\u73b0\u526a\u5200\u5dee&#xff1a;train\/box_loss \u4ece 1.5328 \u5355\u8c03\u964d\u5230 1.2550&#xff08;\u964d 18%&#xff09;&#xff0c;\u800c val\/box_loss \u53ea\u5728 1.3842&#xff5e;1.4758 \u4e4b\u95f4\u6ce2\u52a8\u3001\u6574\u4f53\u51e0\u4e4e\u4e0d\u964d\u3002\u8fd9\u662f\u6a21\u578b\u5f00\u59cb\u8bb0\u5fc6\u8bad\u7ec3\u96c6\u7ec6\u8282\u3001\u6cdb\u5316\u80fd\u529b\u505c\u6b62\u589e\u957f\u7684\u5178\u578b\u4fe1\u53f7\u3002\u65e5\u5fd7\u91cc train2 \u5728\u7b2c 162 \u8f6e\u8fbe\u5230\u6700\u4f73 mAP&#064;0.5&#061;0.93273 \u540e&#xff0c;\u7b2c 177 \u8f6e\u53cd\u800c\u7565\u964d\u5230 0.93189&#xff0c;\u5c5e\u4e8e\u6b63\u5e38\u7684\u672b\u7aef\u6296\u52a8&#xff0c;\u4e0d\u503c\u5f97\u4e3a\u5b83\u8c03\u53c2\u3002<\/li>\n<li>Precision \u59cb\u7ec8\u9ad8\u4e8e Recall&#xff1a;\u672b\u8f6e P&#061;0.9078 \/ R&#061;0.87638&#xff0c;\u5dee\u7ea6 3 \u4e2a\u767e\u5206\u70b9\u3002\u8bf4\u660e\u6a21\u578b\u7684\u6027\u683c\u662f\u300c\u5b81\u53ef\u5c11\u62a5&#xff0c;\u4e0d\u4e71\u62a5\u300d&#xff0c;\u6f0f\u68c0\u7565\u591a\u4e8e\u8bef\u68c0\u3002\u5b89\u5168\u5e3d\u68c0\u6d4b\u573a\u666f\u4e0b\u8fd9\u4e2a\u503e\u5411\u662f\u504f\u5b89\u5168\u7684&#xff08;\u8bef\u62a5\u4e00\u6b21\u8981\u4eba\u5de5\u590d\u6838&#xff0c;\u6f0f\u68c0\u4e00\u6b21\u53ef\u80fd\u51fa\u4eba\u547d&#xff09;&#xff0c;\u53cd\u8fc7\u6765\u8bf4\u5982\u679c\u60f3\u66f4\u4e25\u683c&#xff0c;\u5e94\u8be5\u964d\u4f4e\u63a8\u7406 conf \u9608\u503c\u6765\u6362 Recall\u3002<\/li>\n<p>\u9a8c\u8bc1\u96c6\u7684\u771f\u503c\u4e0e\u6a21\u578b\u9884\u6d4b\u653e\u5728\u4e00\u8d77\u5bf9\u6bd4&#xff0c;\u80fd\u76f4\u89c2\u770b\u51fa\u6f0f\u68c0\u4e0e\u8bef\u68c0\u53d1\u751f\u5728\u4ec0\u4e48\u4f4d\u7f6e&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"802\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261118184841-6afdf30991eb7.jpg\" width=\"1400\" \/><\/p>\n<p>\u56fe 4 \u9a8c\u8bc1\u96c6\u6807\u6ce8\u771f\u503c<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"802\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261118184841-6afdf309dbc1d.jpg\" width=\"1400\" \/><\/p>\n<p>\u56fe 5 \u540c\u4e00\u6279\u9a8c\u8bc1\u56fe\u7684\u6a21\u578b\u9884\u6d4b\u7ed3\u679c<\/p>\n<p>\u5bf9\u6bd4\u8fd9\u4e24\u5f20\u56fe&#xff08;\u540c\u4e00\u6279\u9a8c\u8bc1\u56fe\u3001\u5de6\u771f\u503c\u53f3\u9884\u6d4b&#xff09;&#xff0c;\u53ef\u4ee5\u770b\u5230\u5c0f\u76ee\u6807\u548c\u906e\u6321\u76ee\u6807\u7684\u5dee\u5f02\u6700\u660e\u663e\u2014\u2014\u8fd9\u4e5f\u662f recall \u4e0a\u4e0d\u53bb\u7684\u4e3b\u8981\u539f\u56e0\u3002<\/p>\n<p>\u6df7\u6dc6\u77e9\u9635\u7ed9\u51fa\u4e86\u66f4\u7ec6\u7684\u7c92\u5ea6&#xff1a;\u4e0d\u53ea\u662f\u300c\u5bf9\u4e86\u51e0\u6210\u300d&#xff0c;\u800c\u662f\u300c\u9519\u6210\u4e86\u4ec0\u4e48\u300d&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1200\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261118184842-6afdf30a31564.png\" width=\"1600\" \/><\/p>\n<p>\u56fe 6 \u6df7\u6dc6\u77e9\u9635<\/p>\n<p>\u4e24\u7c7b\u522b\u573a\u666f\u7684\u6df7\u6dc6\u77e9\u9635\u53ea\u6709 3\u00d73&#xff08;hat \/ person \/ background&#xff09;&#xff0c;\u8bfb\u6cd5\u5f88\u7b80\u5355&#xff1a;\u5bf9\u89d2\u7ebf\u662f\u5224\u5bf9\u7684&#xff0c;\u53f3\u4e0a\u4e09\u89d2\u662f\u300c\u628a hat \u5224\u6210 person\u300d\u8fd9\u7c7b\u7c7b\u522b\u4e92\u6362\u9519\u8bef&#xff0c;\u6700\u540e\u4e00\u5217\u662f\u300c\u771f\u5b9e\u5b58\u5728\u4f46\u6ca1\u68c0\u51fa\u6765\u300d&#xff0c;\u6700\u540e\u4e00\u884c\u662f\u300c\u51ed\u7a7a\u591a\u68c0\u51fa\u6765\u7684\u6846\u300d\u3002\u5b89\u5168\u5e3d\u4e0e\u4eba\u7684\u6df7\u5224\u5728\u7406\u8bba\u4e0a\u4e0d\u8be5\u51fa\u73b0&#xff08;\u4e24\u8005\u5c3a\u5bf8\u3001\u4f4d\u7f6e\u5dee\u5f02\u5de8\u5927&#xff09;&#xff0c;\u5982\u679c\u8fd9\u4e24\u683c\u6570\u503c\u504f\u9ad8&#xff0c;\u7b2c\u4e00\u5acc\u7591\u5c31\u662f\u7c7b\u540d\u6620\u5c04\u9519\u4f4d\u2014\u2014\u4e5f\u5c31\u662f\u7b2c\u4e00\u8282\u90a3\u4e2a hat vs helmet \u7684\u5751\u3002<\/p>\n<p>PR \u66f2\u7ebf\u5c55\u793a\u7684\u662f\u4e0d\u540c\u7f6e\u4fe1\u5ea6\u9608\u503c\u4e0b Precision \u4e0e Recall \u7684\u6743\u8861&#xff0c;\u66f2\u7ebf\u4e0b\u9762\u79ef&#xff08;AUC&#xff09;\u5c31\u662f AP&#xff1b;F1 \u66f2\u7ebf\u5219\u662f\u628a\u4e24\u8005\u5408\u6210\u4e00\u4e2a\u6307\u6807&#xff0c;\u5cf0\u503c\u70b9\u5bf9\u5e94\u300c\u7efc\u5408\u6700\u4f18\u7684\u7f6e\u4fe1\u5ea6\u9608\u503c\u300d&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1066\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261118184842-6afdf30ae85ef.png\" width=\"1600\" \/><\/p>\n<p>\u56fe 7 PR \u66f2\u7ebf<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1066\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261118184843-6afdf30b9e9fb.png\" width=\"1600\" \/><\/p>\n<p>\u56fe 8 F1 \u503c\u968f\u7f6e\u4fe1\u5ea6\u9608\u503c\u53d8\u5316<\/p>\n<p>\u8fd9\u4e24\u5f20\u56fe\u7684\u5b9e\u9645\u7528\u6cd5&#xff1a;F1 \u66f2\u7ebf\u7684\u5cf0\u503c\u6a2a\u5750\u6807&#xff0c;\u5c31\u662f\u8fd9\u5957\u6a21\u578b\u5728\u90e8\u7f72\u65f6\u6700\u8be5\u8bbe\u7f6e\u7684 conf \u503c\u3002\u5de5\u7a0b\u91cc\u7528\u7684\u662f\u5e93\u9ed8\u8ba4 0.25&#xff0c;\u5982\u679c\u4f60\u5e0c\u671b\u73b0\u573a\u8bef\u62a5\u66f4\u5c11&#xff0c;\u5c31\u5f80\u5cf0\u503c\u53f3\u4fa7\u632a&#xff1b;\u5e0c\u671b\u4e0d\u6f0f\u4eba&#xff0c;\u5c31\u5f80\u5de6\u632a\u3002\u8fd9\u662f\u628a\u300c\u6307\u6807\u300d\u7ffb\u8bd1\u6210\u300c\u4ea7\u54c1\u51b3\u7b56\u300d\u7684\u5173\u952e\u4e00\u6b65&#xff0c;\u6bd4\u5728\u535a\u5ba2\u91cc\u5199\u4e00\u53e5\u300cmAP 0.93\u300d\u6709\u7528\u5f97\u591a\u3002<\/p>\n<hr \/>\n<h3 id=\"_6\">\u4e03\u3001\u6838\u5fc3\u4ee3\u7801\u9010\u6bb5\u89e3\u8bfb<\/h3>\n<h4 id=\"71\">7.1 \u542f\u52a8\u4e0e\u521d\u59cb\u5316&#xff1a;\u628a\u8d35\u7684\u4e1c\u897f\u653e\u5728\u6700\u524d\u9762<\/h4>\n<p>class MainWindow(QMainWindow):<br \/>\n    def __init__(self):<br \/>\n        super().__init__()<br \/>\n        self.ui &#061; Ui_MainWindow()<br \/>\n        self.ui.setupUi(self)<br \/>\n        self.initMain()<br \/>\n        self.signalconnect()<\/p>\n<p>__init__ \u53ea\u505a\u4e09\u4ef6\u4e8b&#xff1a;\u642d\u754c\u9762\u3001\u521d\u59cb\u5316\u8d44\u6e90\u3001\u7ed1\u4fe1\u53f7\u3002\u987a\u5e8f\u4e0d\u80fd\u6362\u2014\u2014initMain() \u91cc\u8981\u64cd\u4f5c self.ui \u7684\u8868\u683c\u63a7\u4ef6&#xff0c;\u5fc5\u987b\u7b49 setupUi \u4e4b\u540e\u3002<\/p>\n<p>def initMain(self):<br \/>\n    self.show_width &#061; 770<br \/>\n    self.show_height &#061; 480<br \/>\n    self.org_path &#061; None<br \/>\n    self.is_camera_open &#061; False<br \/>\n    self.cap &#061; None<br \/>\n    self.device &#061; 0 if torch.cuda.is_available() else &#039;cpu&#039;<\/p>\n<p>    self.model &#061; YOLO(Config.model_path, task&#061;&#039;detect&#039;)<br \/>\n    self.model(np.zeros((48, 48, 3)))                     # \u9884\u5148\u52a0\u8f7d\u63a8\u7406\u6a21\u578b<br \/>\n    self.fontC &#061; ImageFont.truetype(&#034;Font\/platech.ttf&#034;, 25, 0)<\/p>\n<p>    self.ui.tableWidget.verticalHeader().setSectionResizeMode(QHeaderView.Fixed)<br \/>\n    self.ui.tableWidget.verticalHeader().setDefaultSectionSize(40)<br \/>\n    self.ui.tableWidget.setColumnWidth(0, 80)<br \/>\n    self.ui.tableWidget.setColumnWidth(1, 200)<br \/>\n    self.ui.tableWidget.setColumnWidth(2, 150)<br \/>\n    self.ui.tableWidget.setColumnWidth(3, 90)<br \/>\n    self.ui.tableWidget.setColumnWidth(4, 230)<br \/>\n    self.ui.tableWidget.setSelectionBehavior(QAbstractItemView.SelectRows)<br \/>\n    self.ui.tableWidget.verticalHeader().setVisible(False)<br \/>\n    self.ui.tableWidget.setAlternatingRowColors(True)<\/p>\n<ul>\n<li>self.model(np.zeros((48,48,3))) \u5c31\u662f\u524d\u9762\u8bf4\u7684\u7a7a\u56fe\u9884\u70ed\u3002\u6ce8\u610f\u8fd9\u884c\u4e0d\u662f\u300c\u591a\u4f59\u7684\u63a8\u7406\u300d\u2014\u2014\u5b83\u89e6\u53d1\u4e86 Ultralytics \u5185\u90e8\u7684\u6a21\u578b fuse\u3001\u8bbe\u5907\u642c\u8fd0\u4e0e\u9996\u6b21\u524d\u5411&#xff0c;\u7701\u6389\u7684\u5c31\u662f\u7528\u6237\u7b2c\u4e00\u6b21\u70b9\u6309\u94ae\u65f6\u90a3\u4e24\u4e09\u79d2\u3002<\/li>\n<li>ImageFont.truetype(&#034;Font\/platech.ttf&#034;, 25, 0) \u7528\u76f8\u5bf9\u8def\u5f84\u8bfb\u5b57\u4f53&#xff0c;\u6240\u4ee5\u5fc5\u987b\u5728\u9879\u76ee\u6839\u76ee\u5f55\u542f\u52a8\u7a0b\u5e8f&#xff0c;\u5426\u5219 drawRectBox \u4f1a\u629b OSError: cannot open resource\u3002\u8fd9\u662f\u65b0\u624b\u6700\u5e38\u89c1\u7684\u542f\u52a8\u5931\u8d25\u539f\u56e0\u4e4b\u4e00\u3002<\/li>\n<li>\u8868\u683c\u90a3\u4e03\u884c\u662f\u628a Qt \u8868\u683c\u300c\u8c03\u6210\u4eba\u80fd\u770b\u7684\u6837\u5b50\u300d\u7684\u6807\u51c6\u914d\u65b9&#xff1a;\u884c\u9ad8 40 \u4e0d\u6324\u3001\u9690\u85cf\u5de6\u4fa7\u884c\u53f7\u680f\u3001\u6574\u884c\u9009\u4e2d\u800c\u4e0d\u662f\u5355\u683c\u9009\u4e2d\u3001\u5947\u5076\u884c\u4ea4\u66ff\u914d\u8272\u4fbf\u4e8e\u6a2a\u5411\u8bfb\u3002\u540e\u4e94\u9879&#xff08;\u5217\u5bbd&#xff09;\u4e0e\u4e1a\u52a1\u5b57\u6bb5\u4e00\u4e00\u5bf9\u5e94&#xff0c;\u6539\u52a8\u5217\u987a\u5e8f\u65f6\u5fc5\u987b\u540c\u6b65\u6539\u8fd9\u91cc\u3002<\/li>\n<\/ul>\n<h4 id=\"72\">7.2 \u4fe1\u53f7\u7ed1\u5b9a&#xff1a;\u4e00\u5904\u96c6\u4e2d&#xff0c;\u4fbf\u4e8e\u7ef4\u62a4<\/h4>\n<p>def signalconnect(self):<br \/>\n    self.ui.PicBtn.clicked.connect(self.open_img)           # \u5355\u56fe<br \/>\n    self.ui.FilesBtn.clicked.connect(self.detact_batch_imgs) # \u6587\u4ef6\u5939\u6279\u91cf<br \/>\n    self.ui.VideoBtn.clicked.connect(self.vedio_show)       # \u89c6\u9891<br \/>\n    self.ui.CapBtn.clicked.connect(self.camera_show)        # \u6444\u50cf\u5934&#xff08;\u5f00\u5173\u5f0f&#xff09;<br \/>\n    self.ui.SaveBtn.clicked.connect(self.save_detect_video) # \u4fdd\u5b58\u7ed3\u679c<br \/>\n    self.ui.ExitBtn.clicked.connect(QCoreApplication.quit)  # \u9000\u51fa<br \/>\n    self.ui.comboBox.activated.connect(self.combox_change)  # \u76ee\u6807\u4e0b\u62c9\u9009\u62e9<\/p>\n<p>\u628a\u6240\u6709 connect \u96c6\u4e2d\u5728\u4e00\u4e2a\u65b9\u6cd5\u91cc&#xff0c;\u597d\u5904\u662f\u300c\u754c\u9762\u6709\u54ea\u4e9b\u80fd\u529b\u300d\u53ef\u4ee5\u4e00\u773c\u770b\u5b8c&#xff0c;\u4e0d\u7528\u5728\u51e0\u5343\u884c\u91cc\u7ffb\u3002\u8fd9\u4e5f\u662f Qt \u9879\u76ee\u7684\u63a8\u8350\u5199\u6cd5\u3002<\/p>\n<h4 id=\"73\">7.3 \u5355\u56fe\u63a8\u7406&#xff1a;\u4ece\u8def\u5f84\u5230\u50cf\u7d20&#xff0c;\u518d\u5230\u8868\u683c<\/h4>\n<p>def open_img(self):<br \/>\n    if self.cap:<br \/>\n        self.video_stop()<br \/>\n        self.is_camera_open &#061; False<br \/>\n        self.ui.CaplineEdit.setText(&#039;\u6444\u50cf\u5934\u672a\u5f00\u542f&#039;)<\/p>\n<p>    file_path, _ &#061; QFileDialog.getOpenFileName(None, &#039;\u6253\u5f00\u56fe\u7247&#039;, &#039;.\/&#039;,<br \/>\n                                              &#034;Image files (*.jpg *.jepg *.png)&#034;)<br \/>\n    if file_path:<br \/>\n        self.ui.comboBox.setDisabled(False)<br \/>\n        self.org_path &#061; file_path<br \/>\n        self.org_img &#061; tools.img_cvread(self.org_path)<\/p>\n<p>        t1 &#061; time.time()<br \/>\n        self.results &#061; self.model(self.org_path)[0]<br \/>\n        t2 &#061; time.time()<br \/>\n        self.ui.time_lb.setText(&#039;{:.3f} s&#039;.format(t2 &#8211; t1))<\/p>\n<p>        location_list &#061; self.results.boxes.xyxy.tolist()<br \/>\n        self.location_list &#061; [list(map(int, e)) for e in location_list]<br \/>\n        cls_list &#061; self.results.boxes.cls.tolist()<br \/>\n        self.cls_list &#061; [int(i) for i in cls_list]<br \/>\n        conf_list &#061; self.results.boxes.conf.tolist()<br \/>\n        self.conf_list &#061; [&#039;%.2f %%&#039; % (each * 100) for each in self.conf_list]<\/p>\n<p>        now_img &#061; self.results.plot()<br \/>\n        self.draw_img &#061; now_img<br \/>\n        self.img_width, self.img_height &#061; self.get_resize_size(now_img)<br \/>\n        resize_cvimg &#061; cv2.resize(now_img, (self.img_width, self.img_height))<br \/>\n        pix_img &#061; tools.cvimg_to_qpiximg(resize_cvimg)<br \/>\n        self.ui.label_show.setPixmap(pix_img)<br \/>\n        self.ui.label_show.setAlignment(Qt.AlignCenter)<br \/>\n        self.ui.PiclineEdit.setText(self.org_path)<br \/>\n        self.tabel_info_show(self.location_list, self.cls_list,<br \/>\n                             self.conf_list, path&#061;self.org_path)<\/p>\n<p>\u8fd9\u6bb5\u662f\u5168\u5de5\u7a0b\u4fe1\u606f\u5bc6\u5ea6\u6700\u9ad8\u7684\u5730\u65b9&#xff0c;\u503c\u5f97\u9010\u53e5\u62c6&#xff1a;<\/p>\n<ul>\n<li>\u5148\u5239\u8f66\u518d\u5f00\u65b0\u4efb\u52a1&#xff1a;\u8fdb\u5165\u65b9\u6cd5\u7b2c\u4e00\u4ef6\u4e8b\u662f\u5224\u65ad\u6444\u50cf\u5934\u662f\u5426\u5f00\u7740&#xff0c;\u5f00\u7740\u5c31\u5148 video_stop()\u3002\u5426\u5219\u6444\u50cf\u5934\u7ebf\u7a0b\u7ee7\u7eed\u5f80\u540c\u4e00\u4e2a label_show \u5237\u5e27&#xff0c;\u4f60\u521a\u663e\u793a\u7684\u68c0\u6d4b\u56fe\u4f1a\u5728\u51e0\u5341\u6beb\u79d2\u540e\u88ab\u6444\u50cf\u5934\u753b\u9762\u8986\u76d6&#xff0c;\u8868\u73b0\u4e3a\u300c\u70b9\u4e86\u68c0\u6d4b\u4f46\u56fe\u95ea\u4e00\u4e0b\u5c31\u6ca1\u4e86\u300d\u3002<\/li>\n<li>\u8ba1\u65f6\u53ea\u5305\u4f4f\u63a8\u7406&#xff1a;t1 \u653e\u5728\u6a21\u578b\u8c03\u7528\u524d\u3001t2 \u7d27\u8ddf\u5728\u540e\u9762&#xff0c;\u6240\u4ee5\u754c\u9762\u4e0a\u7684\u300c\u7528\u65f6\u300d\u662f\u7eaf\u63a8\u7406\u8017\u65f6&#xff0c;\u4e0d\u542b\u8bfb\u76d8\u3001\u753b\u6846\u3001\u7f29\u653e\u3001\u5237\u65b0 QT \u63a7\u4ef6\u3002\u8fd9\u4e2a\u53e3\u5f84\u8981\u8bf4\u6e05\u695a&#xff0c;\u5426\u5219\u522b\u4eba\u62ff\u5b83\u5f53\u7aef\u5230\u7aef\u5ef6\u8fdf\u4f1a\u8bef\u5224\u3002<\/li>\n<li>\u4e09\u7c7b\u7ed3\u679c\u5206\u5f00\u53d6&#xff1a;\u5750\u6807 boxes.xyxy&#xff08;\u5de6\u4e0a&#043;\u53f3\u4e0b&#xff0c;\u7edd\u5bf9\u503c\u50cf\u7d20&#xff09;\u3001\u7c7b\u522b boxes.cls&#xff08;float&#xff0c;\u8981\u8f6c int \u5f53\u7d22\u5f15&#xff09;\u3001\u7f6e\u4fe1\u5ea6 boxes.conf&#xff08;0~1&#xff0c;\u4e58 100 \u518d\u683c\u5f0f\u5316\u6210\u767e\u5206\u6bd4&#xff09;\u3002\u4e09\u8005\u662f\u6309\u540c\u4e00\u987a\u5e8f\u6392\u5217\u7684&#xff0c;\u7d22\u5f15\u5bf9\u9f50&#xff0c;\u6240\u4ee5\u540e\u9762 draw_rect_and_tabel \u624d\u80fd\u6309\u4e0b\u6807\u628a\u300c\u6846\u3001\u7c7b\u3001\u5206\u300d\u62fc\u6210\u4e00\u884c\u3002<\/li>\n<li>results.plot() \u662f\u7701\u4e8b\u4f46\u4e0d\u7075\u6d3b\u7684\u9009\u62e9&#xff1a;\u5b83\u76f4\u63a5\u628a\u6846\u3001\u6807\u7b7e\u753b\u597d\u8fd4\u56de BGR \u56fe&#xff0c;\u4ee3\u4ef7\u662f\u4f60\u6ca1\u6cd5\u81ea\u5b9a\u4e49\u989c\u8272\u3001\u5b57\u4f53\u5927\u5c0f\u3001\u6807\u7b7e\u4f4d\u7f6e\u3002\u60f3\u5b8c\u5168\u63a7\u5236\u6837\u5f0f\u5c31\u81ea\u5df1\u7528 detect_tools.drawRectBox \u9010\u6846\u753b\u2014\u2014\u5de5\u7a0b\u91cc\u4e24\u5957\u90fd\u7559\u4e86&#xff0c;draw_rect_and_tabel \u8d70\u7684\u662f\u81ea\u5b9a\u4e49\u8def\u5f84\u3002<\/li>\n<li>\u663e\u793a\u524d\u5fc5\u987b\u7f29\u653e&#xff1a;get_resize_size() \u6309 770\u00d7480 \u7684\u663e\u793a\u533a\u505a\u7b49\u6bd4\u7f29\u653e&#xff0c;\u8fd4\u56de\u7f29\u653e\u540e\u7684\u5bbd\u9ad8&#xff0c;\u518d cv2.resize &#043; \u8f6c QPixmap\u3002\u4e0d\u7f29\u653e\u76f4\u63a5 setPixmap&#xff0c;\u5927\u56fe\u4f1a\u628a\u6574\u4e2a\u5e03\u5c40\u6491\u53d8\u5f62\u3002<\/li>\n<li>img_cvread \u800c\u4e0d\u662f cv2.imread&#xff1a;\u524d\u8005\u7528 np.fromfile &#043; cv2.imdecode&#xff0c;\u7ed5\u5f00 OpenCV \u5bf9\u4e2d\u6587\u8def\u5f84\u7684\u7f16\u7801\u95ee\u9898\u3002\u51e1\u662f\u754c\u9762\u5141\u8bb8\u7528\u6237\u81ea\u5df1\u9009\u6587\u4ef6\u7684\u9879\u76ee&#xff0c;\u8fd9\u4e00\u6b65\u90fd\u4e0d\u80fd\u7701\u3002<\/li>\n<\/ul>\n<h4 id=\"74-qtimer-while\">7.4 \u89c6\u9891\u4e0e\u6444\u50cf\u5934&#xff1a;\u7528 QTimer \u4ee3\u66ff while<\/h4>\n<p>def vedio_show(self):<br \/>\n    if self.is_camera_open:<br \/>\n        self.is_camera_open &#061; False<br \/>\n        self.ui.CaplineEdit.setText(&#039;\u6444\u50cf\u5934\u672a\u5f00\u542f&#039;)<br \/>\n    video_path &#061; self.get_video_path()<br \/>\n    if not video_path:<br \/>\n        return None<br \/>\n    self.cap &#061; cv2.VideoCapture(video_path)<br \/>\n    self.video_start()<br \/>\n    self.ui.comboBox.setDisabled(True)<\/p>\n<p>def camera_show(self):<br \/>\n    self.is_camera_open &#061; not self.is_camera_open<br \/>\n    if self.is_camera_open:<br \/>\n        self.ui.CaplineEdit.setText(&#039;\u6444\u50cf\u5934\u5f00\u542f&#039;)<br \/>\n        self.cap &#061; cv2.VideoCapture(0)<br \/>\n        self.video_start()<br \/>\n        self.ui.comboBox.setDisabled(True)<br \/>\n    else:<br \/>\n        self.ui.CaplineEdit.setText(&#039;\u6444\u50cf\u5934\u672a\u5f00\u542f&#039;)<br \/>\n        if self.cap:<br \/>\n            self.cap.release()<br \/>\n            cv2.destroyAllWindows()<br \/>\n        self.ui.label_show.clear()<\/p>\n<p>video_start() \u91cc\u8d77\u7684\u662f QTimer&#xff0c;\u6bcf\u6b21\u8d85\u65f6\u8bfb\u4e00\u5e27\u3001\u63a8\u7406\u4e00\u5e27\u3001\u5237\u4e00\u6b21\u754c\u9762\u3002\u8fd9\u662f PyQt \u505a\u5b9e\u65f6\u753b\u9762\u7684\u6807\u51c6\u5957\u8def&#xff1a;\u7edd\u4e0d\u80fd\u5728\u4e3b\u7ebf\u7a0b\u5199 while cap.isOpened()&#xff0c;\u90a3\u4e2a\u5faa\u73af\u4f1a\u628a Qt \u4e8b\u4ef6\u5faa\u73af\u997f\u6b7b&#xff0c;\u7a97\u53e3\u76f4\u63a5\u300c\u672a\u54cd\u5e94\u300d\u3002\u6444\u50cf\u5934\u6309\u94ae\u505a\u6210\u5f00\u5173\u5f0f&#xff08;is_camera_open &#061; not is_camera_open&#xff09;&#xff0c;\u4e14\u6253\u5f00\u524d\u5148\u505c\u6389\u6b63\u5728\u64ad\u7684\u89c6\u9891&#xff0c;\u907f\u514d\u4e24\u4e2a\u6765\u6e90\u62a2\u540c\u4e00\u4e2a\u753b\u9762\u63a7\u4ef6\u3002<\/p>\n<h4 id=\"75\">7.5 \u4fdd\u5b58\u89c6\u9891&#xff1a;\u4e3a\u4ec0\u4e48\u8981\u5f00\u7ebf\u7a0b\u4e8c\u6b21\u63a8\u7406<\/h4>\n<p>def save_detect_video(self):<br \/>\n    if self.cap is None and not self.org_path:<br \/>\n        QMessageBox.about(self, &#039;\u63d0\u793a&#039;, &#039;\u5f53\u524d\u6ca1\u6709\u53ef\u4fdd\u5b58\u4fe1\u606f&#xff0c;\u8bf7\u5148\u6253\u5f00\u56fe\u7247\u6216\u89c6\u9891&#xff01;&#039;)<br \/>\n        return<br \/>\n    if self.is_camera_open:<br \/>\n        QMessageBox.about(self, &#039;\u63d0\u793a&#039;, &#039;\u6444\u50cf\u5934\u89c6\u9891\u65e0\u6cd5\u4fdd\u5b58&#xff01;&#039;)<br \/>\n        return<\/p>\n<p>    if self.cap:<br \/>\n        res &#061; QMessageBox.question(self, &#039;\u63d0\u793a&#039;,<br \/>\n                                   &#039;\u4fdd\u5b58\u89c6\u9891\u68c0\u6d4b\u7ed3\u679c\u53ef\u80fd\u9700\u8981\u8f83\u957f\u65f6\u95f4&#xff0c;\u8bf7\u786e\u8ba4\u662f\u5426\u7ee7\u7eed\u4fdd\u5b58&#xff1f;&#039;,<br \/>\n                                   QMessageBox.Yes | QMessageBox.No)<br \/>\n        if res &#061;&#061; QMessageBox.Yes:<br \/>\n            self.video_stop()<br \/>\n            com_text &#061; self.ui.comboBox.currentText()<br \/>\n            self.btn2Thread_object &#061; btn2Thread(self.org_path, self.model, com_text)<br \/>\n            self.btn2Thread_object.start()<br \/>\n            self.btn2Thread_object.update_ui_signal.connect(self.update_process_bar)<\/p>\n<p>btn2Thread \u662f\u4e00\u4e2a QThread \u5b50\u7c7b&#xff0c;run() \u91cc\u91cd\u65b0 cv2.VideoCapture \u6253\u5f00\u6e90\u89c6\u9891&#xff0c;\u9010\u5e27 model(frame)[0] \u2192 results.plot() \u2192 out.write(frame)&#xff0c;\u6bcf\u5e27 emit(cur_num, total) \u66f4\u65b0\u8fdb\u5ea6\u6761\u3002\u5199\u6587\u4ef6\u7528 fourcc &#061; cv2.VideoWriter_fourcc(*&#039;XVID&#039;)&#xff0c;\u6587\u4ef6\u540d\u89c4\u5219\u662f \u539f\u540d_detect_result.avi\u3002<\/p>\n<p>\u8fd9\u4e2a\u8bbe\u8ba1\u6709\u4e00\u4e2a\u5fc5\u987b\u627f\u8ba4\u7684\u4ee3\u4ef7&#xff1a;\u4fdd\u5b58\u4e00\u6b21\u89c6\u9891 &#061; \u63a8\u7406\u4e24\u904d\u3002\u7b2c\u4e00\u904d\u662f\u64ad\u653e\u65f6\u7684\u5b9e\u65f6\u9884\u89c8&#xff0c;\u7b2c\u4e8c\u904d\u662f\u4fdd\u5b58\u65f6\u7684\u91cd\u8dd1\u3002\u4e3a\u4ec0\u4e48\u4e0d\u7528\u300c\u64ad\u653e\u65f6\u987a\u624b\u5b58\u5e27\u300d&#xff1f;\u56e0\u4e3a\u64ad\u653e\u7528\u7684\u662f QTimer(1ms)&#xff0c;\u5b9e\u9645\u5237\u65b0\u7387\u53d7\u63a8\u7406\u901f\u5ea6\u5236\u7ea6&#xff0c;\u6389\u5e27\u662f\u5e38\u6001&#xff0c;\u987a\u624b\u5b58\u51fa\u6765\u7684\u89c6\u9891\u4f1a\u5361\u987f\u3001\u65f6\u957f\u77ed\u4e8e\u539f\u89c6\u9891\u3002\u91cd\u8dd1\u4e00\u904d\u867d\u7136\u6162&#xff0c;\u4f46\u80fd\u4fdd\u8bc1\u5e27\u7387\u4e0e\u6e90\u89c6\u9891\u4e00\u81f4\u3001\u5e27\u6570\u5b8c\u6574\u3002\u8fd9\u662f\u300c\u6b63\u786e\u6027\u4f18\u5148\u4e8e\u901f\u5ea6\u300d\u7684\u53d6\u820d&#xff0c;\u4e5f\u662f\u672c\u5de5\u7a0b\u6700\u503c\u5f97\u5b66\u7684\u4e00\u5904\u5de5\u7a0b\u5224\u65ad\u3002<\/p>\n<h4 id=\"76\">7.6 \u5de5\u5177\u5c42&#xff1a;\u4e09\u4e2a\u5fc5\u987b\u81ea\u5df1\u5199\u7684\u51fd\u6570<\/h4>\n<ul>\n<li>drawRectBox(image, rect, addText, fontC, color)&#xff1a;\u5148 cv2.rectangle \u753b\u6846&#xff0c;\u518d\u5728\u6846\u4e0a\u65b9\u753b\u4e00\u4e2a\u5b9e\u5fc3\u80cc\u666f\u6761&#xff08;thickness&#061;-1&#xff09;\u5f53\u6807\u7b7e\u5e95\u8272&#xff0c;\u6700\u540e Image.fromarray \u2192 ImageDraw.text \u2192 np.array \u8f6c\u56de&#xff0c;\u5b9e\u73b0\u4e2d\u6587\u6807\u7b7e\u3002\u80cc\u666f\u6761\u5bbd\u5ea6\u786c\u7f16\u7801 rect[0] &#043; 60&#xff0c;\u6807\u7b7e\u957f\u4e8e 4 \u4e2a\u6c49\u5b57\u5c31\u4f1a\u6ea2\u51fa&#xff0c;\u5c5e\u4e8e\u5df2\u77e5\u5c0f\u7455\u75b5\u3002<\/li>\n<li>cvimg_to_qpiximg(cvimg)&#xff1a;cv2.cvtColor(BGR2RGB) \u2192 \u6784\u9020 QImage&#xff08;\u6ce8\u610f step \u53c2\u6570\u8981\u4f20 width * depth&#xff0c;\u5426\u5219\u56fe\u50cf\u4f1a\u659c\u5207&#xff09;\u2192 QPixmap\u3002\u8fd9\u4e2a\u51fd\u6570\u662f OpenCV \u4e0e Qt \u4e4b\u95f4\u7684\u552f\u4e00\u6865&#xff0c;BGR\/RGB \u987a\u5e8f\u9519\u4e86\u5c31\u662f\u84dd\u8138\u7ea2\u4eba\u3002<\/li>\n<li>insert_rows(path, lines, header)&#xff1a;\u628a\u68c0\u6d4b\u7ed3\u679c\u8ffd\u52a0\u5199\u8fdb csv&#xff0c;\u6587\u4ef6\u4e0d\u5b58\u5728\u65f6\u5148\u5199\u8868\u5934&#xff0c;\u6bcf\u884c\u81ea\u52a8\u52a0\u81ea\u589e\u5e8f\u53f7\u3002\u8fd9\u662f\u300c\u68c0\u6d4b\u7559\u75d5\u300d\u80fd\u529b\u7684\u5b9e\u73b0&#xff0c;\u6bd4\u53ea\u5b58\u56fe\u7247\u66f4\u6709\u4ef7\u503c\u2014\u2014\u534a\u5e74\u540e\u8981\u67e5\u67d0\u5929\u68c0\u51fa\u4e86\u591a\u5c11\u672a\u6234\u5e3d&#xff0c;\u9760\u7684\u5c31\u662f\u8fd9\u4e2a csv\u3002<\/li>\n<\/ul>\n<hr \/>\n<h3 id=\"_7\">\u516b\u3001\u7cfb\u7edf\u529f\u80fd\u4e0e\u754c\u9762\u5b9e\u73b0<\/h3>\n<p>\u754c\u9762\u4e0a\u534a\u533a\u662f\u300c\u6587\u4ef6\u5bfc\u5165\u300d\u548c\u300c\u68c0\u6d4b\u7ed3\u679c\u300d\u4e24\u5757&#xff0c;\u4e0b\u534a\u533a\u662f\u300c\u68c0\u6d4b\u7ed3\u679c\u4e0e\u4f4d\u7f6e\u4fe1\u606f\u300d\u8868\u683c &#043; \u53f3\u4fa7\u4fe1\u606f\u9762\u677f&#xff08;\u76ee\u6807\u4f4d\u7f6e \/ \u76ee\u6807\u6570\u76ee \/ \u76ee\u6807\u9009\u62e9 \/ \u7528\u65f6 \/ \u7f6e\u4fe1\u5ea6&#xff09;&#xff0c;\u53f3\u4e0b\u89d2\u300c\u4fdd\u5b58\u300d\u300c\u9000\u51fa\u300d\u3002<\/p>\n<p>\u529f\u80fd\u5bf9\u5e94\u5173\u7cfb&#xff1a;<\/p>\n<table>\n<tr>\u529f\u80fd\u65b9\u6cd5\u5b9e\u73b0\u8981\u70b9<\/tr>\n<tbody>\n<tr>\n<td>\u5355\u56fe\u68c0\u6d4b<\/td>\n<td>open_img()<\/td>\n<td>\u63a8\u7406\u524d\u540e\u53d6 time.time() \u5dee\u503c&#xff0c;\u683c\u5f0f\u5316 &#039;{:.3f} s&#039; \u663e\u793a\u5728\u300c\u7528\u65f6\u300d<\/td>\n<\/tr>\n<tr>\n<td>\u6587\u4ef6\u5939\u6279\u91cf<\/td>\n<td>detact_batch_imgs()<\/td>\n<td>\u904d\u5386\u76ee\u5f55\u9010\u5f20\u63a8\u7406&#xff0c;\u7ed3\u679c\u547d\u540d\u4e3a xxx_detect_result.jpg<\/td>\n<\/tr>\n<tr>\n<td>\u89c6\u9891\u68c0\u6d4b<\/td>\n<td>vedio_show()<\/td>\n<td>cv2.VideoCapture &#043; QTimer \u9010\u5e27\u8bfb\u53d6&#xff0c;\u66ff\u4ee3 while \u5faa\u73af&#xff0c;\u907f\u514d\u963b\u585e UI<\/td>\n<\/tr>\n<tr>\n<td>\u6444\u50cf\u5934<\/td>\n<td>camera_show()<\/td>\n<td>\u5f00\u5173\u5f0f\u8bbe\u8ba1&#xff1a;\u6253\u5f00\u65f6\u82e5\u5df2\u6709\u89c6\u9891\u5728\u64ad\u5148 video_stop()&#xff0c;\u518d cv2.VideoCapture(0)<\/td>\n<\/tr>\n<tr>\n<td>\u7ed3\u679c\u8868\u683c<\/td>\n<td>tabel_info_show()<\/td>\n<td>\u4e94\u5217&#xff1a;\u5e8f\u53f7 \/ \u6587\u4ef6\u8def\u5f84 \/ \u7c7b\u522b \/ \u7f6e\u4fe1\u5ea6 \/ \u5750\u6807\u4f4d\u7f6e&#xff0c;\u81ea\u52a8\u6eda\u5230\u6700\u540e\u4e00\u884c<\/td>\n<\/tr>\n<tr>\n<td>\u76ee\u6807\u660e\u7ec6<\/td>\n<td>combox_change()<\/td>\n<td>\u4e0b\u62c9\u6846\u9ed8\u8ba4\u300c\u5168\u90e8\u300d&#xff0c;\u9009\u4e2d\u67d0\u4e00\u76ee\u6807\u540e\u56de\u586b xmin\/ymin\/xmax\/ymax\u3001\u7c7b\u522b\u3001\u7f6e\u4fe1\u5ea6<\/td>\n<\/tr>\n<tr>\n<td>\u7ed3\u679c\u4fdd\u5b58<\/td>\n<td>save_detect_video()<\/td>\n<td>\u56fe\u7247\u76f4\u63a5 cv2.imwrite \u5230 save_data&#xff1b;\u89c6\u9891\u4ea4\u7ed9 btn2Thread \u7ebf\u7a0b\u91cd\u8dd1\u4e00\u904d\u5e76\u5199 xxx_detect_result.avi&#xff08;XVID \u7f16\u7801&#xff09;&#xff0c;\u540c\u65f6\u5f39\u51fa ProgressBar \u53ef\u53d6\u6d88<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>combox_change() \u8fd9\u4e2a\u4ea4\u4e92\u503c\u5f97\u5355\u72ec\u8bf4&#xff1a;\u5b83\u628a\u300c\u8868\u683c\u91cc\u7684\u4e00\u884c\u300d\u53d8\u6210\u300c\u753b\u9762\u4e0a\u67d0\u4e00\u4e2a\u6846\u300d&#xff0c;\u5b9e\u73b0\u65b9\u5f0f\u662f\u6309\u4e0b\u6807\u4ece self.location_list \/ self.cls_list \/ self.conf_list \u91cc\u540c\u6b65\u53d6\u503c\u3002\u4e09\u4e2a\u5217\u8868\u5fc5\u987b\u4e25\u683c\u540c\u957f\u540c\u5e8f&#xff0c;\u4e00\u65e6\u6709\u4e00\u5904\u8fc7\u6ee4\u6389\u4e86\u80cc\u666f\u6846\u800c\u53e6\u4e00\u5904\u6ca1\u8fc7\u6ee4&#xff0c;\u5c31\u4f1a\u51fa\u73b0\u300c\u4e0b\u62c9\u6846\u9009\u7b2c 3 \u4e2a&#xff0c;\u753b\u9762\u4e0a\u6846\u7684\u662f\u7b2c 4 \u4e2a\u300d\u7684\u9519\u4f4d\u3002\u8fd9\u4e5f\u662f\u4e3a\u4ec0\u4e48 results.plot() \u548c\u81ea\u5b9a\u4e49\u7ed8\u56fe\u4e24\u6761\u8def\u5f84\u4e0d\u80fd\u6df7\u7528\u2014\u2014\u5b83\u4eec\u7684\u6846\u96c6\u5408\u4e0d\u4e00\u6837\u3002<\/p>\n<hr \/>\n<h3 id=\"_8\">\u4e5d\u3001\u7cfb\u7edf\u90e8\u7f72\u4e0e\u8fd0\u884c\u6b65\u9aa4<\/h3>\n<p>\u5de5\u7a0b\u63d0\u4f9b\u4e86\u4e00\u952e\u5b89\u88c5\u811a\u672c&#xff0c;\u73af\u5883\u914d\u7f6e\u5c31\u4e09\u6b65&#xff1a;<\/p>\n<p># 1) \u5efa Python 3.9 \u73af\u5883<br \/>\nconda create -n py39 python&#061;3.9<br \/>\nconda activate py39<\/p>\n<p># 2) \u8fdb\u5165\u9879\u76ee\u6839\u76ee\u5f55\u540e\u5b89\u88c5\u4f9d\u8d56&#xff08;\u4e8c\u9009\u4e00&#xff09;<br \/>\npython installPackages.py<br \/>\n# \u6216<br \/>\npip install -r requirements.txt -i https:\/\/pypi.tuna.tsinghua.edu.cn\/simple<\/p>\n<p># 3) \u542f\u52a8&#xff08;\u5fc5\u987b\u5728\u9879\u76ee\u6839\u76ee\u5f55&#xff0c;\u5426\u5219\u627e\u4e0d\u5230 Font\/ \u4e0e models\/&#xff09;<br \/>\npython MainProgram.py<\/p>\n<p>\u5173\u952e\u4f9d\u8d56\u7248\u672c&#xff08;requirements.txt \u5171 31 \u9879&#xff0c;\u8282\u9009&#xff09;&#xff1a;<\/p>\n<table>\n<tr>\u4f9d\u8d56\u7248\u672c<\/tr>\n<tbody>\n<tr>\n<td>ultralytics<\/td>\n<td>8.0.199<\/td>\n<\/tr>\n<tr>\n<td>torch<\/td>\n<td>1.9.0<\/td>\n<\/tr>\n<tr>\n<td>opencv-python<\/td>\n<td>4.8.1.78<\/td>\n<\/tr>\n<tr>\n<td>PyQt5<\/td>\n<td>5.15.2<\/td>\n<\/tr>\n<tr>\n<td>pyqt5-tools<\/td>\n<td>5.15.2.3.1<\/td>\n<\/tr>\n<tr>\n<td>matplotlib<\/td>\n<td>3.8.0<\/td>\n<\/tr>\n<tr>\n<td>numpy<\/td>\n<td>1.26.1<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5b8c\u6574\u7684\u8fc1\u79fb\u6e05\u5355&#xff08;\u6362\u4e00\u53f0\u673a\u5668\u7167\u8fd9\u4e2a\u987a\u5e8f\u505a&#xff0c;\u57fa\u672c\u4e0d\u4f1a\u5361&#xff09;&#xff1a;<\/p>\n<li>\u6539 datasets\/helmetData\/data.yaml \u7684\u4e09\u4e2a\u8def\u5f84\u4e3a\u4f60\u672c\u673a\u8def\u5f84\u3002<\/li>\n<li>\u786e\u8ba4 models\/best.pt \u5b58\u5728&#xff08;\u7ea6 5.95 MB&#xff09;&#xff0c;\u4e0d\u5b58\u5728\u5c31\u53bb runs\/detect\/train*\/weights\/ \u91cc\u53d6\u3002<\/li>\n<li>\u786e\u8ba4 Font\/platech.ttf \u5b58\u5728\u3002<\/li>\n<li>\u786e\u8ba4 UIProgram\/style.css \u4e0e ui_imgs\/ \u8d44\u6e90\u5b8c\u6574&#xff0c;\u5426\u5219\u754c\u9762\u4f1a\u53d8\u6210\u65e0\u6837\u5f0f\u7684\u7070\u767d\u63a7\u4ef6\u5806\u3002<\/li>\n<li>\u88c5\u4f9d\u8d56 \u2192 \u6839\u76ee\u5f55\u542f\u52a8 python MainProgram.py\u3002<\/li>\n<li>\u7528 TestFiles\/test.jpg \u8d70\u4e00\u6b21\u5168\u6d41\u7a0b&#xff0c;\u786e\u8ba4\u80fd\u51fa\u6846\u3001\u80fd\u5b58\u56fe\u3001\u8868\u683c\u6709\u6570\u636e\u3002<\/li>\n<hr \/>\n<h3 id=\"_9\">\u5341\u3001\u5e38\u89c1\u62a5\u9519\u4e0e\u6392\u67e5<\/h3>\n<p>\u90e8\u7f72\u9636\u6bb5\u6700\u5bb9\u6613\u5361\u4f4f\u7684\u51e0\u4e2a\u70b9&#xff08;\u90fd\u662f\u8fd9\u4e2a\u5de5\u7a0b\u91cc\u771f\u5b9e\u5b58\u5728\u7684&#xff09;&#xff1a;<\/p>\n<li>Dataset not found&#xff1a;data.yaml \u8fd8\u662f\u4f5c\u8005\u672c\u673a\u7684 F:\\\\Mlwork\\\\&#8230; \u8def\u5f84\u3002\u6539\u8def\u5f84&#xff0c;\u6216\u8005\u6539\u7528 path &#043; \u76f8\u5bf9\u8def\u5f84\u5199\u6cd5\u3002<\/li>\n<li>\u8def\u5f84\u4e0d\u8981\u6709\u4e2d\u6587&#xff1a;\u7a0b\u5e8f\u8fd0\u884c\u8bf4\u660e\u6587\u6863.txt \u5f00\u5934\u5c31\u5199\u4e86\u8fd9\u4e00\u6761\u3002OpenCV \u7684 imread\/imwrite \u5bf9\u4e2d\u6587\u8def\u5f84\u4e0d\u53cb\u597d&#xff0c;\u9879\u76ee\u91cc\u56e0\u6b64\u5c01\u88c5\u4e86 tools.img_cvread \u7528 np.fromfile &#043; cv2.imdecode \u7ed5\u5f00&#xff1b;\u4f46\u4f60\u81ea\u5df1\u5199\u7684\u811a\u672c\u91cc\u5982\u679c\u76f4\u63a5 cv2.imread \u5c31\u4f1a\u9759\u9ed8\u8fd4\u56de None&#xff0c;\u63a5\u7740\u5728 cv2.resize \u5904\u70b8\u51fa Assertion failed !ssize.empty()\u2014\u2014\u8fd9\u4e2a\u62a5\u9519\u7684\u7b2c\u4e00\u5acc\u7591\u6c38\u8fdc\u662f\u300c\u8def\u5f84\u542b\u4e2d\u6587\u300d\u6216\u300c\u6587\u4ef6\u6839\u672c\u4e0d\u5b58\u5728\u300d\u3002<\/li>\n<li>ModuleNotFoundError: No module named &#039;PIL&#039;&#xff1a;requirements.txt \u6ca1\u6709\u5217 pillow&#xff0c;\u4f46\u4e3b\u7a0b\u5e8f from PIL import ImageFont&#xff0c;\u8865 pip install pillow \u5373\u53ef\u3002<\/li>\n<li>torch.cuda.is_available() \u4e00\u76f4\u662f False&#xff1a;\u6e05\u5355\u91cc\u662f torch&#061;&#061;1.9.0&#xff08;CPU \u7248&#xff09;&#xff0c;\u60f3\u7528 GPU \u5fc5\u987b\u6362\u6210\u5bf9\u5e94 CUDA \u7684\u53d1\u884c\u5305&#xff0c;\u5426\u5219\u89c6\u9891\u63a8\u7406\u53ea\u6709\u4e2a\u4f4d\u6570 FPS\u3002<\/li>\n<li>OSError: cannot open resource&#xff1a;Font\/platech.ttf \u627e\u4e0d\u5230&#xff0c;\u901a\u5e38\u662f\u6ca1\u5728\u9879\u76ee\u6839\u76ee\u5f55\u542f\u52a8\u3002<\/li>\n<li>\u6444\u50cf\u5934\u6253\u4e0d\u5f00&#xff08;cap.isOpened() \u4e3a False&#xff09;&#xff1a;\u88ab\u5fae\u4fe1\/\u9489\u9489\/\u817e\u8baf\u4f1a\u8bae\u5360\u7528&#xff0c;\u5173\u6389\u5b83\u4eec\u518d\u8bd5&#xff1b;\u7b14\u8bb0\u672c\u4e0a\u8fd8\u8981\u68c0\u67e5\u7cfb\u7edf\u9690\u79c1\u8bbe\u7f6e\u91cc\u300c\u6444\u50cf\u5934\u8bbf\u95ee\u300d\u662f\u5426\u5141\u8bb8\u3002<\/li>\n<li>\u6444\u50cf\u5934\u68c0\u6d4b\u7ed3\u679c\u4e0d\u80fd\u4fdd\u5b58&#xff1a;\u4ee3\u7801\u91cc\u5bf9\u6444\u50cf\u5934\u753b\u9762\u505a\u4e86\u663e\u5f0f\u62e6\u622a\u5e76\u63d0\u793a\u300c\u6444\u50cf\u5934\u89c6\u9891\u65e0\u6cd5\u4fdd\u5b58\u300d&#xff0c;\u8fd9\u662f\u8bbe\u8ba1\u7ea6\u675f&#xff0c;\u4e0d\u662f bug\u3002<\/li>\n<li>\u4fdd\u5b58\u89c6\u9891\u8017\u65f6\u8f83\u957f&#xff1a;\u56e0\u4e3a\u5b83\u662f\u7528\u72ec\u7acb\u7ebf\u7a0b\u628a\u89c6\u9891\u91cd\u65b0\u63a8\u7406\u4e00\u904d\u518d\u5199\u6587\u4ef6&#xff0c;\u4e0d\u662f\u7b80\u5355\u5f55\u5c4f\u3002\u8fd9\u6837\u505a\u7684\u4ee3\u4ef7\u662f\u4e24\u500d\u63a8\u7406\u65f6\u95f4&#xff0c;\u6536\u76ca\u662f\u7ed3\u679c\u5e27\u5b8c\u6574\u3001\u4e0d\u4f1a\u88ab UI \u5237\u65b0\u4e22\u5e27\u3002<\/li>\n<li>\u754c\u9762\u80fd\u51fa\u6846\u4f46\u6807\u7b7e\u662f\u65b9\u5757&#xff1a;\u4e2d\u6587\u5b57\u4f53\u6ca1\u52a0\u8f7d\u6210\u529f&#xff0c;\u68c0\u67e5 platech.ttf \u8def\u5f84&#xff0c;\u6216\u6539\u7528 cv2AddChineseText \u91cc\u7684 simsun.ttc\u3002<\/li>\n<p>\u5751\u70b9\u63d0\u9192 4&#xff1a;models\/best.pt \u4e0e runs\/detect\/train2\u3001train4\u3001train5\/weights\/best.pt \u7684\u5b57\u8282\u6570\u5b8c\u5168\u4e00\u81f4&#xff08;\u5747\u4e3a 6240025 \u5b57\u8282&#xff09;\u3002\u8fd9\u8bf4\u660e models\/ \u4e0b\u90a3\u4efd\u662f\u590d\u5236\u800c\u6765\u7684\u526f\u672c&#xff0c;\u4f46\u4ece\u6587\u4ef6\u672c\u8eab\u770b\u4e0d\u51fa\u662f\u54ea\u4e00\u6b21\u8bad\u7ec3\u7684\u4ea7\u7269\u3002\u4e09\u6b21\u8bad\u7ec3\u7684\u6700\u4f73 mAP&#064;0.5 \u5206\u522b\u662f 0.93273 \/ 0.92972 \/ 0.80050&#xff0c;\u5dee\u522b\u4e0d\u5c0f&#xff0c;\u5199\u8bba\u6587\u65f6\u5fc5\u987b\u5148\u8dd1\u4e00\u6b21 model.val() \u53cd\u67e5&#xff0c;\u4e0d\u80fd\u9ed8\u8ba4 models\/best.pt \u5c31\u662f\u6700\u597d\u7684\u90a3\u6b21\u3002<\/p>\n<hr \/>\n<h3 id=\"_10\">\u5341\u4e00\u3001\u68c0\u6d4b\u6548\u679c\u5c55\u793a\u4e0e\u5206\u6790<\/h3>\n<p>\u5355\u76ee\u6807\u573a\u666f\u4e0b&#xff0c;\u6a21\u578b\u5bf9\u300c\u4eba &#043; \u5934\u9876\u5b89\u5168\u5e3d\u300d\u7684\u7ec4\u5408\u6846\u5f97\u5f88\u7d27&#xff0c;\u6807\u7b7e\u4e0e\u7f6e\u4fe1\u5ea6\u4e5f\u6e05\u6670&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"703\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261118184844-6afdf30c563fd.jpg\" width=\"1045\" \/><\/p>\n<p>\u56fe 10 \u5355\u56fe\u68c0\u6d4b\u6548\u679c 2<\/p>\n<p>\u591a\u4eba\u573a\u666f\u624d\u662f\u771f\u5b9e\u8003\u9a8c\u3002\u4e0b\u56fe\u540c\u4e00\u753b\u9762\u91cc\u51fa\u73b0\u591a\u4e2a\u5de5\u4eba&#xff0c;\u6a21\u578b\u7684\u53d6\u820d\u5f88\u80fd\u8bf4\u660e\u95ee\u9898&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"533\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261118184844-6afdf30c98e74.jpg\" width=\"800\" \/><\/p>\n<p>\u56fe 11 \u591a\u4eba\u573a\u666f\u68c0\u6d4b\u6548\u679c<\/p>\n<p>\u4ece\u8fd9\u4e09\u5f20\u5b9e\u9645\u8f93\u51fa\u53ef\u4ee5\u5f52\u7eb3\u51fa\u51e0\u6761\u89c4\u5f8b&#xff08;\u90fd\u662f\u8089\u773c\u53ef\u6838\u5bf9\u7684&#xff0c;\u4e0d\u542b\u63a8\u65ad\u6027\u7684\u7cbe\u5ea6\u58f0\u660e&#xff09;&#xff1a;<\/p>\n<ul>\n<li>\u8fd1\u666f\u5927\u76ee\u6807\u51e0\u4e4e\u4e0d\u6f0f&#xff1a;\u5360\u753b\u9762 1\/4 \u4ee5\u4e0a\u7684\u4eba\u4e0e\u5e3d&#xff0c;\u6846\u90fd\u7a33\u5b9a&#xff0c;\u7f6e\u4fe1\u5ea6\u4e5f\u9ad8\u3002<\/li>\n<li>\u8fdc\u666f\u5c0f\u76ee\u6807\u662f\u4e3b\u8981\u77ed\u677f&#xff1a;\u7ad9\u5728\u753b\u9762\u6df1\u5904\u7684\u4eba&#xff0c;\u5e3d\u5b50\u7684\u50cf\u7d20\u9762\u79ef\u5c0f&#xff0c;\u5076\u5c14\u53ea\u6846\u5230\u4eba\u4e0d\u6846\u5230\u5e3d&#xff0c;\u6216\u8005\u5e3d\u5b50\u6846\u504f\u5c0f\u3002\u8fd9\u4e0e mAP&#064;0.5-0.95 \u53ea\u6709 0.60 \u5de6\u53f3\u662f\u540c\u4e00\u4e2a\u95ee\u9898\u7684\u4e24\u79cd\u8868\u73b0\u2014\u2014\u9608\u503c 0.5 \u65f6\u7b97\u5bf9&#xff0c;\u6846\u5f97\u4e0d\u591f\u7d27\u5c31\u6389\u5230 0.5 \u4ee5\u4e0b\u3002<\/li>\n<li>\u5bc6\u96c6\u906e\u6321\u4f1a\u5408\u5e76\u6846&#xff1a;\u4eba\u6324\u4eba\u65f6 NMS \u66f4\u5bb9\u6613\u628a\u76f8\u90bb\u4e24\u4e2a\u4eba\u6291\u5236\u6210\u4e00\u4e2a\u6846&#xff0c;\u8fd9\u662f\u540e\u5904\u7406\u53c2\u6570\u95ee\u9898&#xff0c;\u4e0d\u662f\u6a21\u578b\u6ca1\u5b66\u5230\u3002<\/li>\n<li>\u9006\u5149\u4e0e\u591c\u95f4\u672a\u8986\u76d6&#xff1a;\u5de5\u7a0b\u81ea\u5e26\u6d4b\u8bd5\u56fe\u90fd\u662f\u767d\u5929\u573a\u666f&#xff0c;\u591c\u95f4\/\u9006\u5149\u6548\u679c\u65e0\u6cd5\u4ece\u73b0\u6709\u6750\u6599\u5224\u65ad&#xff08;\u5f85\u8865\u5145\u5b9e\u6d4b&#xff09;\u3002<\/li>\n<\/ul>\n<p>\u4e00\u4e2a\u5fc5\u987b\u5f3a\u8c03\u7684\u8ba4\u77e5&#xff1a;\u8fd9\u4e9b\u622a\u56fe\u662f\u300c\u6311\u9009\u8fc7\u7684\u6210\u529f\u6848\u4f8b\u300d&#xff0c;\u4e0d\u80fd\u53cd\u63a8\u6574\u4f53\u7cbe\u5ea6\u3002\u8981\u7ed9\u51fa\u53ef\u4fe1\u7684\u6548\u679c\u5206\u6790&#xff0c;\u5f97\u5728\u9a8c\u8bc1\u96c6 763 \u5f20\u4e0a\u7edf\u8ba1\u6f0f\u68c0\/\u8bef\u68c0\u5206\u5e03&#xff0c;\u800c\u5de5\u7a0b\u91cc\u6ca1\u6709\u7559\u5b58\u8fd9\u7c7b\u7edf\u8ba1\u3002\u8fd9\u4e5f\u662f\u7b2c\u516b\u8282\u300c\u8981\u70b9\u603b\u7ed3\u300d\u91cc\u53cd\u590d\u8bf4\u7684\u90a3\u53e5\u2014\u2014\u65e5\u5fd7\u6307\u6807 \u2260 \u6a21\u578b\u6307\u6807 \u2260 \u771f\u5b9e\u573a\u666f\u8868\u73b0&#xff0c;\u4e09\u8005\u8981\u5206\u5f00\u5f15\u7528\u3002<\/p>\n<hr \/>\n<h3 id=\"_11\">\u5341\u4e8c\u3001\u53ef\u4f18\u5316\u65b9\u5411<\/h3>\n<p>\u6309\u300c\u6295\u5165\u4ea7\u51fa\u6bd4\u300d\u4ece\u9ad8\u5230\u4f4e\u6392&#xff0c;\u7ed9\u540e\u7eed\u63a5\u624b\u7684\u4eba\u4e00\u4efd\u65bd\u5de5\u56fe&#xff1a;<\/p>\n<li>\u8865\u9f50\u300c\u672a\u6234\u5b89\u5168\u5e3d\u300d\u5224\u5b9a\u903b\u8f91&#xff08;\u4e1a\u52a1\u4ef7\u503c\u6700\u9ad8&#xff09;\u3002\u73b0\u5728\u7cfb\u7edf\u53ea\u80fd\u544a\u8bc9\u4f60\u300c\u8fd9\u91cc\u6709\u4eba\u3001\u8fd9\u91cc\u6709\u4e00\u9876\u5e3d\u5b50\u300d&#xff0c;\u4e0d\u80fd\u76f4\u63a5\u8f93\u51fa\u300c\u8fd9\u4e2a\u4eba\u6ca1\u6234\u300d\u3002\u505a\u6cd5&#xff1a;\u5bf9\u6bcf\u4e2a person \u6846\u53d6\u4e0a\u90e8 1\/3 \u4f5c\u4e3a\u5934\u90e8\u533a\u57df&#xff0c;\u5224\u65ad\u8be5\u533a\u57df\u5185\u662f\u5426\u5b58\u5728 hat \u6846\u4e14 IoU \u8fbe\u6807&#xff0c;\u4e0d\u8fbe\u6807\u5373\u5224\u672a\u6234&#xff1b;\u754c\u9762\u4e0a\u7528\u7ea2\u8272\u6846\u5355\u72ec\u6807\u51fa\u3002\u8fd9\u4e00\u6b65\u4e0d\u9700\u8981\u91cd\u8bad\u6a21\u578b&#xff0c;\u7eaf\u540e\u5904\u7406\u5c31\u80fd\u628a\u7cfb\u7edf\u4ece\u300c\u68c0\u6d4b\u73a9\u5177\u300d\u53d8\u6210\u300c\u5b89\u5168\u5de5\u5177\u300d\u3002<\/li>\n<li>\u628a conf \u4e0e imgsz \u66b4\u9732\u5230\u754c\u9762\u3002conf \u51b3\u5b9a\u8bef\u62a5\/\u6f0f\u62a5\u7684\u53d6\u820d&#xff08;\u53c2\u8003 F1 \u66f2\u7ebf\u5cf0\u503c&#xff09;&#xff0c;imgsz \u63d0\u5230 800 \u80fd\u660e\u663e\u6539\u5584\u5c0f\u76ee\u6807&#xff1b;\u4e24\u8005\u505a\u6210\u914d\u7f6e\u9879\u653e\u8fdb settings \u6216 Config.py&#xff0c;\u73b0\u573a\u4eba\u5458\u81ea\u5df1\u5c31\u80fd\u8c03\u3002<\/li>\n<li>\u8865\u591c\u95f4\u4e0e\u9006\u5149\u6570\u636e\u3002\u8fd9\u662f mAP \u5361\u5728 0.93 \u4e0a\u4e0d\u53bb\u7684\u6839\u672c\u539f\u56e0&#xff0c;\u6bd4\u8c03\u5b66\u4e60\u7387\u6709\u7528\u4e00\u767e\u500d\u3002<\/li>\n<li>\u52a0\u8ddf\u8e2a&#xff08;ByteTrack\/BoT-SORT&#xff09;\u3002\u89c6\u9891\u91cc\u9010\u5e27\u72ec\u7acb\u68c0\u6d4b\u4f1a\u51fa\u73b0\u6846\u95ea\u70c1\u3001ID \u8df3\u53d8&#xff1b;\u63a5\u4e0a\u8ddf\u8e2a\u540e\u53ef\u4ee5\u7a33\u5b9a\u7edf\u8ba1\u300c\u67d0\u533a\u57df\u7d2f\u8ba1\u591a\u5c11\u4eba\u672a\u6234\u300d&#xff0c;\u8fd9\u662f\u771f\u6b63\u7684\u7ba1\u7406\u6307\u6807\u3002<\/li>\n<li>\u6743\u91cd\u4e0e\u6307\u6807\u53e3\u5f84\u7edf\u4e00\u3002\u8dd1\u4e00\u6b21 model.val() \u62ff\u5230 models\/best.pt \u7684\u771f\u5b9e\u6307\u6807\u5e76\u5199\u8fdb README&#xff0c;\u628a\u300c\u65e5\u5fd7\u672b\u8f6e\u503c\u300d\u4e0e\u300c\u4ea4\u4ed8\u6a21\u578b\u503c\u300d\u5206\u5f00\u5217&#xff0c;\u4ea4\u4ed8\u6587\u6863\u7684\u53ef\u4fe1\u5ea6\u4f1a\u5b8c\u5168\u4e0d\u540c\u3002<\/li>\n<li>\u6a21\u578b\u8f7b\u91cf\u5316\u5bfc\u51fa\u3002train.py \u91cc\u5df2\u7ecf\u6ce8\u91ca\u6389 model.export(format&#061;&#039;onnx&#039;)&#xff0c;\u6253\u5f00\u5b83\u5bfc ONNX&#xff0c;\u518d\u7528 onnxruntime \u63a8\u7406&#xff0c;CPU \u4e0a\u901a\u5e38\u80fd\u62ff\u5230\u6bd4 PyTorch \u660e\u663e\u66f4\u4f4e\u7684\u5ef6\u8fdf&#xff08;\u5177\u4f53\u52a0\u901f\u6bd4\u9700\u5b9e\u6d4b&#xff0c;\u5de5\u7a0b\u5185\u65e0\u8bb0\u5f55&#xff0c;\u5f85\u8865\u5145&#xff09;\u3002<\/li>\n<hr \/>\n<h3 id=\"_12\">\u5341\u4e09\u3001\u76ee\u5f55\u7ed3\u6784<\/h3>\n<p>YOLOv8hat-helmet\/<br \/>\n\u251c\u2500\u2500 MainProgram.py            # \u4e3b\u7a0b\u5e8f&#xff1a;\u754c\u9762\u903b\u8f91 &#043; \u68c0\u6d4b\u8c03\u5ea6 &#043; \u7ed3\u679c\u4fdd\u5b58<br \/>\n\u251c\u2500\u2500 Config.py                 # \u6a21\u578b\u8def\u5f84 \/ \u4fdd\u5b58\u76ee\u5f55 \/ \u4e2d\u82f1\u6587\u7c7b\u540d<br \/>\n\u251c\u2500\u2500 train.py                  # YOLOv8n \u8bad\u7ec3\u811a\u672c<br \/>\n\u251c\u2500\u2500 detect_tools.py           # \u753b\u6846\u3001\u4e2d\u6587\u6e32\u67d3\u3001\u5750\u6807\u8f6c\u6362\u3001\u89c6\u9891\u5199\u51fa<br \/>\n\u251c\u2500\u2500 installPackages.py        # \u4e00\u952e\u88c5\u4f9d\u8d56<br \/>\n\u251c\u2500\u2500 requirements.txt          # 31 \u9879\u4f9d\u8d56<br \/>\n\u251c\u2500\u2500 datasets\/helmetData\/      # \u6570\u636e\u96c6&#xff08;train\/valid\/test &#043; data.yaml&#xff09;<br \/>\n\u251c\u2500\u2500 models\/best.pt            # \u7cfb\u7edf\u9ed8\u8ba4\u6743\u91cd&#xff08;\u7ea6 5.95 MB&#xff09;<br \/>\n\u251c\u2500\u2500 UIProgram\/                # \u754c\u9762\u4ee3\u7801\u3001QSS\u3001\u56fe\u6807\u8d44\u6e90<br \/>\n\u251c\u2500\u2500 Font\/platech.ttf          # \u4e2d\u6587\u7ed8\u5236\u5b57\u4f53<br \/>\n\u251c\u2500\u2500 TestFiles\/                # \u6d4b\u8bd5\u56fe\u7247\u4e0e\u6d4b\u8bd5\u89c6\u9891<br \/>\n\u251c\u2500\u2500 save_data\/                # \u68c0\u6d4b\u7ed3\u679c\u8f93\u51fa\u76ee\u5f55<br \/>\n\u2514\u2500\u2500 runs\/detect\/              # \u8bad\u7ec3\u8f93\u51fa&#xff08;train2 \/ train4 \/ train5 \u4fdd\u7559\u6709 results.csv \u4e0e args.yaml&#xff09;<\/p>\n<hr \/>\n<h3 id=\"_13\">\u5341\u56db\u3001\u8981\u70b9\u603b\u7ed3<\/h3>\n<li>\u7c7b\u522b\u540d\u5fc5\u987b\u4e09\u5904\u5bf9\u9f50&#xff1a;data.yaml \u7684 names\u3001Config.names\u3001Config.CH_names&#xff0c;\u987a\u5e8f\u9519\u4e86\u754c\u9762\u5c31\u4f1a\u5f20\u51a0\u674e\u6234\u3002<\/li>\n<li>\u6570\u636e yaml \u7528\u7edd\u5bf9\u8def\u5f84\u662f\u6700\u5927\u7684\u8fc1\u79fb\u969c\u788d&#xff0c;\u5efa\u8bae\u6539\u6210 path &#043; \u76f8\u5bf9\u8def\u5f84\u7684\u5199\u6cd5\u3002<\/li>\n<li>\u6279\u91cf\u5c0f\u3001patience \u5927\u662f\u8fd9\u5957\u8bad\u7ec3\u53c2\u6570\u7684\u663e\u8457\u7279\u5f81&#xff1a;batch&#061;4 \u8bf4\u660e\u663e\u5b58\u53d7\u9650&#xff0c;patience&#061;300 &gt; epochs&#061;150 \u8bf4\u660e\u65e9\u505c\u5f62\u540c\u865a\u8bbe&#xff1b;\u800c train2 \u90a3\u6b21\u662f batch&#061;32 \/ patience&#061;50&#xff0c;\u522b\u628a\u4e24\u6b21\u7684\u914d\u7f6e\u6df7\u7740\u5f15\u7528\u3002<\/li>\n<li>\u6536\u655b\u5feb\u7684\u529f\u52b3\u5927\u534a\u5728\u9884\u8bad\u7ec3\u6743\u91cd&#xff1a;\u7b2c 1 \u8f6e mAP&#064;0.5 \u5c31 0.66489&#xff0c;\u7b2c 25 \u8f6e\u5df2 0.89816&#xff0c;\u540e 150 \u8f6e\u53ea\u63d0\u5347\u7ea6 3 \u4e2a\u767e\u5206\u70b9\u3002\u60f3\u518d\u5f80\u4e0a\u5fc5\u987b\u9760\u6570\u636e&#xff0c;\u4e0d\u662f\u9760\u8f6e\u6570\u3002<\/li>\n<li>\u770b\u4e09\u9879\u635f\u5931\u5206\u5de5&#xff1a;box \u7ba1\u5b9a\u4f4d\u3001cls \u7ba1\u5206\u7c7b\u3001dfl \u7ba1\u8fb9\u754c\u7cbe\u5ea6&#xff0c;\u8bad\u7ec3\u964d\u800c\u9a8c\u8bc1\u4e0d\u964d\u5c31\u662f\u8fc7\u62df\u5408\u7684\u5f00\u59cb\u3002<\/li>\n<li>\u65e5\u5fd7\u6307\u6807 \u2260 \u6a21\u578b\u6307\u6807\u3002runs\/*\/results.csv \u53ea\u662f\u8bad\u7ec3\u8bb0\u5f55&#xff0c;models\/best.pt \u7684\u771f\u5b9e\u7cbe\u5ea6\u5fc5\u987b\u81ea\u5df1 model.val() \u8dd1\u4e00\u904d&#xff0c;\u522b\u76f4\u63a5\u6284 csv\u3002<\/li>\n<li>\u89c6\u9891\u68c0\u6d4b\u7528 QTimer \u800c\u4e0d\u662f while \u5faa\u73af&#xff0c;\u662f PyQt \u505a\u5b9e\u65f6\u753b\u9762\u5237\u65b0\u7684\u6807\u51c6\u5957\u8def&#xff1b;\u4fdd\u5b58\u89c6\u9891\u518d\u5f00 QThread \u4e8c\u6b21\u63a8\u7406&#xff0c;\u624d\u80fd\u517c\u987e\u754c\u9762\u6d41\u7545\u548c\u5199\u76d8\u5b8c\u6574\u3002<\/li>\n<li>\u4e2d\u6587\u663e\u793a\u9760\u5b57\u4f53\u6587\u4ef6&#xff1a;cv2.putText \u53ea\u652f\u6301 ASCII&#xff0c;\u7528 PIL &#043; platech.ttf \u6e32\u67d3\u518d\u8f6c\u56de OpenCV \u56fe\u50cf&#xff0c;\u662f\u8fd9\u7c7b\u4e2d\u6587\u754c\u9762\u5de5\u7a0b\u7684\u901a\u7528\u89e3\u6cd5\u3002<\/li>\n<li>\u5de5\u7a0b\u91cc\u786e\u5b9e\u7f3a\u7684\u4e1c\u897f\u8981\u7167\u5b9e\u8bf4&#xff1a;\u663e\u5361\u578b\u53f7\u3001CUDA \u7248\u672c\u3001\u5355\u8f6e\u8017\u65f6\u3001models\/best.pt \u7684\u72ec\u7acb\u8bc4\u6d4b\u7cbe\u5ea6\u3001\u591c\u95f4\u573a\u666f\u5b9e\u6d4b&#xff0c;\u5168\u90e8&#xff08;\u5f85\u8865\u5145&#xff09;\u3002\u8bda\u5b9e\u6807\u6ce8\u6bd4\u7f16\u4e00\u4e2a\u6f02\u4eae\u6570\u5b57\u6709\u4ef7\u503c\u5f97\u591a\u3002<\/li>\n<p>            <span id=\"quality-guide-article-end\" aria-hidden=\"true\" style=\"display:block;height:1px;margin-bottom:-1px\"><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u505a\u5b89\u5168\u5e3d\u68c0\u6d4b\u7684\u7ec3\u624b\u9879\u76ee\u5f88\u591a&#xff0c;\u4f46\u5927\u591a\u6570\u53ea\u7ed9\u4e00\u4e2a train.py \u548c\u4e00\u4e2a detect.py&#xff0c;\u771f\u6b63\u628a\u5b83\u505a\u6210\u300c\u80fd\u70b9\u3001\u80fd\u5b58\u3001\u80fd\u770b\u300d\u7684\u684c\u9762\u8f6f\u4ef6\u7684\u8d44\u6599\u5e76\u4e0d\u591a\u3002\u8fd9\u7bc7\u6587\u7ae0\u6309\u5de5\u7a0b\u771f\u5b9e\u7684\u6587\u4ef6\u987a\u5e8f\u5f80\u4e0b\u62c6&#xff1a;\u5148\u8bb2\u6e05\u695a\u8fd9\u4e2a\u4efb\u52a1\u5230\u5e95\u96be\u5728\u54ea\u3001\u65b9\u6848\u4e3a\u4ec0\u4e48\u8fd9\u4e48\u5206\u5c42&#xff0c;\u518d\u628a YOLOv8 \u7684\u7f51\u7edc\u7ed3\u6784\u4e0e\u635f\u5931\u8bb2\u900f&#xff0c;\u7136\u540e\u662f\u6570\u636e\u96c6\u7ec4\u7ec7\u3001\u8bad\u7ec3\u8d85\u53c2\u3001\u8bad\u7ec3\u65e5\u5fd7\u91cc\u90a3\u6761\u66f2\u7ebf\u5230\u5e95\u8bf4\u660e\u4e86\u4ec0\u4e48&#xff0c;\u63a5\u7740\u9010\u6bb5\u8bfb\u6838\u5fc3\u4ee3\u7801&#xff0c;\u6700\u540e\u7ed9\u51fa\u90e8\u7f72\u6b65\u9aa4\u3001\u5e38\u89c1\u62a5\u9519<\/p>\n","protected":false},"author":2,"featured_media":124497,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[156,50,3829],"topic":[],"class_list":["post-124508","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-yolo","tag-50","tag-3829"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u4ece\u96f6\u62c6\u89e3\u4e00\u4e2a YOLOv8 \u5b89\u5168\u5e3d\u68c0\u6d4b\u7cfb\u7edf\uff1a\u6a21\u578b\u8bad\u7ec3 + PyQt5 \u684c\u9762\u7aef\u7684\u5b8c\u6574\u5de5\u7a0b\u7ed3\u6784 - \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\/124508.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u4ece\u96f6\u62c6\u89e3\u4e00\u4e2a YOLOv8 \u5b89\u5168\u5e3d\u68c0\u6d4b\u7cfb\u7edf\uff1a\u6a21\u578b\u8bad\u7ec3 + PyQt5 \u684c\u9762\u7aef\u7684\u5b8c\u6574\u5de5\u7a0b\u7ed3\u6784 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u505a\u5b89\u5168\u5e3d\u68c0\u6d4b\u7684\u7ec3\u624b\u9879\u76ee\u5f88\u591a&#xff0c;\u4f46\u5927\u591a\u6570\u53ea\u7ed9\u4e00\u4e2a train.py \u548c\u4e00\u4e2a detect.py&#xff0c;\u771f\u6b63\u628a\u5b83\u505a\u6210\u300c\u80fd\u70b9\u3001\u80fd\u5b58\u3001\u80fd\u770b\u300d\u7684\u684c\u9762\u8f6f\u4ef6\u7684\u8d44\u6599\u5e76\u4e0d\u591a\u3002\u8fd9\u7bc7\u6587\u7ae0\u6309\u5de5\u7a0b\u771f\u5b9e\u7684\u6587\u4ef6\u987a\u5e8f\u5f80\u4e0b\u62c6&#xff1a;\u5148\u8bb2\u6e05\u695a\u8fd9\u4e2a\u4efb\u52a1\u5230\u5e95\u96be\u5728\u54ea\u3001\u65b9\u6848\u4e3a\u4ec0\u4e48\u8fd9\u4e48\u5206\u5c42&#xff0c;\u518d\u628a YOLOv8 \u7684\u7f51\u7edc\u7ed3\u6784\u4e0e\u635f\u5931\u8bb2\u900f&#xff0c;\u7136\u540e\u662f\u6570\u636e\u96c6\u7ec4\u7ec7\u3001\u8bad\u7ec3\u8d85\u53c2\u3001\u8bad\u7ec3\u65e5\u5fd7\u91cc\u90a3\u6761\u66f2\u7ebf\u5230\u5e95\u8bf4\u660e\u4e86\u4ec0\u4e48&#xff0c;\u63a5\u7740\u9010\u6bb5\u8bfb\u6838\u5fc3\u4ee3\u7801&#xff0c;\u6700\u540e\u7ed9\u51fa\u90e8\u7f72\u6b65\u9aa4\u3001\u5e38\u89c1\u62a5\u9519\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/124508.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-18T18:48:45+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261118184839-6afdf30716b16.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=\"14 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/124508.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/124508.html\",\"name\":\"\u4ece\u96f6\u62c6\u89e3\u4e00\u4e2a YOLOv8 \u5b89\u5168\u5e3d\u68c0\u6d4b\u7cfb\u7edf\uff1a\u6a21\u578b\u8bad\u7ec3 + PyQt5 \u684c\u9762\u7aef\u7684\u5b8c\u6574\u5de5\u7a0b\u7ed3\u6784 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-11-18T18:48:45+00:00\",\"dateModified\":\"2026-11-18T18:48:45+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/124508.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/124508.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/124508.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4ece\u96f6\u62c6\u89e3\u4e00\u4e2a YOLOv8 \u5b89\u5168\u5e3d\u68c0\u6d4b\u7cfb\u7edf\uff1a\u6a21\u578b\u8bad\u7ec3 + PyQt5 \u684c\u9762\u7aef\u7684\u5b8c\u6574\u5de5\u7a0b\u7ed3\u6784\"}]},{\"@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":"\u4ece\u96f6\u62c6\u89e3\u4e00\u4e2a YOLOv8 \u5b89\u5168\u5e3d\u68c0\u6d4b\u7cfb\u7edf\uff1a\u6a21\u578b\u8bad\u7ec3 + PyQt5 \u684c\u9762\u7aef\u7684\u5b8c\u6574\u5de5\u7a0b\u7ed3\u6784 - \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\/124508.html","og_locale":"zh_CN","og_type":"article","og_title":"\u4ece\u96f6\u62c6\u89e3\u4e00\u4e2a YOLOv8 \u5b89\u5168\u5e3d\u68c0\u6d4b\u7cfb\u7edf\uff1a\u6a21\u578b\u8bad\u7ec3 + PyQt5 \u684c\u9762\u7aef\u7684\u5b8c\u6574\u5de5\u7a0b\u7ed3\u6784 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u505a\u5b89\u5168\u5e3d\u68c0\u6d4b\u7684\u7ec3\u624b\u9879\u76ee\u5f88\u591a&#xff0c;\u4f46\u5927\u591a\u6570\u53ea\u7ed9\u4e00\u4e2a train.py \u548c\u4e00\u4e2a detect.py&#xff0c;\u771f\u6b63\u628a\u5b83\u505a\u6210\u300c\u80fd\u70b9\u3001\u80fd\u5b58\u3001\u80fd\u770b\u300d\u7684\u684c\u9762\u8f6f\u4ef6\u7684\u8d44\u6599\u5e76\u4e0d\u591a\u3002\u8fd9\u7bc7\u6587\u7ae0\u6309\u5de5\u7a0b\u771f\u5b9e\u7684\u6587\u4ef6\u987a\u5e8f\u5f80\u4e0b\u62c6&#xff1a;\u5148\u8bb2\u6e05\u695a\u8fd9\u4e2a\u4efb\u52a1\u5230\u5e95\u96be\u5728\u54ea\u3001\u65b9\u6848\u4e3a\u4ec0\u4e48\u8fd9\u4e48\u5206\u5c42&#xff0c;\u518d\u628a YOLOv8 \u7684\u7f51\u7edc\u7ed3\u6784\u4e0e\u635f\u5931\u8bb2\u900f&#xff0c;\u7136\u540e\u662f\u6570\u636e\u96c6\u7ec4\u7ec7\u3001\u8bad\u7ec3\u8d85\u53c2\u3001\u8bad\u7ec3\u65e5\u5fd7\u91cc\u90a3\u6761\u66f2\u7ebf\u5230\u5e95\u8bf4\u660e\u4e86\u4ec0\u4e48&#xff0c;\u63a5\u7740\u9010\u6bb5\u8bfb\u6838\u5fc3\u4ee3\u7801&#xff0c;\u6700\u540e\u7ed9\u51fa\u90e8\u7f72\u6b65\u9aa4\u3001\u5e38\u89c1\u62a5\u9519","og_url":"https:\/\/www.wsisp.com\/helps\/124508.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-11-18T18:48:45+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261118184839-6afdf30716b16.jpg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"14 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/124508.html","url":"https:\/\/www.wsisp.com\/helps\/124508.html","name":"\u4ece\u96f6\u62c6\u89e3\u4e00\u4e2a YOLOv8 \u5b89\u5168\u5e3d\u68c0\u6d4b\u7cfb\u7edf\uff1a\u6a21\u578b\u8bad\u7ec3 + PyQt5 \u684c\u9762\u7aef\u7684\u5b8c\u6574\u5de5\u7a0b\u7ed3\u6784 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-11-18T18:48:45+00:00","dateModified":"2026-11-18T18:48:45+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/124508.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/124508.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/124508.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u4ece\u96f6\u62c6\u89e3\u4e00\u4e2a YOLOv8 \u5b89\u5168\u5e3d\u68c0\u6d4b\u7cfb\u7edf\uff1a\u6a21\u578b\u8bad\u7ec3 + PyQt5 \u684c\u9762\u7aef\u7684\u5b8c\u6574\u5de5\u7a0b\u7ed3\u6784"}]},{"@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\/124508","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=124508"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/124508\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/124497"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=124508"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=124508"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=124508"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=124508"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}