1.centos7 安装显卡驱动、cuda、cudnn-CSDN博客
4.Swin Transformer目标检测——训练数据集-CSDN博客
1.Swin-Transformer-Object-Detection环境配置
下载地址:
https://github.com/SwinTransformer/Swin-Transformer-Object-Detection
步骤1:解压缩
yum install unzip
unzip Swin-Transformer-Object-Detection-master.zip
步骤2:执行命令
pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
报错:gcc:error
解决方式,安装cython
pip install cython==0.29.36 -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
再执行 pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com 成功后如下图
再执行
python setup.py develop 成功后如下图
步骤3:安装mmcv-full安装
首先下载文件
https://download.openmmlab.com/mmcv/dist/cu111/torch1.8.0/index.html
版本选择1.4.0,下载好后,执行安装
pip install mmcv_full-1.4.0-cp38-cp38-manylinux1_x86_64.whl --trusted-host pypi.douban.com
步骤4:下载代码apex
解压缩文件后,进入文件目录,执行命令
pip install -v --no-cache-dir ./
如果出现如下错误
则先执行命令:export CUDA_HOME=/usr/local/cuda
然后再执行:
pip install -v --no-cache-dir ./
步骤5:测试
apex安装成功
步骤6:代码测试
新建代码文件test.py
from mmdet.apis import init_detector, inference_detector
config_file = 'configs/swin/mask_rcnn_swin_tiny_patch4_window7_mstrain_480-800_adamw_1x_coco.py' #配置文件路径
checkpoint_file = 'mask_rcnn_swin_tiny_patch4_window7_1x.pth' #权重文件路径
device = 'cuda:0'
# init a detector
model = init_detector(config_file, checkpoint_file, device=device)
# inference the demo image
img = 'demo/demo.jpg'
result = inference_detector(model, 'demo/demo.jpg')
model.show_result(img, result)
model.show_result(img, result, out_file='demo/demo_result.jpg')
首先下载预训练模型,在如下代码仓库的后面
https://github.com/SwinTransformer/Swin-Transformer-Object-Detection
下载链接,可以直接迅雷下载
其次执行python test.py
查看demo_result.jpg
运行成功。
参考地址:
Swin-Transformer目标检测_swin transformer目标检测_咚咚锵咚咚锵的博客-CSDN博客
Linux系统下搭建Swin Transformer目标检测环境_linux搭建swin_kiwi_hhh的博客-CSDN博客