์ฝ˜ํ…์ธ ๋กœ ๊ฑด๋„ˆ๋›ฐ๊ธฐ

Ultralytics YOLO11 ๐Ÿš€์„ ์‚ฌ์šฉํ•œ ์ธ์Šคํ„ด์Šค ์„ธ๋ถ„ํ™” ๋ฐ ์ถ”์ 

์ธ์Šคํ„ด์Šค ์„ธ๋ถ„ํ™”๋ž€ ๋ฌด์—‡์ธ๊ฐ€์š”?

Ultralytics YOLO11 ์ธ์Šคํ„ด์Šค ๋ถ„ํ• ์€ ์ด๋ฏธ์ง€์—์„œ ๊ฐœ๋ณ„ ๊ฐ์ฒด๋ฅผ ์‹๋ณ„ํ•˜๊ณ  ์œค๊ณฝ์„ ๊ทธ๋ ค ๊ณต๊ฐ„ ๋ถ„ํฌ์— ๋Œ€ํ•œ ์ƒ์„ธํ•œ ์ดํ•ด๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ์‹œ๋งจํ‹ฑ ์„ธ๋ถ„ํ™”์™€๋Š” ๋‹ฌ๋ฆฌ ๊ฐ ๊ฐ์ฒด์— ๊ณ ์œ ํ•œ ๋ ˆ์ด๋ธ”์„ ์ง€์ •ํ•˜๊ณ  ์ •ํ™•ํ•˜๊ฒŒ ๋ฌ˜์‚ฌํ•˜๋ฏ€๋กœ ๊ฐ์ฒด ๊ฐ์ง€ ๋ฐ ์˜๋ฃŒ ์˜์ƒ๊ณผ ๊ฐ™์€ ์ž‘์—…์— ๋งค์šฐ ์ค‘์š”ํ•ฉ๋‹ˆ๋‹ค.

Ultralytics ํŒจํ‚ค์ง€์—์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ์ธ์Šคํ„ด์Šค ์„ธ๋ถ„ํ™” ์ถ”์ ์—๋Š” ๋‘ ๊ฐ€์ง€ ์œ ํ˜•์ด ์žˆ์Šต๋‹ˆ๋‹ค:

  • ํด๋ž˜์Šค ๊ฐ์ฒด๋ฅผ ์‚ฌ์šฉํ•œ ์ธ์Šคํ„ด์Šค ์„ธ๋ถ„ํ™”: ๊ฐ ํด๋ž˜์Šค ๊ฐ์ฒด์—๋Š” ์‹œ๊ฐ์ ์œผ๋กœ ๋ช…ํ™•ํ•˜๊ฒŒ ๊ตฌ๋ถ„ํ•  ์ˆ˜ ์žˆ๋„๋ก ๊ณ ์œ ํ•œ ์ƒ‰์ƒ์ด ํ• ๋‹น๋ฉ๋‹ˆ๋‹ค.

  • ์˜ค๋ธŒ์ ํŠธ ํŠธ๋ž™์„ ์‚ฌ์šฉํ•œ ์ธ์Šคํ„ด์Šค ์„ธ๋ถ„ํ™”: ๋ชจ๋“  ํŠธ๋ž™์€ ๊ณ ์œ ํ•œ ์ƒ‰์ƒ์œผ๋กœ ํ‘œ์‹œ๋˜์–ด ์‰ฝ๊ฒŒ ์‹๋ณ„ํ•˜๊ณ  ์ถ”์ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.



Watch: ์˜ค๋ธŒ์ ํŠธ ์ถ”์ ์„ ์‚ฌ์šฉํ•œ ์ธ์Šคํ„ด์Šค ์„ธ๋ถ„ํ™” Ultralytics YOLO11

์ƒ˜ํ”Œ

