swin transformer的表现就不用多说了,简单记录其目标检测的运行环境搭建过程。
在这里插入图片描述

创建Pycharm工程

在这里插入图片描述

现在虚拟环境中只有以下几个包
在这里插入图片描述

github下载源码

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

复制源码到项目中
在这里插入图片描述

安装第三方库

conda install pytorch==1.7.1 torchvision==0.8.2 cudatoolkit=10.1 -c pytorch
pip install timm==0.3.2

pycocotools的安装(后来发现用不到)

pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
pip install -r requirements.txt    
pip install mmcv-full==1.2.4

这步安装时间比较长,长时间停在:Building wheel for mmcv-full (setup.py) …

pip install -v -e .

注意后面有个点

python setup.py develop

新建weights文件夹,用于放置权重文件
在这里插入图片描述

在这里插入图片描述

运行测试代码

python demo/image_demo.py demo/demo.jpg configs/swin/mask_rcnn_swin_tiny_patch4_window7_mstrain_480-800_adamw_3x_coco.py weights/mask_rcnn_swin_tiny_patch4_window7.pth
  • 如果没有出图,看最后面的问题及参考的Q2

运行效果

在这里插入图片描述

问题及参考

Q1:TypeError: MaskRCNN: SwinTransformer: init() got an unexpected keyword argument ‘embed_dim’:
A1:https://blog.csdn.net/weixin_44777827/article/details/122310873

Q2:UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
A2:https://blog.csdn.net/qq_41073715/article/details/105033751
添加如下代码

import matplotlib
matplotlib.use('TkAgg')

在这里插入图片描述

视频参考:https://www.bilibili.com/video/BV1KS4y1g7pc?spm_id_from=333.999.0.0

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