C.W.K.
Stream
Lesson 04 of 06 · published

Image segmentation

~8 min · keras-cv

Level 0Keras 도제
0 XP0/97 lessons0/20 achievements
0/120 XP to next level120 XP to go0% complete

per-box 가 아니라 per-pixel

detection 은 객체마다 box 를 그렸어. segmentation 은 더 정밀해 — 모든 pixel 에 class 를 매겨서, 출력이 입력이랑 같은 H×W 의 label map 이야. shape 자체가 중요할 때 필요한 거 — 종양의 정확한 경계, 차 앞의 주행 가능 영역, 피사체를 배경에서 떼어내는 matte.

문제가 다른 두 갈래

  • Semantic segmentation (예: DeepLabV3Plus, SegFormer) — 모든 pixel 에 class label. DeepLab 은 atrous (dilated) convolution 으로 해상도 안 잃고 여러 scale 을 한 번에 보고, SegFormer 는 transformer 시대 버전. 신경 쓰는 class 집합이 고정돼 있을 때.
  • Salient / boundary-aware (예: BASNet) — class 정체성보다 깔끔한 edge 를 최적화하면서 전경/배경 분리. matting / cut-out 용도.

전부 같은 from_preset 문으로 로드되고, pretrained backbone 타고, 아무 backend 에서 돌아. 내재화할 건 출력 규약: channel 축으로 argmax 하면 pixel 당 단일 label 나오는 class map.

Code

semantic segmenter 로드 + 출력 읽기·python
import keras
import keras_cv

# Semantic segmentation: one class per pixel
segmenter = keras_cv.models.SegFormerB0.from_preset(
    "segformer_b0_ade20k"
)

logits = segmenter.predict(images)        # (B, H, W, num_classes)
masks = keras.ops.argmax(logits, axis=-1) # (B, H, W) class label per pixel

External links

Exercise

SAM 을 from_preset 로드. sample 이미지 한 장. 서로 다른 객체 세 군데에 point prompt (image 좌표) 주고 반환 mask 를 이미지 위에 overlay 시각화. 그 다음 한 객체에 *box* prompt 줘서 비교 — prompt 타입에 따라 mask 가 어떻게 달라지는지 메모. 마지막으로 같은 이미지에 SegFormer semantic segmenter 돌려서 대조: SAM 은 '이 덩어리', SegFormer 는 '이건 class 12'.
Hint
SAM 은 prompt 당 confidence 붙은 후보 mask 여러 개 반환 — 제일 높은 거 고르거나, 전부 시각화해서 SAM 이 해소 중인 모호함을 봐.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.