第一步:重新建conda虚拟环境
conda create -n transmil python=3.7 -y
conda activate transmil
第二步:安装pytorch
conda install pytorch==1.7.1 torchvision==0.8.2 torchaudio==0.7.2 cudatoolkit=11.0 -c pytorch
第三步:修改TransMIL代码中提供的requirements.txt文件内容
修改前:
addict==2.2.1
albumentations==0.4.3
einops==0.3.0
matplotlib==3.5.1
numpy==1.20.3
nystrom-attention==0.0.9
omegaconf==2.2.3
opencv-python==4.2.0.34
opencv-python-headless==4.2.0.34
pandas==1.2.3
Pillow==8.4.0
pytorch-lightning==1.2.3
修改后:
addict==2.2.1
albumentations==0.4.3
einops==0.3.0
matplotlib==3.5.1
numpy==1.20.3
nystrom-attention==0.0.9
opencv-python==4.2.0.34
opencv-python-headless==4.2.0.34
pandas==1.2.3
Pillow==8.4.0
pytorch-lightning==1.2.3
pytorch-toolbelt==0.4.0
torchmetrics==0.4.1
第四步:使用pip安装修改后的requirements.txt中的包
pip install -r requirements.txt
第五步:修改nystrom_attention.py中的语句
将q *= self.scale
修改为q = q * self.scale
nystrom_attention.py所在位置:每个人的都不一样,在此,我提供一下我的文件位置,大家可以做个参考:
/usr/local/miniconda3/envs/transmil/lib/python3.7/site-packages/nystrom_attention/nystrom_attention.py
参考
https://github.com/szc19990412/TransMIL/issues/33
本文解决方案是github上其他大佬提供的,上面这个是链接。
感谢大佬们的分享,本博客只用作学习笔记,侵删!