Browse Source

Update 'README.md'

天问 2 years ago
parent
commit
a683f80346
1 changed files with 75 additions and 1 deletions
  1. 75 1
      README.md

+ 75 - 1
README.md

@@ -1,3 +1,77 @@
 # MedSAM
 
-segment-anything医学影像应用
+这是 MedSAM 的官方存储库: 医学图像分割。
+
+## 安装
+
+1. 创建一个虚拟环境 'conda create-n medsam python=3.10 -y' 并激活它 'condaa ctivate medsam'
+2. 安装 [Pytorch 2.0](https://pytorch.org/get-started/locally/)
+3. 'git clone https://github.com/bowang-lab/MedSAM'
+4. 进入 MedSAM 文件夹 'cd MedSAM' 并运行 'pip install -e .'
+
+## 在定制数据集上微调SAM
+
+我们提供了一个带有小数据集的分步教程,以帮助您快速开始培训过程。
+
+### 数据准备和预处理
+
+下载 [SAM checkpoint](https://dl.fbaipublicfiles.com/segment_anything/sam_vit_b_01ec64.pth),并将其放在 “work_dir/SAM/sam_vit_b_01ec64.pth”。
+
+下载演示 [dataset](https://zenodo.org/record/7860267) 并解压缩。
+
+该数据集包含50个腹部ct扫描,每个扫描包含一个带有13个器官的注释掩模。器官标签的名称可在 [MICCAI FLARE2022](https://flare22.grand-challenge.org/) 上获得。
+在本教程中,我们将微调胆囊分割的SAM。
+
+运行 pre-processing
+
+'''bash
+python pre_CT.py -i path_to_image_folder -gt path_to_gt_folder -o path_to_output
+'''
+
+- 分割数据集: 80% 训练和20% 测试
+- 图像归一化
+- 预计算图像嵌入
+- 将归一化图像、地面真相掩码和图像嵌入保存为 “npz” 文件
+
+> 注意: 医学图像具有各种数据格式。因此,一个脚本不可能处理所有这些不同的格式。在这里,我们提供了CT和非CT (例如,各种MR序列,PET图像) 图像预处理的两个典型示例。您可以使预处理代码适应您自己的数据集。
+
+### 模型训练 ([视频教程](https://drive.google.com/file/d/1EvVBTSa9L7pDTmUOp-MHXxGD1lrU9Txk/view?usp=share_link))
+
+请查看分步教程: finetune_and_inference_tutorial_3D_dataset.ipynb
+
+我们还提供了一个关于2D数据集 (png格式) 的教程: finetune_and_inference_tutorial_2D_dataset.ipynb
+
+您还可以在整个数据集上训练模型。
+1) 下载训练集 ([GoogleDrive](https://drive.google.com/drive/folders/1pwpAkWPe6czxkATG9SmVV0TP62NZiKld?usp=share_link))
+
+> 注意: 为了方便文件共享,我们压缩了 “npz” 文件中的每个图像和蒙版对。预先计算的图像嵌入太大 (需要约1 TB的空间)。您可以使用以下命令生成它
+
+2) 预先计算图像嵌入,并将图像嵌入和地面真相保存为 “.Npy” 文件。
+
+```bash
+python utils/precompute_img_embed.py -i path_to_train_folder -o ./data/Tr_npy
+```
+
+3) 训练模型
+
+```bash
+python train -i ./data/Tr_npy --task_name SAM-ViT-B --num_epochs 1000 --batch_size 8 --lr 1e-5
+```
+
+If you find this dataset valuable in your research, kindly acknowledge and credit the original data sources: [AMOS](https://zenodo.org/record/7262581), [BraTS2021](http://braintumorsegmentation.org/), [ACDC](https://www.creatis.insa-lyon.fr/Challenge/acdc/), [M\&Ms](https://www.ub.edu/mnms/), [PROMISE12](https://promise12.grand-challenge.org/) [ABCs](https://abcs.mgh.harvard.edu/), [AbdomenCT-1K](https://ieeexplore.ieee.org/document/9497733), [MSD](http://medicaldecathlon.com/), [KiTS19](https://kits19.grand-challenge.org/), [LiTS](https://competitions.codalab.org/competitions/17094), [COVID-19 CT-Seg](https://github.com/JunMa11/COVID-19-CT-Seg-Benchmark), [HECKTOR](https://www.sciencedirect.com/science/article/pii/S1361841521003819) [DRIVE](https://drive.grand-challenge.org/), [Colon gland](https://www.kaggle.com/datasets/sani84/glasmiccai2015-gland-segmentation), [polyp](https://www.nature.com/articles/s41597-023-01981-y), [instruments](https://www.synapse.org/#!Synapse:syn22427422), [Abdomen Ultrasound](https://www.kaggle.com/datasets/ignaciorlando/ussimandsegm), [Breast Ultrasound](https://www.sciencedirect.com/science/article/pii/S2352340919312181), [JSRT](http://imgcom.jsrt.or.jp/minijsrtdb/)
+
+
+
+## 推理
+
+下载模型 checkpoint ([GoogleDrive](https://drive.google.com/drive/folders/1bWv_Zs5oYLpGMAvbotnlNXJPq7ltRUvF?usp=share_link)) 和测试数据 ([GoogleDrive](https://drive.google.com/drive/folders/1Qx-4EM0MoarzAfvSIp9fkpk8UBrWM6EP?usp=share_link)),并将它们分别放入 “data/Test” 和 “work_dir/MedSAM'路径。
+
+运行
+
+```bash
+python MedSAM_Inference.py -i ./data/Test -o ./ -chk work_dir/MedSAM/medsam_20230423_vit_b_0.0.1.pth
+```
+
+分割结果可在 [here] 获得 (https://drive.google.com/drive/folders/1I8sgCRi30QtMix8DbDBIBTGDM_1FmSaO?usp=sharing)。
+
+DSC和NSD的实现代码可以得到 [这里](http://medicaldecathlon.com/files/Surface_distance_based_measures.ipynb)。