{"id":863,"date":"2025-10-11T15:14:21","date_gmt":"2025-10-11T06:14:21","guid":{"rendered":"http:\/\/practical.kr\/?p=863"},"modified":"2025-10-11T15:14:21","modified_gmt":"2025-10-11T06:14:21","slug":"sam%ea%b3%bc-yolov8%ec%9d%84-%ed%99%9c%ec%9a%a9%ed%95%9c-%ea%b0%9d%ec%b2%b4-%ec%84%b8%ea%b7%b8%eb%a9%98%ed%85%8c%ec%9d%b4%ec%85%98","status":"publish","type":"post","link":"http:\/\/practical.kr\/?p=863","title":{"rendered":"SAM\uacfc YOLOv8\uc744 \ud65c\uc6a9\ud55c \uac1d\uccb4 \uc138\uadf8\uba58\ud14c\uc774\uc158"},"content":{"rendered":"\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/velog.velcdn.com\/images\/rtlink\/post\/a5a4bd5c-0129-4993-998e-a90397cbb7ea\/image.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>\uc9c0\ub09c\ubc88 \uae00\uc5d0\uc11c Supervision\uacfc ByteTrack\uc744 \uc774\uc6a9\ud574\uc11c \ub3c4\ub85c\uc5d0\uc11c \ucc28\ub7c9\uc744 \ucc3e\uace0(Yolo) \ud2b8\ub798\ud0b9(ByteTracking) \ud558\ub294 \uc608\uc81c\ub97c \ub9cc\ub4e4\uc5b4 \ubd24\ub294\ub370, \uc774\uae00\uc740 \uadf8 \uc5f0\uc7a5\uc120\uc5d0\uc11c \ubaa9\ud45c\ub97c \ucc3e\uc544\uc11c \ucc3e\uc544\uc11c \ubc15\uc2a4\ub9cc \ub450\ub974\ub294 \uac83\uc774 \uc544\ub2c8\uace0 \uc815\ud655\ud55c \ud615\uc0c1\uc744 \ucd94\ucd9c(\uc138\uadf8\uba58\ud14c\uc774\uc158)\ud558\ub294 \uae30\ub2a5\uc744 \uad6c\ud604\ud558\uae30 \uc704\ud558\uc5ec Segment Anything Model (SAM)\uacfc YOLOv8\uc744 \uacb0\ud569\ud558\uc5ec \uc0ac\ub78c\uacfc \uacf5(sports ball) \uac1d\uccb4\ub97c \uc815\ud655\ud558\uac8c \ud0d0\uc9c0\ud558\uace0 \uc138\uadf8\uba58\ud14c\uc774\uc158\ud558\ub294 \uc2dc\uc2a4\ud15c\uc744 \uad6c\ud604\ud574\ubd24\ub2e4. UI\ub294 Streamlit\uc744 \ud65c\uc6a9\ud588\ub2e4.<\/p>\n\n\n\n<p>\uc148\ud50c \uc774\ubbf8\uc9c0\ub294 \uc5b4\uc81c \ucd95\uad6c \uacbd\uae30\uc758 \ud55c\uc7a5\uba74. 5-0 \uc774\ub77c\ub2c8\u2026 \u3160,\u3160<\/p>\n\n\n\n<p><br><img decoding=\"async\" src=\"https:\/\/velog.velcdn.com\/images\/rtlink\/post\/fbf0d820-3923-40c3-b932-573333f588eb\/image.png\" alt=\"\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\uae30\uc220 \uc2a4\ud0dd<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>SAM (Segment Anything Model)<\/strong>: Meta\uc758 \ucd5c\uc2e0 \uc138\uadf8\uba58\ud14c\uc774\uc158 \ubaa8\ub378<\/li>\n\n\n\n<li><strong>YOLOv8<\/strong>: Ultralytics\uc758 \uac1d\uccb4 \ud0d0\uc9c0 \ubaa8\ub378<\/li>\n\n\n\n<li><strong>Streamlit<\/strong>: \uc6f9 \uc560\ud50c\ub9ac\ucf00\uc774\uc158 \ud504\ub808\uc784\uc6cc\ud06c<\/li>\n\n\n\n<li><strong>OpenCV<\/strong>: \uc774\ubbf8\uc9c0 \ucc98\ub9ac<\/li>\n\n\n\n<li><strong>PyTorch<\/strong>: \ub525\ub7ec\ub2dd \ud504\ub808\uc784\uc6cc\ud06c<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\uc2dc\uc2a4\ud15c \uc544\ud0a4\ud14d\ucc98<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. YOLOv8 \uac1d\uccb4 \ud0d0\uc9c0<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \uc120\uc218(\uc0ac\ub78c) (\ud074\ub798\uc2a4 ID: 0) \ub610\ub294 \uacf5 (\ud074\ub798\uc2a4 ID: 32 - sports ball)\nif (cls_id == 0 or cls_id == 32) and conf > 0.5:\n    object_type = \"person\" if cls_id == 0 else \"ball\"<\/pre>\n\n\n\n<p>YOLOv8\uc744 \uc0ac\uc6a9\ud558\uc5ec COCO \ub370\uc774\ud130\uc14b \uae30\ubc18\uc73c\ub85c \uc0ac\ub78c\uacfc \uacf5\uc744 \ud0d0\uc9c0\ud574\uc11c YOLO\ub97c \uc774\uc6a9\ud574 \ubc14\uc6b4\ub529 \ubc15\uc2a4\ub97c \ub9cc\ub4e0\ub2e4.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. SAM \uc138\uadf8\uba58\ud14c\uc774\uc158<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">predictor = SamPredictor(sam)\npredictor.set_image(image_array)\n\ninput_box = np.array([x1, y1, x2, y2])\nmasks, scores, logits = predictor.predict(\n    point_coords=None,\n    point_labels=None,\n    box=input_box[None, :],\n    multimask_output=False,\n)<\/pre>\n\n\n\n<p>\uadf8\ub9ac\uace0 \uc138\uadf8\uba58\ud14c\uc774\uc158\uc744 \uc2e4\ud589\ud55c\ub2e4<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/velog.velcdn.com\/images\/rtlink\/post\/c7b773d9-108a-4767-a5fe-748321341dfb\/image.png\" alt=\"\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\ud575\uc2ec \uad6c\ud604 \uc138\ubd80\uc0ac\ud56d<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. \uc774\uc911 \ubaa8\ub378 \ud30c\uc774\ud504\ub77c\uc778<\/h3>\n\n\n\n<p><strong>1\ub2e8\uacc4: YOLO \ud0d0\uc9c0<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\ube60\ub978 \uac1d\uccb4 \ud0d0\uc9c0\ub97c \ud1b5\ud55c ROI(Region of Interest) \uc2dd\ubcc4<\/li>\n\n\n\n<li>\ubc14\uc6b4\ub529 \ubc15\uc2a4 \uc88c\ud45c \ucd94\ucd9c<\/li>\n\n\n\n<li>\uac1d\uccb4 \ud0c0\uc785 \ubd84\ub958 (\uc0ac\ub78c\/\uacf5)<\/li>\n<\/ul>\n\n\n\n<p><strong>2\ub2e8\uacc4: SAM \uc138\uadf8\uba58\ud14c\uc774\uc158<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>YOLO\uc758 \ubc14\uc6b4\ub529 \ubc15\uc2a4\ub97c SAM\uc758 \uc785\ub825\uc73c\ub85c \ud65c\uc6a9<\/li>\n\n\n\n<li>\uc815\ubc00\ud55c \ud53d\uc140 \ub2e8\uc704 \ub9c8\uc2a4\ud06c \uc0dd\uc131<\/li>\n\n\n\n<li>\uac1d\uccb4 \uacbd\uacc4\uc758 \uc815\ud655\ud55c \ubd84\ud560<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">2. \ub370\uc774\ud130 \uad6c\uc870 \uc124\uacc4<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">all_masks.append({\n    'segmentation': best_mask,\n    'area': np.sum(best_mask),\n    'object_id': i+1,\n    'object_type': detection['type'],\n    'bbox': [x1, y1, x2, y2]\n})<\/pre>\n\n\n\n<p>\uac01 \ub9c8\uc2a4\ud06c \uac1d\uccb4\ub294 \uc138\uadf8\uba58\ud14c\uc774\uc158 \ub9c8\uc2a4\ud06c, \uba74\uc801, \uac1d\uccb4 ID, \ud0c0\uc785, \ubc14\uc6b4\ub529 \ubc15\uc2a4 \uc815\ubcf4\ub97c \ud3ec\ud568.<br>\uc774 \ub2e8\uacc4\ub294 \uc911\uac04 \ub2e8\uacc4\ub85c \ub2e4\uc74c\uc740 \ub3d9\uc601\uc0c1\uc5d0\uc11c \uac01\uac01\uc758 \ud504\ub808\uc784\ubcc4\ub3c4 \uc704\uc758 \uc791\uc5c5\uc744 \uc9c4\ud589\ud558\uc5ec \ub3d9\uc601\uc0c1\uc73c\ub85c \ub2e4\uc2dc \ud569\uce58\uba74 \ubc15\uc2a4 \uc624\ube0c\uc81d\ud2b8\uac00 \uc544\ub2cc \uc138\uadf8\uba58\ud14c\uc774\uc158 \ub2e8\uc704\uc758 \uc624\ube0c\uc81d\ud2b8 \ud2b8\ub798\ud0b9\uc774 \uac00\ub2a5\ud558\ub2e4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\uc9c0\ub09c\ubc88 \uae00\uc5d0\uc11c Supervision\uacfc ByteTrack\uc744 \uc774\uc6a9\ud574\uc11c \ub3c4\ub85c\uc5d0\uc11c \ucc28\ub7c9\uc744 \ucc3e\uace0(Yolo) \ud2b8\ub798\ud0b9(ByteTracking) \ud558\ub294 \uc608\uc81c\ub97c \ub9cc\ub4e4\uc5b4 \ubd24\ub294\ub370, \uc774\uae00\uc740 \uadf8 \uc5f0\uc7a5\uc120\uc5d0\uc11c \ubaa9\ud45c\ub97c \ucc3e\uc544\uc11c \ucc3e\uc544\uc11c \ubc15\uc2a4\ub9cc \ub450\ub974\ub294 \uac83\uc774 \uc544\ub2c8\uace0 \uc815\ud655\ud55c \ud615\uc0c1\uc744 \ucd94\ucd9c(\uc138\uadf8\uba58\ud14c\uc774\uc158)\ud558\ub294 \uae30\ub2a5\uc744 \uad6c\ud604\ud558\uae30 \uc704\ud558\uc5ec Segment Anything Model (SAM)\uacfc YOLOv8\uc744 \uacb0\ud569\ud558\uc5ec \uc0ac\ub78c\uacfc \uacf5(sports ball) \uac1d\uccb4\ub97c \uc815\ud655\ud558\uac8c \ud0d0\uc9c0\ud558\uace0 \uc138\uadf8\uba58\ud14c\uc774\uc158\ud558\ub294 \uc2dc\uc2a4\ud15c\uc744 \uad6c\ud604\ud574\ubd24\ub2e4. UI\ub294 Streamlit\uc744 \ud65c\uc6a9\ud588\ub2e4. \uc148\ud50c \uc774\ubbf8\uc9c0\ub294 \uc5b4\uc81c \ucd95\uad6c \uacbd\uae30\uc758 \ud55c\uc7a5\uba74. 5-0 \uc774\ub77c\ub2c8\u2026<\/p>\n<div class=\"more-link\">\n\t\t\t\t <a href=\"http:\/\/practical.kr\/?p=863\" class=\"link-btn theme-btn\"><span>Read More <\/span> <i class=\"fa fa-caret-right\"><\/i><\/a>\n\t\t\t<\/div>\n","protected":false},"author":1,"featured_media":866,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[38,35],"tags":[114,115],"class_list":["post-863","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ai","category-python","tag-sam","tag-yolo"],"jetpack_featured_media_url":"http:\/\/practical.kr\/wp-content\/uploads\/2025\/10\/\uc2a4\ud06c\ub9b0\uc0f7-2025-10-11-15.07.21.jpg","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/practical.kr\/index.php?rest_route=\/wp\/v2\/posts\/863","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/practical.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/practical.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/practical.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/practical.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=863"}],"version-history":[{"count":3,"href":"http:\/\/practical.kr\/index.php?rest_route=\/wp\/v2\/posts\/863\/revisions"}],"predecessor-version":[{"id":867,"href":"http:\/\/practical.kr\/index.php?rest_route=\/wp\/v2\/posts\/863\/revisions\/867"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/practical.kr\/index.php?rest_route=\/wp\/v2\/media\/866"}],"wp:attachment":[{"href":"http:\/\/practical.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=863"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/practical.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=863"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/practical.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=863"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}