{"id":617,"date":"2024-02-21T08:00:04","date_gmt":"2024-02-21T00:00:04","guid":{"rendered":"https:\/\/www.zhoubin.asia\/?p=617"},"modified":"2024-02-20T13:51:08","modified_gmt":"2024-02-20T05:51:08","slug":"dfc-2","status":"publish","type":"post","link":"https:\/\/www.zhoubin.asia\/index.php\/2024\/02\/21\/dfc-2\/","title":{"rendered":"[DFC]yolov5\u6a21\u578b\u8f6c\u5316\u4e3ahailo\u91cf\u5316\u6a21\u578b\u7cbe\u5ea6\u4e0b\u964d\u5206\u6790"},"content":{"rendered":"<p>Hailo\u6a21\u578b\u8f6c\u6362\/\u91cf\u5316\u4e00\u822c\u4f1a\u6709\u5c11\u91cf\u7684\u7cbe\u5ea6\u4e0b\u964d\uff0c\u6b63\u5e38mAP\u4e0b\u964d\u57282\u4e2a\u70b9\u4ee5\u5185\uff0c\u5982\u679c\u4e0b\u964d\u592a\u591a\uff0c\u6216\u8005\u662f\u4e3b\u89c2\u67e5\u770b\u7cbe\u5ea6\u5dee\u522b\u6bd4\u8f83\u5927\uff1b\u5927\u90e8\u5206\u60c5\u51b5\u4e0b\u5c31\u662f\u8f6c\u6a21\u578b\u7684\u65f6\u5019\u9057\u6f0f\u4e86\u4e00\u4e9b\u4e1c\u897f\uff1b<\/p>\n<p>\u4e3b\u8981\u53ef\u80fd\u662f\u5982\u4e0b\u51e0\u4e2a\u65b9\u9762\uff1a<\/p>\n<ol>\n<li>\u5f52\u4e00\u5316\u662f\u5728hailo\u505a\u8fd8\u662f\u524d\u5904\u7406\u505a\uff0c\u8bf7\u6ce8\u610f\u4e0d\u8981\u91cd\u590d\u505a\u5f52\u4e00\u5316\u4f8b\u5982\uff1a\u8f6c\u5316\u811a\u672c\u4e2d\u52a0\u5165\u4e86\uff1a<em>normalization1 = normalization([0.0, 0.0, 0.0],[255.0, 255.0, 255.0])<\/em> \u5219\u8868\u660e\u5f52\u4e00\u5316\u662f\u5728hailo\u4e2d\u505a\u7684\uff0c\u90a3\u4e48\u5728\u91cf\u5316\u7684calibration datasets\u7684\u65f6\u5019\u5c31\u4e0d\u8981\u505a\u5f52\u4e00\u5316\uff1a<br \/>\n[python]<br \/>\n<em>calib_dataset[idx,:,:,:] = preproc(img)<\/em><br \/>\n<em>#calib_dataset[idx,:,:,:] = preproc(img)\/255.0<\/em><\/li>\n<li>\u5bf9\u4e8eyolo\u6a21\u578b\uff0c\u524d\u5904\u7406\u662fresize\u8fd8\u662fletter_box(\u5b98\u65b9\u7684github\u4f7f\u7528\u7684\u662fletterbox)? \u6a21\u578b\u91cf\u5316\u7684\u65f6\u5019\u5219\u9700\u8981\u4e0e\u6a21\u578b\u4e00\u81f4\uff0c\u540c\u7406\u5728c++\u505ainference\u4e5f\u9700\u8981\u4e00\u81f4<br \/>\n[python]<br \/>\n<em>def preproc(image, output_height=640, output_width=640):<\/em><br \/>\n<em>\u00a0 \u00a0 #resized_image = tf.image.resize(image, (output_height, output_width), method=&#8217;bicubic&#8217;)<\/em><br \/>\n<em>\u00a0 \u00a0 resized_image, x, y = letterbox_image(image.copy(), (output_height,output_width))<\/em><br \/>\n<em>\u00a0 \u00a0 return resized_image<\/em><br \/>\n[c++]<br \/>\n<em>#ifdef LETTER_BOX<\/em><br \/>\n<em>tmp = Letterbox(oriFrame, _model_height, ratio, 144);<\/em><br \/>\n<em>#else<\/em><br \/>\n<em>cv::resize( oriFrame, tmp, cv::Size(_model_width, _model_height));<\/em><br \/>\n<em>#endif<\/em><\/li>\n<li>\u6a21\u578b\u91cf\u5316\u4ee5\u53ca\u505ainference\u7684\u65f6\u5019\uff0c\u5904\u7406\u56fe\u50cf\u7684\u683c\u5f0f\u662fRGB\u8fd8\u662fBGR? \u540c\u6837\u4e5f\u8981\u4fdd\u6301\u6b63\u786e\u4ee5\u53ca\u4e00\u81f4\u3002\u6a21\u578b\u4e00\u822c\u9ed8\u8ba4\u4f7f\u7528RGB\u683c\u5f0f\uff0c\u4f46\u662fc++\u4f7f\u7528opencv\u5904\u7406\u65f6\uff0c\u9ed8\u8ba4\u683c\u5f0f\u662fBGR\uff0c\u9700\u8981\u8fdb\u884c\u8f6c\u5316\u4e0b<em>cv::cvtColor(tmp, outFrame, cv::COLOR_BGR2RGB);<\/em><\/li>\n<li>\u6a21\u578b\u8f6c\u6362\u7684\u65f6\u5019\uff0c\u662f\u5426\u6709\u5c06\u6700\u540e\u8f93\u51fasigmoid\u653e\u5165\u5230hailo\u4e2d\u8fdb\u884c\u5904\u7406<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-619\" src=\"https:\/\/www.zhoubin.asia\/wp-content\/uploads\/2024\/02\/Capture-1.jpg\" alt=\"\" width=\"1037\" height=\"926\" \/><br \/>\n<em>change_output_activation(sigmoid)<\/em><br \/>\n\u5c06sigmoid\u653e\u5165hailo\u4e2d\u5904\u7406\u5e76\u4e14\u4e00\u8d77\u8fdb\u884c\u91cf\u5316\u7684\u8bdd\uff0c\u53ef\u4ee5\u6709\u6548\u7684\u63d0\u9ad8\u6574\u4e2a\u91cf\u5316\u540e\u7684\u6a21\u578b\u7cbe\u5ea6\uff0c\u7279\u522b\u662f\u5f53\u6211\u4eec\u53ea\u4f7f\u7528optimization level 0\u8fdb\u884c\u6700\u57fa\u7840\u7684\u91cf\u5316\u7684\u65f6\u5019\u3002<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Hailo\u6a21\u578b\u8f6c\u6362\/\u91cf\u5316\u4e00\u822c\u4f1a\u6709\u5c11\u91cf\u7684\u7cbe\u5ea6\u4e0b\u964d\uff0c\u6b63\u5e38mAP\u4e0b\u964d\u57282\u4e2a\u70b9\u4ee5\u5185\uff0c\u5982\u679c\u4e0b\u964d\u592a\u591a\uff0c\u6216\u8005\u662f\u4e3b\u89c2\u67e5\u770b\u7cbe\u5ea6\u5dee [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"categories":[15,16,1],"tags":[],"class_list":["post-617","post","type-post","status-publish","format-standard","hentry","category-ai","category-dfc","category-tech"],"_links":{"self":[{"href":"https:\/\/www.zhoubin.asia\/index.php\/wp-json\/wp\/v2\/posts\/617","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhoubin.asia\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhoubin.asia\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhoubin.asia\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhoubin.asia\/index.php\/wp-json\/wp\/v2\/comments?post=617"}],"version-history":[{"count":3,"href":"https:\/\/www.zhoubin.asia\/index.php\/wp-json\/wp\/v2\/posts\/617\/revisions"}],"predecessor-version":[{"id":622,"href":"https:\/\/www.zhoubin.asia\/index.php\/wp-json\/wp\/v2\/posts\/617\/revisions\/622"}],"wp:attachment":[{"href":"https:\/\/www.zhoubin.asia\/index.php\/wp-json\/wp\/v2\/media?parent=617"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhoubin.asia\/index.php\/wp-json\/wp\/v2\/categories?post=617"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhoubin.asia\/index.php\/wp-json\/wp\/v2\/tags?post=617"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}