????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
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
运行效果

问题及参考
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
|