1.源码
Mask2Former/INSTALL.md at main · facebookresearch/Mask2Former (github.com)
测试与训练
Mask2Former/GETTING_STARTED.md at main · facebookresearch/Mask2Former (github.com)
由于需要编译多尺度注意力机制,建议在ubuntu上配置环境,windows很麻烦
问题1:ImportError: cannot import name 'FrozenBatchNorm2d' from 'torchvision.ops'
timm模块的问题,降低版本即可
pip install timm==0.3.0
问题2:ModuleNotFoundError:
Please compile MultiScaleDeformableAttention CUDA op with the following commands:
`cd mask2former/modeling/pixel_decoder/ops`
`sh make.sh`
安装要求操作即可,windows上编译能成功,但是导入会出错,建议在ubuntu上运行,省事很多
问题3: TypeError: __init__() got an unexpected keyword argument 'dtype'
Installation — detectron2 0.6 documentation
此问题源自detectron安装,使用源码安装时,和你安装的pytorch等不匹配导致,建议按照上面detectron2官方的安装提示,安装预编译的版本;当然也可以升级/降级你的pytorch
问题4:AttributeError: module 'distutils' has no attribute 'version'
修改setuptools的版本
pip install setuptools==59.5.0
问题5:AttributeError: module 'numpy' has no attribute 'bool'.
numpy版本太高,1.20即可
pip install numpy==1.20
测试过程
python demo/demo.py --config-file /public/home/chenweiwen/Mask2Former/configs/coco/instance-segmentation/maskformer2_R50_bs16_50ep.yaml --input input/1.jpg --opts MODEL.WEIGHTS model_final_3c8ec9.pkl
训练过程
python train_net.py --num-gpus 4 --config-file configs/coco/instance-segmentation/maskformer2_R50_bs16_50ep1.yaml