{"id":1927,"date":"2019-10-07T03:05:01","date_gmt":"2019-10-06T18:05:01","guid":{"rendered":"https:\/\/www.kdel.org\/wp\/?p=1927"},"modified":"2019-11-15T23:14:36","modified_gmt":"2019-11-15T14:14:36","slug":"ssd-keras%e3%81%ae%e6%95%99%e5%b8%ab%e3%83%87%e3%83%bc%e3%82%bf%e3%82%92yolo%e7%94%a8%e3%81%ab%e5%a4%89%e6%8f%9b","status":"publish","type":"post","link":"https:\/\/www.kdel.org\/wp\/?p=1927","title":{"rendered":"ssd keras\u306e\u6559\u5e2b\u30c7\u30fc\u30bf\u3092yolo\u7528\u306b\u5909\u63db"},"content":{"rendered":"<p>\u4e16\u306e\u4e2d\u306e\u6d41\u308c\u3068\u9006\u884c\u3057\u3066\u3044\u307e\u3059\u304c\uff0c\u8af8\u822c\u306e\u4e8b\u60c5\u306b\u3088\u308a\u5fc5\u8981\u3068\u306a\u3063\u305f\u306e\u3067\uff0c\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u66f8\u304d\u307e\u3057\u305f\uff0e<\/p>\n<p>\u307e\u305a\u306f\uff0c<a href=\"https:\/\/qiita.com\/haru1977\/items\/d30e9730abfa9a193285\">Pascal VOC\u5f62\u5f0f\u306exml\u30d5\u30a1\u30a4\u30eb\u3092Python\u3067\u8aad\u3080<\/a>\u3092\u5143\u306b\uff0cxml\u30d5\u30a1\u30a4\u30eb\u306e\u30c7\u30fc\u30bf\u3092\u53d6\u3063\u3066\u304d\u3066\uff0c\u5909\u63db\u3057\u3066\u51fa\u529b\u3057\u3066\u307f\u307e\u3057\u305f\uff0e<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n# coding:utf-8\r\n\r\nimport xml.etree.ElementTree as ET\r\nimport sys\r\n\r\n# FILE = '00001.xml'\r\nargs = sys.argv\r\n\r\nfor FILE in args:\r\n    # print FILE\r\n    if FILE != args&#x5B;0]:\r\n        file = open(FILE)\r\n        tree = ET.parse(file)\r\n        root = tree.getroot()\r\n\r\n        all_list = &#x5B;]\r\n\r\n        img_file = root.find('filename').text  # \u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u53d6\u5f97\r\n\r\n        for obj in root.iter('object'):\r\n            cls = obj.find('name').text\r\n            xmlbox = obj.find('bndbox')\r\n            b = &#x5B;int(xmlbox.find('xmin').text), int(xmlbox.find('ymin').text), int(xmlbox.find('xmax').text), int(xmlbox.find('ymax').text)]\r\n            all_list.append(&#x5B;img_file] + b + &#x5B;cls])\r\n        # print all_list\r\n        # &#x5B;&#x5B;'00102.jpg', 148, 369, 494, 957, 'WALL'], &#x5B;'00102.jpg', 470, 16, 1176, 849, 'MPS']]\r\n        if cls == 'MPS':\r\n            print '0',\r\n        else:\r\n            print '1',\r\n        centerx = (int(xmlbox.find('xmin').text) + int(xmlbox.find('xmax').text)) \/ 2\r\n        centery = (int(xmlbox.find('ymin').text) + int(xmlbox.find('ymax').text)) \/ 2\r\n        widthx = (int(xmlbox.find('xmax').text) - int(xmlbox.find('xmin').text))\r\n        widthy = (int(xmlbox.find('ymax').text) - int(xmlbox.find('ymin').text))\r\n        print centerx, centery, widthx, widthy\r\n<\/pre>\n<p>\u8907\u6570\u30d5\u30a1\u30a4\u30eb\u306b\u5bfe\u5fdc\u3055\u305b\u3066\u304a\u304d\u306a\u304c\u3089\uff0c\u3053\u306e\u51fa\u529b\u7d50\u679c\u3092\u6271\u3046\u65b9\u6cd5\u304c\u9762\u5012\u304f\u3055\u304b\u3063\u305f\u306e\u3067\uff0c\u305d\u306e\u90e8\u5206\u306fbash\u3067\u66f8\u3044\u3061\u3083\u3044\u307e\u3057\u305f\uff0e<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n#!\/bin\/bash\r\n\r\nfor FILE in `ls *.xml`; do\r\n        TXT=&quot;`echo $FILE|sed 's\/\\.&#x5B;^\\.]*$\/\/'`.txt&quot;\r\n        echo $TXT\r\n        python convert.py $FILE &gt; $TXT\r\ndone\r\n<\/pre>\n<p>\u3053\u308c\u3067\uff0cxml \u30d5\u30a1\u30a4\u30eb\u304b\u3089darknet \u306etxt \u30d5\u30a1\u30a4\u30eb\u306b\u4e00\u62ec\u5909\u63db\u3067\u304d\u307e\u3057\u305f\uff0e<\/p>\n<p>\u203b2019\/11\/15\u8ffd\u52a0<br \/>\n\u5b66\u751f\u304b\u3089\u306e\u6307\u6458\u3067\uff0c\u5909\u63db\u5f8c\u306f\uff0c\u753b\u50cf\u306e\u30b5\u30a4\u30ba\u3067\u6b63\u898f\u5316\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u3068\u306e\u3053\u3068\u3067\u3057\u305f\uff0e<br \/>\n\u3064\u307e\u308a\uff0cint(\u30b5\u30a4\u30ba) \/2\u306e\u3068\u3053\u308d\u304c\uff0c1920X1080\u306e\u5834\u5408\u306f\uff0c<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n        centerx = (float(xmlbox.find('xmin').text) + float(xmlbox.find('xmax').text)) \/ 2 \/ 1920\r\n        centery = (float(xmlbox.find('ymin').text) + float(xmlbox.find('ymax').text)) \/ 2 \/1080\r\n        widthx = (float(xmlbox.find('xmax').text) - float(xmlbox.find('xmin').text)) \/ 1980\r\n        widthy = (float(xmlbox.find('ymax').text) - float(xmlbox.find('ymin').text)) \/ 1080\r\n<\/pre>\n<p>\u3068\u306a\u308b\u3068\u306e\u3053\u3068\u3067\u3057\u305f\uff0e<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e16\u306e\u4e2d\u306e\u6d41\u308c\u3068\u9006\u884c\u3057\u3066\u3044\u307e\u3059\u304c\uff0c\u8af8\u822c\u306e\u4e8b\u60c5\u306b\u3088\u308a\u5fc5\u8981\u3068\u306a\u3063\u305f\u306e\u3067\uff0c\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u66f8 &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/www.kdel.org\/wp\/?p=1927\"> <span class=\"screen-reader-text\">ssd keras\u306e\u6559\u5e2b\u30c7\u30fc\u30bf\u3092yolo\u7528\u306b\u5909\u63db<\/span> \u7d9a\u304d\u3092\u8aad\u3080 &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[19,3,2,9,17,6,8],"tags":[],"class_list":["post-1927","post","type-post","status-publish","format-standard","hentry","category-jetson","category-logistics-league","category-robocup","category-robotino-3","category-robview3","category-setting","category-ubuntu"],"_links":{"self":[{"href":"https:\/\/www.kdel.org\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1927","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kdel.org\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kdel.org\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kdel.org\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kdel.org\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1927"}],"version-history":[{"count":3,"href":"https:\/\/www.kdel.org\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1927\/revisions"}],"predecessor-version":[{"id":1950,"href":"https:\/\/www.kdel.org\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1927\/revisions\/1950"}],"wp:attachment":[{"href":"https:\/\/www.kdel.org\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1927"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kdel.org\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1927"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kdel.org\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1927"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}