Skip to content

Latest commit

 

History

History
55 lines (39 loc) · 1.58 KB

README.md

File metadata and controls

55 lines (39 loc) · 1.58 KB

APW-SAM

Code for APW-SAM: Segment Anything Model Adaptation with Automatic Box Prompting and Wavelet-Enhanced Decoding for Medical Image Segmentation.

This repository contains the final paper model only:

  • MSG-Adapter in selected ViT-B blocks {1,3,5,7,9,11}
  • MLFBP (Pixel Shuffle upsampling) for automatic box prompts
  • WEMD + DAWF (Haar high-frequency fusion in the mask decoder)

Ablation variants, 3D / Synapse code, and unused adapter / prompt / fusion modules are not included.

Setup

conda env create -f environment.yml
conda activate apw-sam

Place the official SAM ViT-B weights at:

pretrained_weights/sam_vit_b_01ec64.pth

Prepare datasets under data/<Kvasir|ISIC2018|BUSI|GLAS>/ with images/ and masks/.

Train / test

Run from this repository root (environment apw-sam or your existing wxc env):

conda run -n wxc python scripts/sam/train_SuperSAM.py \
  --config configs/Kvasir/apw_sam.yaml --gpu-ids 0

conda run -n wxc python scripts/sam/test_SuperSAM.py \
  --ckpt run/Kvasir/SUPERSAM/<exp>/checkpoint_best.pth.tar \
  --config run/Kvasir/SUPERSAM/<exp>/supersam_config.yaml \
  --gpu-ids 0

Configs for ISIC2018, BUSI, and GlaS are under configs/<dataset>/apw_sam.yaml.

Layout

APW_SAM/segment_anything/
  adapters/MSG_Adapter.py
  adapters/MonaAdapter.py          # MonaOp used by MSG-Adapter
  box_generator/multi_layer_feature_box_prompter.py
  up_sample/pixel_shuffle_up.py
  mask_decoder/mask_decoder_wemd.py
  fusion_modules/dual_attention_wavelet_fusion.py
  mask_generator/WaveletTransform.py