์ธ์Šคํ„ด์Šค ์„ธ๋ถ„ํ™” ์ธ์Šคํ„ด์Šค ์„ธ๋ถ„ํ™” + ์˜ค๋ธŒ์ ํŠธ ์ถ”์ 
Ultralytics ์ธ์Šคํ„ด์Šค ์„ธ๋ถ„ํ™” Ultralytics ์˜ค๋ธŒ์ ํŠธ ์ถ”์ ์„ ํ†ตํ•œ ์ธ์Šคํ„ด์Šค ์„ธ๋ถ„ํ™”
Ultralytics ์ธ์Šคํ„ด์Šค ์„ธ๋ถ„ํ™” ๐Ÿ˜ Ultralytics ์˜ค๋ธŒ์ ํŠธ ์ถ”์ ์„ ํ†ตํ•œ ์ธ์Šคํ„ด์Šค ์„ธ๋ถ„ํ™” ๐Ÿ”ฅ.

์ธ์Šคํ„ด์Šค ์„ธ๋ถ„ํ™” ๋ฐ ์ถ”์ 

import cv2

from ultralytics import YOLO
from ultralytics.utils.plotting import Annotator, colors

model = YOLO("yolo11n-seg.pt")  # segmentation model
names = model.model.names
cap = cv2.VideoCapture("path/to/video/file.mp4")
w, h, fps = (int(cap.get(x)) for x in (cv2.CAP_PROP_FRAME_WIDTH, cv2.CAP_PROP_FRAME_HEIGHT, cv2.CAP_PROP_FPS))

out = cv2.VideoWriter("instance-segmentation.avi", cv2.VideoWriter_fourcc(*"MJPG"), fps, (w, h))

while True:
    ret, im0 = cap.read()
    if not ret:
        print("Video frame is empty or video processing has been successfully completed.")
        break

    results = model.predict(im0)
    annotator = Annotator(im0, line_width=2)

    if results[0].masks is not None:
        clss = results[0].boxes.cls.cpu().tolist()
        masks = results[0].masks.xy
        for mask, cls in zip(masks, clss):
            color = colors(int(cls), True)
            txt_color = annotator.get_txt_color(color)
            annotator.seg_bbox(mask=mask, mask_color=color, label=names[int(cls)], txt_color=txt_color)

    out.write(im0)
    cv2.imshow("instance-segmentation", im0)

    if cv2.waitKey(1) & 0xFF == ord("q"):
        break

out.release()
cap.release()
cv2.destroyAllWindows()
import cv2

from ultralytics import YOLO
from ultralytics.utils.plotting import Annotator, colors

model = YOLO("yolo11n-seg.pt")  # segmentation model
cap = cv2.VideoCapture("path/to/video/file.mp4")
w, h, fps = (int(cap.get(x)) for x in (cv2.CAP_PROP_FRAME_WIDTH, cv2.CAP_PROP_FRAME_HEIGHT, cv2.CAP_PROP_FPS))

out = cv2.VideoWriter("instance-segmentation-object-tracking.avi", cv2.VideoWriter_fourcc(*"MJPG"), fps, (w, h))

while True:
    ret, im0 = cap.read()
    if not ret:
        print("Video frame is empty or video processing has been successfully completed.")
        break

    annotator = Annotator(im0, line_width=2)

    results = model.track(im0, persist=True)

    if results[0].boxes.id is not None and results[0].masks is not None:
        masks = results[0].masks.xy
        track_ids = results[0].boxes.id.int().cpu().tolist()

        for mask, track_id in zip(masks, track_ids):
            color = colors(int(track_id), True)
            txt_color = annotator.get_txt_color(color)
            annotator.seg_bbox(mask=mask, mask_color=color, label=str(track_id), txt_color=txt_color)

    out.write(im0)
    cv2.imshow("instance-segmentation-object-tracking", im0)

    if cv2.waitKey(1) & 0xFF == ord("q"):
        break

out.release()
cap.release()
cv2.destroyAllWindows()

seg_bbox ์ธ์ˆ˜

