Git Product home page Git Product logo

m-sam's Introduction

M-SAM [Paper]

We introduce Mask-Enhanced SAM (M-SAM), an innovative architecture tailored for 3D tumor lesion segmentation. This method is elaborated on the paper Mask-Enhanced Segment Anything Model for Tumor Lesion Semantic Segmentation.

๐ŸŒŸ Highlights

  • We introduce a novel Mask-Enhanced SAM (M-SAM) architecture to explore the application of SAM in the medical domain, validating its effectiveness in tumor lesion segmentation.
  • We propose a Mask-Enhanced Adapter (MEA) to align the positional information of the prompt with the semantic information of the input image, optimizing precise guidance for mask prediction. Based on the design of the MEA, we further implement an iterative refining scheme to refine masks, yielding improved performances.
  • With updates to only about 20% of the parameters, our model outperforms state-of-the-art medical image segmentation methods on five tumor lesion segmentation benchmarks. Additionally, we validate the effectiveness of our method in domain transferring.

๐Ÿซฑ A Quick Overview

M-SAM consists of multiple stages of iterative refinement, which makes it possible to refine the predicted segmentation masks iteratively, thus obtaining more accurate segmentation boundaries progressively.

image

Our MEA is proposed to aggregate the image embedding with corresponding mask, so that the updated image embedding can perceive position priors of the lesion regions.

image

๐Ÿซฑ Requirement

Install the environment:

pip install -r requirements.txt

Then download SAM checkpoint, and put it at .work_dir/SAM/

๐Ÿซฑ Usage

  1. Prepare your own train dataset and refer to the samples in M-SAM/demo to replace them according to your specific scenario. The target file structures should be like the following:
data/train
      โ”œโ”€โ”€ ct_BraTS
      โ”‚ โ”œโ”€โ”€ imagesTr
      โ”‚ โ”‚ โ”œโ”€โ”€ word_0025.nii.gz
      โ”‚ โ”‚ โ”œโ”€โ”€ ...
      โ”‚ โ”œโ”€โ”€ labelsTr
      โ”‚ โ”‚ โ”œโ”€โ”€ word_0025.nii.gz
      โ”‚ โ”‚ โ”œโ”€โ”€ ...
      โ”‚ โ”€โ”€ ct_LiTS
      โ”‚ โ”œโ”€โ”€ imagesTr
      โ”‚ โ”‚ โ”œโ”€โ”€ word_0025.nii.gz
      โ”‚ โ”‚ โ”œโ”€โ”€ ...
      โ”‚ โ”œโ”€โ”€ labelsTr
      โ”‚ โ”‚ โ”œโ”€โ”€ word_0025.nii.gz
      โ”‚ โ”‚ โ”œโ”€โ”€ ...
      โ”œโ”€โ”€ ...
  1. Start Training!
cd ./M-SAM
python train_msam.py

This will start the training process of the M-SAM model on your prepared data. The key options are listed below:

  • task_name: task name
  • checkpoint: pre-trained checkpoint
  • work_dir: results folder for log and ckpt
  • num_epochs: number of epoches
  • batch_size: batch size for training
  • num_workers: the num_workers
  • lr: learning rate for training
  • lr_scheduler: the choices of scheduler, default is multisteplr

๐Ÿ’กNote: Use the --checkpoint to set the pre-trained weight path, if no checkpoint is found in the specified path, the model will undergo training from scratch.

  1. Evaluation Prepare your own test dataset and refer to the samples in M-SAM/demo to replace them according to your specific scenario. The target file structures should be like the following:
data/test
      โ”œโ”€โ”€ adrenal
      โ”‚ โ”œโ”€โ”€ ct_WORD
      โ”‚ โ”‚ โ”œโ”€โ”€ imagesTr
      โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ word_0027.nii.gz
      โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ ...
      โ”‚ โ”‚ โ”œโ”€โ”€ labelsTr
      โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ word_0027.nii.gz
      โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ ...
      โ”œโ”€โ”€ liver
      โ”‚ โ”œโ”€โ”€ ct_WORD
      โ”‚ โ”‚ โ”œโ”€โ”€ imagesTr
      โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ word_0029.nii.gz
      โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ ...
      โ”‚ โ”‚ โ”œโ”€โ”€ labelsTr
      โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ word_0029.nii.gz
      โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ ...
      โ”œโ”€โ”€ ...

And

cd ./M-SAM
python test_msam.py

This will start the testing process of the M-SAM model on your prepared data.

๐Ÿ“ง Citation

@article{shi2024mask,
  title={Mask-Enhanced Segment Anything Model for Tumor Lesion Semantic Segmentation},
  author={Shi, Hairong and Han, Songhao and Huang, Shaofei and Liao, Yue and Li, Guanbin and Kong, Xiangxing and Zhu, Hua and Wang, Xiaomu and Liu, Si},
  journal={arXiv preprint arXiv:2403.05912},
  year={2024}
}

๐Ÿค Acknowledgement

๐Ÿ“š License

This project is released under the Apache 2.0 license.

m-sam's People

Contributors

nanase1025 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.