본문으로 건너뛰기
Skillpedia
이미지 및 아이콘14k · #11236

segment-anything-model

하는 일

이 스킬은 이미지 분할을 위한 기반 모델인 Segment Anything Model을 설명합니다. 학습 없이 사진에서 물체를 분리해야 하는 디자이너, 연구자, 개발자를 위한 내용입니다.

사용하는 경우

  • ✓사진에서 특정 물체를 오려 내야 할 때.
  • ✓주석 도구에 쓸 마스크를 만들거나 학습 데이터 세트를 만들고 싶을 때.
  • ✓의료나 위성 사진처럼 특수한 이미지를 다루며 제로샷 분할이 필요할 때.

스킬 링크

https://github.com/Orchestra-Research/AI-Research-SKILLs/blob/main/18-multimodal/segment-anything/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/Orchestra-Research/AI-Research-SKILLs/blob/main/18-multimodal/segment-anything/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“이 사진에서 커피 머그컵만 오려 내서 배경이 투명한 버전을 만들어 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

점, 경계 상자, 이전 마스크 같은 프롬프트를 주면 모델이 맞는 물체의 형태를 돌려줍니다. 이미지 안의 모든 물체에 대한 마스크를 자동으로 만들 수도 있습니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Segment Anything Model (SAM)

Comprehensive guide to using Meta AI's Segment Anything Model for zero-shot image segmentation.

When to use SAM

Use SAM when:

  • Need to segment any object in images without task-specific training
  • Building interactive annotation tools with point/box prompts
  • Generating training data for other vision models
  • Need zero-shot transfer to new image domains
  • Building object detection/segmentation pipelines
  • Processing medical, satellite, or domain-specific images

Key features:

  • Zero-shot segmentation: Works on any image domain without fine-tuning
  • Flexible prompts: Points, bounding boxes, or previous masks
  • Automatic segmentation: Generate all object masks automatically
  • High quality: Trained on 1.1 billion masks from 11 million images
  • Multiple model sizes: ViT-B (fastest), ViT-L, ViT-H (most accurate)
  • ONNX export: Deploy in browsers and edge devices

Use alternatives instead:

  • YOLO/Detectron2: For real-time object detection with classes
  • Mask2Former: For semantic/panoptic segmentation with categories
  • GroundingDINO + SAM: For text-prompted segmentation
  • SAM 2: For video segmentation tasks

Quick start

Installation

# From GitHub
pip install git+https://github.com/facebookresearch/segment-anything.git

# Optional dependencies
pip install opencv-python pycocotools matplotlib

# Or use HuggingFace transformers
pip install transformers

Download checkpoints

# ViT-H (largest, most accurate) - 2.4GB
wget https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth

# ViT-L (medium) - 1.2GB
wget https://dl.fbaipublicfiles.com/segment_anything/sam_vit_l_0b3195.pth

# ViT-B (smallest, fastest) - 375MB
wget https://dl.fbaipublicfiles.com/segment_anything/sam_vit_b_01ec64.pth

Basic usage with SamPredictor

import numpy as np
from segment_anything import sam_model_registry, SamPredictor

# Load model
sam = sam_model_registry["vit_h"](checkpoint="sam_vit_h_4b8939.pth")
sam.to(device="cuda")

# Create predictor
predictor = SamPredictor(sam)

# Set image (computes embeddings once)
image = cv2.imread("image.jpg")
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
predictor.set_image(image)

# Predict with point prompts
input_point = np.array([[500, 375]])  # (x, y) coordinates
input_label = np.array([1])  # 1 = foreground, 0 = background

masks, scores, logits = predictor.predict(
    point_coords=input_point,
    point_labels=input_label,
    multimask_output=True  # Returns 3 mask options
)

# Select best mask
best_mask = masks[np.argmax(scores)]

HuggingFace Transformers

import torch
from PIL import Image
from transformers import SamModel, SamProcessor

# Load model and processor
model = SamModel.from_pretrained("facebook/sam-vit-huge")
processor = SamProcessor.from_pretrained("facebook/sam-vit-huge")
model.to("cuda")

# Process image with point prompt
image = Image.open("image.jpg")
input_points = [[[450, 600]]]  # Batch of points

inputs = processor(image, input_points=input_points, return_tensors="pt")
inputs = {k: v.to("cuda") for k, v in inputs.items()}

# Generate masks
with torch.no_grad():
    outputs = model(**inputs)

# Post-process masks to original size
masks = processor.image_processor.post_process_masks(
    outputs.pred_masks.cpu(),
    inputs["original_sizes"].cpu(),
    inputs["reshaped_input_sizes"].cpu()
)

Core concepts

Model architecture

SAM Architecture:
┌─────────────────┐     ┌─────────────────┐     ┌─────────────────┐
│  Image Encoder  │────▶│ Prompt Encoder  │────▶│  Mask Decoder   │
│     (ViT)       │     │ (Points/Boxes)  │     │ (Transformer)   │
└─────────────────┘     └─────────────────┘     └─────────────────┘
        │                       │                       │
   Image Embeddings      Prompt Embeddings         Masks + IoU
   (computed once)       (per prompt)             predictions

Model variants

Model Checkpoint Size Speed Accuracy
ViT-H vit_h 2.4 GB Slowest Best
ViT-L vit_l 1.2 GB Medium Good
ViT-B vit_b 375 MB Fastest Good

Prompt types

Prompt Description Use Case
Point (foreground) Click on object Single object selection
Point (background) Click outside object Exclude regions
Bounding box Rectangle around object La
자주 묻는 질문

학습이 필요한가요?

아니요. 이 스킬은 미세 조정 없이 새로운 이미지 영역에서도 제로샷으로 작동한다고 설명합니다.

어떤 모델 크기가 있나요?

이 스킬은 가장 빠른 ViT-B, 더 정확한 ViT-L과 ViT-H를 나열합니다.

브라우저에서 실행하도록 내보낼 수 있나요?

네. 이 스킬은 브라우저와 엣지 기기를 위한 ONNX 내보내기를 언급합니다.

상세 정보

작성자의 원본 설명

Foundation model for image segmentation with zero-shot transfer. Use when you need to segment any object in images using points, boxes, or masks as prompts, or automatically generate all object masks in an image.

repo: Orchestra-Research/AI-Research-SKILLs

인기도

GitHub 스타
14k
순위
#11236
라이선스
MIT
업데이트
2026. 10. 10.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