์ด๋ฆ„ ์œ ํ˜• ๊ธฐ๋ณธ๊ฐ’ ์„ค๋ช…
mask array None ์„ธ๋ถ„ํ™” ๋งˆ์Šคํฌ ์ขŒํ‘œ
mask_color RGB (255, 0, 255) ๋ชจ๋“  ์„ธ๊ทธ๋จผํŠธ ์ƒ์ž์— ๋Œ€ํ•œ ๋งˆ์Šคํฌ ์ƒ‰์ƒ
label str None ์„ธ๊ทธ๋จผํŠธ ๊ฐ์ฒด์— ๋Œ€ํ•œ ๋ ˆ์ด๋ธ”
txt_color RGB None ์„ธ๊ทธ๋จผํŠธ ๋ฐ ์ถ”์  ๋Œ€์ƒ์˜ ๋ ˆ์ด๋ธ” ์ƒ‰์ƒ

์ฐธ๊ณ 

๋ฌธ์˜ ์‚ฌํ•ญ์ด ์žˆ์œผ์‹œ๋ฉด Ultralytics ์ด์Šˆ ์„น์…˜ ๋˜๋Š” ์•„๋ž˜์— ์–ธ๊ธ‰๋œ ํ† ๋ก  ์„น์…˜์— ์ž์œ ๋กญ๊ฒŒ ์งˆ๋ฌธ์„ ๊ฒŒ์‹œํ•ด ์ฃผ์„ธ์š”.

์ž์ฃผ ๋ฌป๋Š” ์งˆ๋ฌธ

Ultralytics YOLO11 ์„ ์‚ฌ์šฉํ•˜์—ฌ ์ธ์Šคํ„ด์Šค ์„ธ๋ถ„ํ™”๋ฅผ ์ˆ˜ํ–‰ํ•˜๋ ค๋ฉด ์–ด๋–ป๊ฒŒ ํ•ด์•ผ ํ•˜๋‚˜์š”?

Ultralytics YOLO11 ์„ ์‚ฌ์šฉํ•˜์—ฌ ์ธ์Šคํ„ด์Šค ์„ธ๊ทธ๋จผํ…Œ์ด์…˜์„ ์ˆ˜ํ–‰ํ•˜๋ ค๋ฉด YOLO ๋ชจ๋ธ์„ YOLO11 ์˜ ์„ธ๊ทธ๋จผํ…Œ์ด์…˜ ๋ฒ„์ „์œผ๋กœ ์ดˆ๊ธฐํ™”ํ•˜๊ณ  ์ด๋ฅผ ํ†ตํ•ด ๋น„๋””์˜ค ํ”„๋ ˆ์ž„์„ ์ฒ˜๋ฆฌํ•ฉ๋‹ˆ๋‹ค. ๋‹ค์Œ์€ ๊ฐ„๋‹จํ•œ ์ฝ”๋“œ ์˜ˆ์‹œ์ž…๋‹ˆ๋‹ค:

์˜ˆ

import cv2

from ultralytics import YOLO
from ultralytics.utils.plotting import Annotator, colors

model = YOLO("yolo11n-seg.pt")  # segmentation model
cap = cv2.VideoCapture("path/to/video/file.mp4")
w, h, fps = (int(cap.get(x)) for x in (cv2.CAP_PROP_FRAME_WIDTH, cv2.CAP_PROP_FRAME_HEIGHT, cv2.CAP_PROP_FPS))

out = cv2.VideoWriter("instance-segmentation.avi", cv2.VideoWriter_fourcc(*"MJPG"), fps, (w, h))

while True:
    ret, im0 = cap.read()
    if not ret:
        break

    results = model.predict(im0)
    annotator = Annotator(im0, line_width=2)

    if results[0].masks is not None:
        clss = results[0].boxes.cls.cpu().tolist()
        masks = results[0].masks.xy
        for mask, cls in zip(masks, clss):
            annotator.seg_bbox(mask=mask, mask_color=colors(int(cls), True), det_label=model.model.names[int(cls)])

    out.write(im0)
    cv2.imshow("instance-segmentation", im0)
    if cv2.waitKey(1) & 0xFF == ord("q"):
        break

out.release()
cap.release()
cv2.destroyAllWindows()

์ธ์Šคํ„ด์Šค ์„ธ๋ถ„ํ™”์— ๋Œ€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ Ultralytics YOLO11 ๊ฐ€์ด๋“œ์—์„œ ํ™•์ธํ•˜์„ธ์š”.

