赞
踩
创建虚拟环境
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
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。