Swin-Transformer object detection 环境配置

Swin-Transformer object detection 环境配置

1. 下载Swin-Transformer Object Detection官方代码到服务器

git clone https://github.com/SwinTransformer/Swin-Transformer-Object-Detection.git

2. 创建 conda虚拟环境

conda create -n swin python=3.7
conda activate swin

3. 配置环境

conda install pytorch==1.7.0 torchvision cudatoolkit=10.2 -c pytorch
pip install cython matplotlib opencv-python

4. 安装 mmcv

根据CUDA版本和pytorch版本参考mmcv官方链接安装 mmcv-full

pip install mmcv-full=={mmcv_version} -f https://download.openmmlab.com/mmcv/dist/cu102/torch1.7.0/index.html

5. 安装 MMDetection

方法一:

pip install openmim
mim install mmdet

方法二:

git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection
pip install -r requirements/build.txt
pip install -v -e .

6. 安装apex

git clone https://github.com/NVIDIA/apex
cd apex
python setup.py install
pip install -v --disable-pip-version-check --no-cache-dir ./

7. 运行程序

python tools/train.py configs/swin/swim_base-cascade_rcnn.py --gpus 4 --work-dir work_dirs/swin

报错

AssertionError: MMCV==1.4.5 is used but incompatible. Please install mmcv>=1.2.4, <=1.4.0.

解决办法:降低mmcv版本

pip install mmcv-full==1.3.17 -f https://download.openmmlab.com/mmcv/dist/cu101/torch1.6.0/index.html

再次运行,报错

TypeError: MaskRCNN: SwinTransformer: init() got an unexpected keyword argument ‘embed_dim’

解决办法

按照mmdetection官网指示,运行:

pip install -v -e .

你可能感兴趣的:(CV,目标检测,计算机视觉,python,transformer)