【TransMIL复现 / 解决Error】assert self.key_type is Any or isinstance(self.key_type, type)报错

第一步:重新建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上其他大佬提供的,上面这个是链接。
感谢大佬们的分享,本博客只用作学习笔记,侵删!

  • 5
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值