Mask2Former install

========
Linux:
conda activate pytorch2

git clone https://github.com/facebookresearch/detectron2.git
cd detectron2
pip install -e .

git clone https://github.com/facebookresearch/Mask2Former.git
cd Mask2Former
pip install -r requirements.txt

# 为 MSDeformAttn 编译 CUDA 内核
cd mask2former/modeling/pixel_decoder/ops
sh make.sh
========


========
Windows:
设置环境变量:
E:\dev\Qt5.14.2\Tools\mingw730_64\bin

修改D:\detectron2_windows\detectron2\layers\csrc\nms_rotated\nms_rotated_cuda.cu
#include 
/*#ifdef WITH_CUDA
#include "../box_iou_rotated/box_iou_rotated_utils.h"
#endif
// TODO avoid this when pytorch supports "same directory" hipification
#ifdef WITH_HIP
#include "box_iou_rotated/box_iou_rotated_utils.h"
#endif*/
#include "box_iou_rotated/box_iou_rotated_utils.h"

cd D:\detectron2_windows
pip install -e .

cd D:\Mask2Former_windows
pip install -r requirements.txt

Use git-bash:
cd "E:\miniconda3\Scripts"
source activate
conda activate pytorch2
cd "D:\Mask2Former_windows\mask2former\modeling\pixel_decoder\ops"
sh make.sh
========


下载预训练模型
https://github.com/facebookresearch/Mask2Former/blob/main/MODEL_ZOO.md

cd demo
python demo.py --config-file ../configs/coco/instance-segmentation/maskformer2_R50_bs16_50ep.yaml --input input1.jpg --output ./output/ --opts MODEL.WEIGHTS ../model_final_3c8ec9.pkl
python demo.py --config-file ../configs/coco/instance-segmentation/maskformer2_R50_bs16_50ep.yaml --input F:/mask/input_imgs/1000068_p4_upper.jpg --output ./output/ --opts MODEL.WEIGHTS ../output/model_0004999.pth

python train_net.py --num-gpus 1 --config-file ./configs/coco/instance-segmentation/maskformer2_R50_bs16_50ep.yaml --resume SOLVER.IMS_PER_BATCH 3 SOLVER.BASE_LR 0.0001
python train_net.py --num-gpus 1 --config-file ./configs/coco/instance-segmentation/swin/maskformer2_swin_large_IN21k_384_bs16_100ep.yaml --resume SOLVER.IMS_PER_BATCH 3 SOLVER.BASE_LR 0.0001
python train_net.py --num-gpus 1 --config-file ./configs/coco/instance-segmentation/swin/maskformer2_swin_small_bs16_50ep.yaml --resume SOLVER.IMS_PER_BATCH 2 SOLVER.BASE_LR 0.0001

python train_net.py --num-gpus 1 --config-file ./configs/coco/instance-segmentation/swin/maskformer2_swin_small_bs16_50ep.yaml --eval-only MODEL.WEIGHTS output/model_final.pth

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

1 × 2 =