{"id":8235,"date":"2019-10-04T04:47:51","date_gmt":"2019-10-03T19:47:51","guid":{"rendered":"http:\/\/www.gisdeveloper.co.kr\/?p=8235"},"modified":"2020-05-28T10:13:31","modified_gmt":"2020-05-28T01:13:31","slug":"%ec%82%ac%eb%9e%8c%ec%9d%98-%eb%88%88-%ec%bd%94-%ea%b7%80-%ea%b7%b8%eb%a6%ac%ea%b3%a0-%ed%8c%94%ea%b3%bc-%eb%8b%a4%eb%a6%ac%eb%a5%bc-%ea%b2%80%ec%b6%9c%ed%95%98%eb%8a%94-person-keypoints-detection","status":"publish","type":"post","link":"http:\/\/www.gisdeveloper.co.kr\/?p=8235","title":{"rendered":"\uc0ac\ub78c\uc758 \ub208, \ucf54, \uadc0 \uadf8\ub9ac\uace0 \ud314\uacfc \ub2e4\ub9ac\ub97c \uac80\ucd9c\ud558\ub294 Person Keypoints Detection"},"content":{"rendered":"<p>\uc774\ubbf8\uc9c0\uc5d0 \ub300\ud55c Detection\uc758 \ud55c \uc885\ub958\ub85c Person Keypoints Detection\uc774 \uc788\uc2b5\ub2c8\ub2e4. \uc774 Detection\uc740 \uc0ac\ub78c\uc758 \ub208, \ucf54, \uadc0 \uadf8\ub9ac\uace0 \ud314\uacfc \ub2e4\ub9ac\ub97c \uac80\ucd9c\ud569\ub2c8\ub2e4. \uc544\ub798\ucc98\ub7fc\uc694.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gisdeveloper.co.kr\/wp-content\/uploads\/2019\/10\/Person_Keypoints_Detection.png\" alt=\"\" width=\"1920\" height=\"967\" class=\"aligncenter size-full wp-image-8236\" \/><\/p>\n<p>\uba38\uc2e0\ub7ec\ub2dd \ub77c\uc774\ube0c\ub9ac \uc911\uc5d0 \ud558\ub098\uc778, PyTorch\uc5d0\uc11c\ub294 Person Keypoints Detection\uc744 \uc704\ud55c \ubaa8\ub378\uc5d0 \ub300\ud574\uc11c \uc774\ubbf8 \uc798 \ud559\uc2b5\ub41c \ub370\uc774\ud130\ub97c \uc81c\uacf5\ud569\ub2c8\ub2e4. \uc774 \uae00\uc740 \ubbf8\ub9ac \ud559\uc2b5\ub41c \ub370\uc774\ud130\ub97c \ud65c\uc6a9\ud558\uc5ec \uc774\ubbf8\uc9c0\uc5d0\uc11c \uc0ac\ub78c\uc758 \ub208, \ucf54, \uadc0\uc640 \ud314 \uadf8\ub9ac\uace0 \ub2e4\ub9ac\ub97c \uac80\ucd9c\ud558\ub294 \ucf54\ub4dc\ub97c \uc0b4\ud3b4\ubd05\ub2c8\ub2e4.<\/p>\n<p>\uc544\uc6b8\ub7ec \uc774 \uae00\uc5d0\uc11c\ub294 matplotlib\uc5d0\uc11c \uadf8\ub798\ud504\ub098 \uc774\ubbf8\uc9c0\ub97c \ub2e8\uc21c\ud788 \ud45c\uc2dc\ud558\ub294 \uac83\uc5d0\uc11c \uc6d0\ud558\ub294 \ub3c4\ud615\uc744 \uc6d0\ud558\ub294 \uc704\uce58\uc5d0 \ud45c\uc2dc\ud558\ub294 API\ub3c4 \ud30c\uc545\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<p>\uba3c\uc800 \ud544\uc694\ud55c \ud328\ud0a4\uc9c0\ub97c import \ud569\ub2c8\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">\r\nimport numpy as np\r\nfrom PIL import Image\r\n\r\nimport torch\r\nimport torchvision\r\nfrom torchvision import models\r\nimport torchvision.transforms as T\r\n\r\nimport matplotlib.pyplot as plt\r\nfrom matplotlib.path import Path\r\nimport matplotlib.patches as patches\r\n<\/pre>\n<p>\ubbf8\ub9ac\ud559\uc2b5\ub41c \ub370\uc774\ud130\ub97c \ud65c\uc6a9\ud558\uc5ec Person Keypoints Detection\uc744 \uc704\ud55c \ubaa8\ub378\uc744 \uac00\uc838\uc624\ub294\ub370, \uba38\uc2e0\ub7ec\ub2dd\uc740 \ub300\uaddc\ubaa8\uc758 \ud589\ub82c\uc5f0\uc0b0\uc5d0 \ucd5c\uc801\ud654\ub41c GPU\uc5d0\uc11c \uc218\ud589\ud558\ub294 \uac83\uc774 \uc81c\ub9db\uc774\ubbc0\ub85c GPU \uc5f0\uc0b0\uc744 \ud1b5\ud574 \uc2e0\uacbd\ub9dd \ubaa8\ub378\uc744 \ub85c\ub4dc\ud569\ub2c8\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">\r\ndevice = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\") # CPU to GPU\r\nmodel = models.detection.keypointrcnn_resnet50_fpn(pretrained=True).to(device).eval()\r\n<\/pre>\n<p>\uc774\ubbf8\uc9c0\ub97c \ubd88\ub7ec\uc624\uace0 \uc774\ubbf8\uc9c0\uc758 \ud06c\uae30\ub97c \uc904\uc785\ub2c8\ub2e4. GPU\uc758 \uba54\ubaa8\ub9ac\uac00 \ucda9\ubd84\ud558\ub2e4\uba74 \uc774\ubbf8\uc9c0\ub97c \uc6d0\ubcf8 \ud06c\uae30 \uadf8\ub300\ub85c \uc0ac\uc6a9\ud574\ub3c4 \ub418\uc9c0\ub9cc, \uc774\ubbf8\uc9c0\ub97c \uac00\ub85c\ub85c 800px\ub85c \uc904\uc5ec\uc90d\ub2c8\ub2e4. \uba54\ubaa8\ub9ac\ub97c \ub35c \uc0ac\uc6a9\ud558\ub294 \uac83\ub3c4 \uc788\uace0, \uc18d\ub3c4\ub3c4 \ud06c\uac8c \ud5a5\uc0c1\ub418\uaca0\uc8e0.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">\r\nIMAGE_SIZE = 800\r\n \r\nimg = Image.open('data\/running_1.jpg')\r\nimg = img.resize((IMAGE_SIZE, int(img.height * IMAGE_SIZE \/ img.width)))\r\n<\/pre>\n<p>\uac80\ucd9c\uc744 \uc218\ud589\ud569\ub2c8\ub2e4. \uc774\ub97c \uc704\ud574 \uba3c\uc800 \uc785\ub825 \uc774\ubbf8\uc9c0\ub97c \ud150\uc11c\ub85c \ubcc0\ud658\ud574\uc57c\ud569\ub2c8\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">\r\ntrf = T.Compose([\r\n    T.ToTensor()\r\n])\r\n\r\ninput_img = trf(img).to(device) # CPU to GPU\r\n\r\nout = model([input_img])[0]\r\n<\/pre>\n<p>out \ubcc0\uc218\uc5d0 \uc0ac\ub78c\uc5d0 \ub300\ud55c \ub208, \ucf54, \uadc0 \uadf8\ub9ac\uace0 \ud314\uacfc \ub2e4\ub9ac\uc5d0 \ub300\ud55c \uc815\ubcf4\uac00 \ub2f4\uaca8 \uc788\uc2b5\ub2c8\ub2e4. \uc774 \ubcc0\uc218\ub97c \uc774\uc6a9\ud574 \uc774\ubbf8\uc9c0 \uc0c1\uc5d0 \ud574\ub2f9 \uc815\ubcf4\ub97c \uc2dc\uac01\ud654 \ud569\ub2c8\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">\r\ncodes = [\r\n    Path.MOVETO,\r\n    Path.LINETO,\r\n    Path.LINETO\r\n]\r\n\r\nfig, ax = plt.subplots(1)\r\nax.imshow(img)\r\n\r\nTHRESHOLD = 0.9 # \ud574\ub2f9 \uc815\ubcf4\uc758 \uc815\ud655\ub3c4\uac00 90% \uc774\uc0c1\uc778 \uac83\ub9cc \uc0ac\uc6a9\r\n\r\nfor box, score, keypoints in zip(out['boxes'], out['scores'], out['keypoints']):\r\n    score = score.detach().cpu().numpy() # GPU to CPU\r\n\r\n    if score < THRESHOLD:\r\n        continue\r\n\r\n    box = box.detach().cpu().numpy() # GPU to CPU\r\n    keypoints = keypoints.detach().cpu().numpy()[:, :2] # GPU to CPU\r\n\r\n    # \uc0ac\ub78c\uc5d0 \ub300\ud55c \uc601\uc5ed\uc744 \uadf8\ub9ac\uae30\r\n    rect = patches.Rectangle((box[0], box[1]), box[2]-box[0], box[3]-box[1], linewidth=2, edgecolor='white', facecolor='none')\r\n    ax.add_patch(rect)\r\n\r\n    # \uc67c\ucabd \ud314\uc5d0 \ub300\ud55c \uc120 \uadf8\ub9ac\uae30\r\n    path = Path(keypoints[5:10:2], codes)\r\n    line = patches.PathPatch(path, linewidth=2, facecolor='none', edgecolor='red')\r\n    ax.add_patch(line)\r\n    \r\n    # \uc624\ub978\ucabd \ud314\uc5d0 \ub300\ud55c \uc120 \uadf8\ub9ac\uae30\r\n    path = Path(keypoints[6:11:2], codes)\r\n    line = patches.PathPatch(path, linewidth=2, facecolor='none', edgecolor='red')\r\n    ax.add_patch(line)\r\n    \r\n    # \uc67c\ucabd \ub2e4\ub9ac\uc5d0 \ub300\ud55c \uc120 \uadf8\ub9ac\uae30\r\n    path = Path(keypoints[11:16:2], codes)\r\n    line = patches.PathPatch(path, linewidth=2, facecolor='none', edgecolor='red')\r\n    ax.add_patch(line)\r\n    \r\n    # \uc624\ub978\ucabd \ub2e4\ub9ac\uc5d0 \ub300\ud55c \uc120 \uadf8\ub9ac\uae30\r\n    path = Path(keypoints[12:17:2], codes)\r\n    line = patches.PathPatch(path, linewidth=2, facecolor='none', edgecolor='red')\r\n    ax.add_patch(line)\r\n\r\n    # \ub208,\ucf54,\uadc0\ub294 \ub178\ub780\uc0c9\uc73c\ub85c \uadf8\ub9ac\uace0 \ud314\ub2e4\ub9ac\uc758 \uc2dc\uc791\uc810\uacfc \ub05d\uc810\uc740 \ube68\uac04\uc0c9\uc73c\ub85c \uadf8\ub9ac\uae30\r\n    for i, k in enumerate(keypoints):\r\n        if i < 5:\r\n            RADIUS = 5\r\n            FACE_COLOR = 'yellow'\r\n        else:\r\n            RADIUS = 10\r\n            FACE_COLOR = 'red'\r\n\r\n        circle = patches.Circle((k[0], k[1]), radius=RADIUS, facecolor=FACE_COLOR)\r\n        ax.add_patch(circle)    \r\n\r\nplt.show()    \r\n<\/pre>\n<p>\uc5b4\uc81c \ud734\uc77c\uc774\ub77c \uc77c\ucc0d \uc7a0\ub4e4\uc5c8\ub354\ub2c8, \uc0c8\ubcbd 3\uc2dc\uc5d0 \uc77c\uc5b4\ub0ac\uc2b5\ub2c8\ub2e4. \uae00\uc744 \uc791\uc131\ud558\ub358 \uc911\uc5d0 \uc0c8\ubcbd 4\uc2dc \uc870\uae08 \ub118\uc5b4\uc11c \ub9c8\ucf13\uceec\ub9ac \ubc30\uc1a1\uc774 \uc654\ub124\uc694. \uc2dc\uac04\uc744 \ucd08\uc6d4\ud55c \ub9c8\ucf13\uceec\ub9ac\uc758 \ubc30\uc1a1.. \uace0\uc0dd\uc774 \ub9ce\uc73c\uc2ed\ub2c8\ub2f9..<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\uc774\ubbf8\uc9c0\uc5d0 \ub300\ud55c Detection\uc758 \ud55c \uc885\ub958\ub85c Person Keypoints Detection\uc774 \uc788\uc2b5\ub2c8\ub2e4. \uc774 Detection\uc740 \uc0ac\ub78c\uc758 \ub208, \ucf54, \uadc0 \uadf8\ub9ac\uace0 \ud314\uacfc \ub2e4\ub9ac\ub97c \uac80\ucd9c\ud569\ub2c8\ub2e4. \uc544\ub798\ucc98\ub7fc\uc694. \uba38\uc2e0\ub7ec\ub2dd \ub77c\uc774\ube0c\ub9ac \uc911\uc5d0 \ud558\ub098\uc778, PyTorch\uc5d0\uc11c\ub294 Person Keypoints Detection\uc744 \uc704\ud55c \ubaa8\ub378\uc5d0 \ub300\ud574\uc11c \uc774\ubbf8 \uc798 \ud559\uc2b5\ub41c \ub370\uc774\ud130\ub97c \uc81c\uacf5\ud569\ub2c8\ub2e4. \uc774 \uae00\uc740 \ubbf8\ub9ac \ud559\uc2b5\ub41c \ub370\uc774\ud130\ub97c \ud65c\uc6a9\ud558\uc5ec \uc774\ubbf8\uc9c0\uc5d0\uc11c \uc0ac\ub78c\uc758 \ub208, \ucf54, \uadc0\uc640 \ud314 \uadf8\ub9ac\uace0 \ub2e4\ub9ac\ub97c \uac80\ucd9c\ud558\ub294 \ucf54\ub4dc\ub97c \uc0b4\ud3b4\ubd05\ub2c8\ub2e4. \uc544\uc6b8\ub7ec \uc774 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/www.gisdeveloper.co.kr\/?p=8235\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;\uc0ac\ub78c\uc758 \ub208, \ucf54, \uadc0 \uadf8\ub9ac\uace0 \ud314\uacfc \ub2e4\ub9ac\ub97c \uac80\ucd9c\ud558\ub294 Person Keypoints Detection&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[132],"tags":[],"class_list":["post-8235","post","type-post","status-publish","format-standard","hentry","category-deep-machine-learning"],"_links":{"self":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/8235","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8235"}],"version-history":[{"count":7,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/8235\/revisions"}],"predecessor-version":[{"id":9375,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/8235\/revisions\/9375"}],"wp:attachment":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8235"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8235"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}