"매 image 의 의 의 pixel-level 의 의 의 region 의 의 의 classify". 매 semantic (class only) / instance (per-object) / panoptic (both). 매 modern: SAM (Meta 2023), SAM 2 (video), Mask R-CNN, DeepLab v3+.
매 핵심
매 type
Semantic: 매 매 pixel 의 class.
Instance: 매 매 object 의 separate.
Panoptic: 매 semantic + instance.
매 famous
U-Net (Ronneberger 2015): 매 medical.
Mask R-CNN (He 2017): 매 instance.
DeepLab v3+ (Chen 2018): 매 atrous conv.
SAM (Meta 2023): 매 promptable, foundation.
SAM 2 (Meta 2024): 매 video.
Segment Anything in Medical.
매 응용
Medical (tumor, organ).
Autonomous driving.
Photo editing (background remove).
Industrial inspection.
Satellite / agriculture.
💻 패턴
SAM (segment anything)
fromsegment_anythingimportSamPredictor,sam_model_registrysam=sam_model_registry['vit_h'](checkpoint='sam_vit_h.pth').cuda()predictor=SamPredictor(sam)predictor.set_image(image)# 매 prompt: pointmasks,scores,logits=predictor.predict(point_coords=np.array([[500,375]]),point_labels=np.array([1]),# 매 1 = foregroundmultimask_output=True,)
fromdetectron2.engineimportDefaultPredictorfromdetectron2.configimportget_cfgfromdetectron2importmodel_zoocfg=get_cfg()cfg.merge_from_file(model_zoo.get_config_file('COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml'))cfg.MODEL.WEIGHTS=model_zoo.get_checkpoint_url('COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml')predictor=DefaultPredictor(cfg)outputs=predictor(image)# 매 boxes, masks, classes
defselect_to_label(model,unlabeled_imgs,k=10):"""매 매 image 의 의 entropy 의 highest."""entropies=[]forimginunlabeled_imgs:prob=model(img).softmax(1)ent=-(prob*prob.log()).sum(1).mean()entropies.append(ent)return[unlabeled_imgs[i]foriinnp.argsort(entropies)[-k:]]
Foundation model fine-tune (SAM-Med)
fromsegment_anythingimportsam_model_registrysam=sam_model_registry['vit_b']()# 매 freeze image encoder, train mask decoder on medical dataforpinsam.image_encoder.parameters():p.requires_grad=False
매 결정 기준
상황
Approach
Promptable
SAM / SAM 2
Medical
U-Net + transfer
Instance + class
Mask R-CNN
Real-time
YOLOv8-seg
Panoptic
Mask2Former
Video
SAM 2
Few-shot
SAM zero-shot
기본값: 매 modern = SAM 2 (zero-shot) + 매 fine-tune for domain + 매 Dice + BCE loss + 매 IoU eval + 매 active learning.