无监督异常定位的深度学习(二)_Anomalib安装

创建虚拟环境

yes | conda create -n anomalib_env python=3.8
conda activate anomalib_env

添加清华源(加快下载速度)

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro/

安装cuda、cudnn及对应版本pytorch

pip3 install torch==1.8.1+cu111 torchvision==0.9.1+cu111 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html
pip3 install torch==1.11.1+cu113 torchvision==0.11.1+cu113 torchaudio==0.10.0 -f https://download.pytorch.org/whl/torch_stable.html
pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu113(官网pip口令)

注意:这里如果之前在某个虚拟环境里安装过某个版本的cuda,即使删掉这个虚拟环境,这个版本的cuda也不能再安装了(不知道为什么)
还是在官网上查看pip口令吧,之前看各种教程均以失败告终
查看是否安装完成

python
import torch
 
torch.cuda.is_available()   # cuda是否可用
torch.version.cuda          # cuda版本     11.3
 
torch.backends.cudnn.is_available()  # cudnn是否可用
torch.backends.cudnn.version()       # cudnn版本   8302

torch.__version__                    #torch版本   1.12.1+cu113

在这里插入图片描述

git拉取

git clone https://github.com/openvinotoolkit/anomalib.git
cd anomalib
pip install -e .

我这里git clone切换到d盘了
git如果出问题,取消全局代理

git config --global --unset http.proxy
git config --global --unset https.proxy```

在这里插入图片描述
训练

By default python tools/train.py runs PADIM model on leather category from the MVTec AD (CC BY-NC-SA 4.0) dataset.

python tools/train.py    # Train PADIM on MVTec AD leather
python tools/train.py --config anomalib/models/patchcore/config.yaml

训练前要安装这个
pip install wandb

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值