Segment Anything Model (SAM, Meta AI)
- 미리 학습된 강력한 세그멘테이션 모델
- 사람이 따로 학습 데이터를 만들 필요 없이 미술 작품을 자동으로 분할 가능
모델 다운로드
https://github.com/facebookresearch/segment-anything?tab=readme-ov-file
GitHub - facebookresearch/segment-anything: The repository provides code for running inference with the SegmentAnything Model (S
The repository provides code for running inference with the SegmentAnything Model (SAM), links for downloading the trained model checkpoints, and example notebooks that show how to use the model. -...
github.com
아래로 내리다 보면, Model Checkpoints에 여러 모델이 있다.
VIT-H SAM model 클릭하여 다운로드.
python 코드와 같은 위치에, 다운로드한 sam_vit_h.pth 파일을 복붙하자.
from segment_anything import SamPredictor, sam_model_registry
# ----------------------------- SAM 설정 -----------------------------
sam = sam_model_registry['vit_h'](checkpoint='app/models/one_imageDetection/sam_vit_h.pth')
sam_predictor = SamPredictor(sam)
# image 넣어줘야함
def segment_with_sam(image, bbox):
sam_predictor.set_image(image)
bbox = np.array(bbox).reshape(1, 4)
masks, _, _ = sam_predictor.predict(box=bbox)
return masks[0]
'AI 및 Data Analysis' 카테고리의 다른 글
[Alzheimer] 녹음 파일 불러와서 이미지로 변환하기 (0) | 2025.03.23 |
---|---|
[ScRAT] STEP 1. Sample mixup (0) | 2025.03.20 |
[SK텔레콤 FLY AI] 대화형 작품 감상 AI 프로젝트 ; AI 흐름 개요 (0) | 2025.02.21 |
Metropolitan Museum of Art 데이터 CNN 학습하기 (1) | 2025.02.20 |
[LLM] VTS 기법 과정 설정 (0) | 2025.02.19 |