当前位置:   article > 正文

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

anomalib

创建虚拟环境

yes | conda create -n anomalib_env python=3.8
conda activate anomalib_env
  • 1
  • 2

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

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/
  • 1
  • 2
  • 3
  • 4
  • 5

安装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口令)
  • 1
  • 2
  • 3

注意:这里如果之前在某个虚拟环境里安装过某个版本的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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

在这里插入图片描述

git拉取

git clone https://github.com/openvinotoolkit/anomalib.git
cd anomalib
pip install -e .
  • 1
  • 2
  • 3

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

git config --global --unset http.proxy
git config --global --unset https.proxy```
  • 1
  • 2

在这里插入图片描述
训练

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
  • 1
  • 2
  • 3
  • 4

训练前要安装这个
pip install wandb

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/空白诗007/article/detail/1011722
推荐阅读
  

闽ICP备14008679号