Ultralytics YOLO11 ์—์„œ ์ธ์Šคํ„ด์Šค ์„ธ๋ถ„ํ™”์™€ ๊ฐ์ฒด ์ถ”์ ์˜ ์ฐจ์ด์ ์€ ๋ฌด์—‡์ธ๊ฐ€์š”?

์ธ์Šคํ„ด์Šค ๋ถ„ํ• ์€ ์ด๋ฏธ์ง€ ๋‚ด์˜ ๊ฐœ๋ณ„ ๊ฐ์ฒด๋ฅผ ์‹๋ณ„ํ•˜๊ณ  ์œค๊ณฝ์„ ๊ทธ๋ ค ๊ฐ ๊ฐ์ฒด์— ๊ณ ์œ ํ•œ ๋ ˆ์ด๋ธ”๊ณผ ๋งˆ์Šคํฌ๋ฅผ ๋ถ€์—ฌํ•ฉ๋‹ˆ๋‹ค. ๊ฐ์ฒด ์ถ”์ ์€ ์ด๋ฅผ ํ™•์žฅํ•˜์—ฌ ๋น„๋””์˜ค ํ”„๋ ˆ์ž„ ์ „์ฒด์— ๊ฑธ์ณ ๊ฐ์ฒด์— ์ผ๊ด€๋œ ๋ ˆ์ด๋ธ”์„ ํ• ๋‹นํ•˜์—ฌ ์‹œ๊ฐ„์ด ์ง€๋‚˜๋„ ๋™์ผํ•œ ๊ฐ์ฒด๋ฅผ ์ง€์†์ ์œผ๋กœ ์ถ”์ ํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•ฉ๋‹ˆ๋‹ค. Ultralytics YOLO11 ๋ฌธ์„œ์—์„œ ์ฐจ์ด์ ์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์•Œ์•„๋ณด์„ธ์š”.

์˜ˆ๋ฅผ ๋“ค์–ด ์„ธ๋ถ„ํ™” ๋ฐ ์ถ”์ ์— Mask R-CNN ๋˜๋Š” Faster R-CNN๊ณผ ๊ฐ™์€ ๋‹ค๋ฅธ ๋ชจ๋ธ๋ณด๋‹ค Ultralytics YOLO11 ์„ ์‚ฌ์šฉํ•ด์•ผ ํ•˜๋Š” ์ด์œ ๋Š” ๋ฌด์—‡์ธ๊ฐ€์š”?

Ultralytics YOLO11 ์€ ์‹ค์‹œ๊ฐ„ ์„ฑ๋Šฅ, ๋›ฐ์–ด๋‚œ ์ •ํ™•๋„, ์‚ฌ์šฉ ํŽธ์˜์„ฑ์„ ์ œ๊ณตํ•˜๋ฉฐ, ๋‹ค๋ฅธ ๋ชจ๋ธ์ธ Mask R-CNN์ด๋‚˜ Faster R-CNN๊ณผ ๋น„๊ตํ•ด๋„ ์†์ƒ‰์ด ์—†์Šต๋‹ˆ๋‹ค. YOLO11 ์€ Ultralytics ํ—ˆ๋ธŒ์™€ ์›ํ™œํ•˜๊ฒŒ ํ†ตํ•ฉ๋˜์–ด ์‚ฌ์šฉ์ž๊ฐ€ ๋ชจ๋ธ, ๋ฐ์ดํ„ฐ์„ธํŠธ, ํ›ˆ๋ จ ํŒŒ์ดํ”„๋ผ์ธ์„ ํšจ์œจ์ ์œผ๋กœ ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ๋„๋ก ์ง€์›ํ•ฉ๋‹ˆ๋‹ค. Ultralytics ๋ธ”๋กœ๊ทธ์—์„œ YOLO11 ์˜ ์ด์ ์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์•Œ์•„๋ณด์„ธ์š”.

