文章名:《Explicit Boundary Guided Semi-Push-Pull Contrastive Learning for Supervised Anomaly Detection》
原作者代码:https://github.com/xcyao00/BGAD
复现过程:
系统Ubuntu22.04, PyTorch1.12.1,python3.9
下载原作者代码到本地,将MvTec AD数据集解压,我放到了BGAD/data,在训练过程遇到以下问题:
问题1,从huggingface_hub下载模型时,由于网络问题,无法连接到huggingface_hub,模型无法下载。
解决1,使用hf-mirror.com - Huggingface 镜像站中的解决办法,
export HF_ENDPOINT=https://hf-mirror.com
在main.py的main函数中,添加环境变量,从镜像网站下载模型。
if __name__ == '__main__':
os.environ['HF_ENDPOINT'] = 'https://hf-mirror.com'
warnings.filterwarnings('ignore')
main()
问题2,报错“'PIL.Image' has no attribute 'ANTIALIAS'”
解决2,按照AttributeError: module ‘PIL.Image‘ has no attribute ‘ANTIALIAS‘_attributeerror: module 'pil.image' has no attribut-CSDN博客的解决办法,将Image.ANTIALIAS替换为Image.LANCZOS;
问题3,报错“np.bool”
解决3,将np.bool替换为np.bool_
问题4,开始训练后,报错“No such file or directory: 'fg_mask/bottle/125.png'”
解决4,按照issuehttps://github.com/xcyao00/BGAD/issues/3,作者在源代码中提供了fg_mask.zip,将其解压在根目录即可