MedSAM本地部署:
- 项目介绍:该工具可用于分割医学图像中的内容。项目地址:GitHub - bowang-lab/MedSAM: Segment Anything in Medical Images
- 本机项目环境,工具及电脑配置:python3.10,cuda12.4,torch2.2.0,annconda3
- 本地部署
打开Anaconda prompt
- 虚拟环境创建:conda create -n medsam python=3.10 -y
- 激活虚拟环境:conda activate medsam
- 进入项目所在文件夹,如:
D:
D:\liu\Project\MedSAM-main(进入上述网址将项目下载到本地)
- 安装对应版本的pytorch:pip install torch==2.2.0 torchvision==0.17.0 torchaudio==2.2.0 --index-url https://download.pytorch.org/whl/cu121(不可使用镜像加速,否则安装cpu版本)
- 使用项目的安装模块进行依赖安装:(pip install -e .)
可以加上-i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com 使用阿里源加速
- 进入MedSAM - Google Drive 将模型下载解压缩至项目中的(work_dir\MedSAM)路径中
- 在anaconda终端输入命令运行工具:python MedSAM_Inference.py
命令行参数增加:
-i input_img #输入图像
-o output path #输出路径
--box bounding box of the segmentation target #需分割区域
也可直接修改MedSAM_Inference.py文件中的默认参数
坐标与对应参数如图所示(所需参数为左下坐标与右上坐标)