Ultralytics YOLO11 ์„ ์‚ฌ์šฉํ•˜์—ฌ ๊ฐ์ฒด ์ถ”์ ์„ ๊ตฌํ˜„ํ•˜๋ ค๋ฉด ์–ด๋–ป๊ฒŒ ํ•ด์•ผ ํ•˜๋‚˜์š”?

๊ฐœ์ฒด ์ถ”์ ์„ ๊ตฌํ˜„ํ•˜๋ ค๋ฉด model.track ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๊ฐ ๊ฐ์ฒด์˜ ID๊ฐ€ ํ”„๋ ˆ์ž„ ๊ฐ„์— ์ผ๊ด€๋˜๊ฒŒ ํ• ๋‹น๋˜๋„๋ก ํ•ฉ๋‹ˆ๋‹ค. ์•„๋ž˜๋Š” ๊ฐ„๋‹จํ•œ ์˜ˆ์‹œ์ž…๋‹ˆ๋‹ค:

์˜ˆ

import cv2

from ultralytics import YOLO
from ultralytics.utils.plotting import Annotator, colors

model = YOLO("yolo11n-seg.pt")  # segmentation model
cap = cv2.VideoCapture("path/to/video/file.mp4")
w, h, fps = (int(cap.get(x)) for x in (cv2.CAP_PROP_FRAME_WIDTH, cv2.CAP_PROP_FRAME_HEIGHT, cv2.CAP_PROP_FPS))

out = cv2.VideoWriter("instance-segmentation-object-tracking.avi", cv2.VideoWriter_fourcc(*"MJPG"), fps, (w, h))

while True:
    ret, im0 = cap.read()
    if not ret:
        break

    annotator = Annotator(im0, line_width=2)
    results = model.track(im0, persist=True)

    if results[0].boxes.id is not None and results[0].masks is not None:
        masks = results[0].masks.xy
        track_ids = results[0].boxes.id.int().cpu().tolist()

        for mask, track_id in zip(masks, track_ids):
            annotator.seg_bbox(mask=mask, mask_color=colors(track_id, True), track_label=str(track_id))

    out.write(im0)
    cv2.imshow("instance-segmentation-object-tracking", im0)
    if cv2.waitKey(1) & 0xFF == ord("q"):
        break

out.release()
cap.release()
cv2.destroyAllWindows()

์ธ์Šคํ„ด์Šค ์„ธ๋ถ„ํ™” ๋ฐ ์ถ”์  ์„น์…˜์—์„œ ์ž์„ธํžˆ ์•Œ์•„๋ณด์„ธ์š”.

Ultralytics ์—์„œ ์ œ๊ณตํ•˜๋Š” ๋ฐ์ดํ„ฐ ์„ธํŠธ ์ค‘ ์ธ์Šคํ„ด์Šค ์„ธ๋ถ„ํ™” ๋ฐ ์ถ”์ ์„ ์œ„ํ•œ YOLO11 ๋ชจ๋ธ ํ•™์Šต์— ์ ํ•ฉํ•œ ๊ฒƒ์ด ์žˆ๋‚˜์š”?

์˜ˆ, Ultralytics ์—์„œ๋Š” ์„ธ๋ถ„ํ™” ๋ฐ ์ถ”์  ๋ฐ์ดํ„ฐ ์„ธํŠธ๋ฅผ ํฌํ•จํ•˜์—ฌ YOLO11 ๋ชจ๋ธ ํ›ˆ๋ จ์— ์ ํ•ฉํ•œ ์—ฌ๋Ÿฌ ๋ฐ์ดํ„ฐ ์„ธํŠธ๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ๋ฐ์ดํ„ฐ ์„ธํŠธ ์˜ˆ์ œ, ๊ตฌ์กฐ ๋ฐ ์‚ฌ์šฉ ์ง€์นจ์€ Ultralytics ๋ฐ์ดํ„ฐ ์„ธํŠธ ๋ฌธ์„œ์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

11๊ฐœ์›” ์ „ ์ƒ์„ฑ๋จ โœ๏ธ 1 ์ผ ์ „ ์—…๋ฐ์ดํŠธ๋จ

๋Œ“๊ธ€