项目地址 https://github.com/ShuLiu1993/PANet
该存储库适用于CVPR 2018 Spotlight论文,“ 用于实例细分的路径聚合网络 ”,其中2017年COCO实例细分挑战赛排名第一,2017年COCO检测挑战赛第二名(团队名称:UCenter)和2018年场景理解第一名非结构化环境中自主导航的挑战(团队名称:TUTU)。
结构主要基于Detectron 使用Pytorch写的
需要的环境:
python packages
其中pycocotools的安装方法参见我的其他博客
在确保你的CUDA CUDNN PYTORCH 还有 上述的包之后
cd lib
sh make.sh
我忘了要不要setup.py了 应该是不用 编译了就OK
-------------单张推断 Demo
python tools/infer_simple.py --dataset coco2017 --cfg configs/panet/e2e_panet_R-50-FPN_2x_mask.yaml --load_ckpt /media/yang/56c81da5-109b-42e1-9e51-0f9e1396fa9d/yang/PANet-master/data/pretrained_model/panet_mask_step179999.pth --images /media/yang/56c81da5-109b-42e1-9e51-0f9e1396fa9d/yang/PANet-master/demo/33823288584_1d21cf0a26_k.jpg --output_dir /media/yang/56c81da5-109b-42e1-9e51-0f9e1396fa9d/yang/PANet-master/
-------------批量推断 Demo
python tools/infer_simple.py --dataset coco2017 --cfg configs/panet/e2e_panet_R-50-FPN_2x_mask.yaml --load_ckpt /media/yang/56c81da5-109b-42e1-9e51-0f9e1396fa9d/yang/PANet-master/data/pretrained_model/panet_mask_step179999.pth --image_dir /media/yang/56c81da5-109b-42e1-9e51-0f9e1396fa9d/yang/PANet-master/demo/sample_images/ --output_dir /media/yang/56c81da5-109b-42e1-9e51-0f9e1396fa9d/yang/PANet-master/
其中权重下载地址为https://drive.google.com/file/d/1-pVZQ3GR6Aj7KJzH9nWoRQ-Lts8IcdMS/view?usp=sharing
我用的Coco-Annotator标记的 关于这个标注工具的用法后面会说
格式和coco2014做到一致就行
文件结构我用的
.
├── coco-annotations
│ ├── captions_train2014.json
│ ├── captions_val2014.json
│ ├── instances_minival2014.json
│ ├── instances_train2014.json
│ ├── instances_val2014.json
│ ├── instances_val2017.json
├── configs
│ ├── baselines
│ │ ├── e2e_faster_rcnn_R-101-FPN_1x.yaml
│ │ ├── e2e_faster_rcnn_R-101-FPN_2x.yaml
...
│ ├── getting_started
│ │ ├── tutorial_1gpu_e2e_faster_rcnn_R-50-FPN.yaml
│ │ ├── tutorial_2gpu_e2e_faster_rcnn_R-50-FPN.yaml
│ │ ├── tutorial_4gpu_e2e_faster_rcnn_R-50-FPN.yaml
│ │ └── tutorial_8gpu_e2e_faster_rcnn_R-50-FPN.yaml
│ ├── gn_baselines
│ │ ├── e2e_mask_rcnn_R-101-FPN_2x_gn.yaml
...
│ └── panet
│ ├── e2e_panet_R-50-FPN_1x_det_2fc.yaml
│ ├── e2e_panet_R-50-FPN_1x_det.yaml
│ └── e2e_panet_R-50-FPN_2x_mask.yaml
├── data
│ ├── cache
│ │ └── coco_2014_train_gt_roidb.pkl
│ ├── coco
│ │ ├── annotations
│ │ │ ├── instances_train2014.json
│ │ │ └── instances_val2014.json
│ │ └── images
│ │ ├── train2014
│ │ │ ├── 1000.jpg
│ │ │ ├── 1001.jpg
│ │ │ ├── 1002.jpg
│ └── pretrained_model
│ ├── panet_mask_step179999.pth
│ ├── resnet101_caffe.pth
│ └── resnet50_caffe.pth
├── demo
│ ├── 33823288584_1d21cf0a26_k-detectron-R101-FPN.jpg
│ ├── convert_pdf2img.sh
│ ├── e2e_mask_rcnn_R-50-C4
│ │ └── train_from_scratch_epoch1_bs4
│ │ ├── img1.jpg
│ │ ├── img2.jpg
│ │ ├── img3.jpg
│ │ └── img4.jpg
│ ├── img1_keypoints-detectron-R50-FPN.jpg
...
│ ├── sample_images
│ │ ├── img1.jpg
│ │ ├── img2.jpg
│ │ ├── img3.jpg
│ │ └── img4.jpg
│ └── sample_images_keypoints
│ ├── img1_keypoints.jpg
│ └── img2_keypoints.jpg
├── images
│ ├── 0L8A0059.jpg
│ ├── 0L8A0066.jpg
├── lib
│ ├── core
│ │ ├── config.py
│ │ ├── __init__.py
│ │ ├── __pycache__
│ │ │ ├── config.cpython-36.pyc
│ │ │ ├── __init__.cpython-36.pyc
│ │ │ └── test.cpython-36.pyc
│ │ ├── test_engine.py
│ │ └── test.py
│ ├── datasets
│ │ ├── cityscapes
│ │ │ ├── coco_to_cityscapes_id.py
│ │ │ ├── __init__.py
│ │ │ └── tools
│ │ │ ├── convert_cityscapes_to_coco.py
│ │ │ └── convert_coco_model_to_cityscapes.py
│ │ ├── cityscapes_json_dataset_evaluator.py
│ │ ├── dataset_catalog.py
│ │ ├── dummy_datasets.py
│ │ ├── __init__.py
│ │ ├── json_dataset_evaluator.py
│ │ ├── json_dataset.py
│ │ ├── __pycache__
│ │ │ ├── dataset_catalog.cpython-36.pyc
│ │ │ ├── dummy_datasets.cpython-36.pyc
│ │ │ ├── __init__.cpython-36.pyc
│ │ │ ├── json_dataset.cpython-36.pyc
│ │ │ └── roidb.cpython-36.pyc
│ │ ├── roidb.py
│ │ ├── task_evaluation.py
│ │ ├── voc_dataset_evaluator.py
│ │ ├── VOCdevkit-matlab-wrapper
│ │ │ ├── get_voc_opts.m
│ │ │ ├── voc_eval.m
│ │ │ └── xVOCap.m
│ │ └── voc_eval.py
│ ├── make.sh
│ ├── model
│ │ ├── __init__.py
│ │ ├── nms
│ │ │ ├── build.py
│ │ │ ├── _ext
│ │ │ │ ├── __init__.py
│ │ │ │ └── nms
│ │ │ │ ├── __init__.py
│ │ │ │ └── _nms.so
│ │ │ ├── __init__.py
│ │ │ ├── make.sh
│ │ │ ├── nms_gpu.py
│ │ │ ├── nms_kernel.cu
│ │ │ ├── nms_wrapper.py
│ │ │ └── src
│ │ │ ├── nms_cuda.c
│ │ │ ├── nms_cuda.h
│ │ │ ├── nms_cuda_kernel.cu
│ │ │ ├── nms_cuda_kernel.cu.o
│ │ │ └── nms_cuda_kernel.h
│ │ ├── __pycache__
│ │ │ └── __init__.cpython-36.pyc
│ │ ├── roi_align
│ │ │ ├── build.py
│ │ │ ├── _ext
│ │ │ │ ├── __init__.py
│ │ │ │ └── roi_align
│ │ │ │ └── __init__.py
│ │ │ ├── functions
│ │ │ │ ├── __init__.py
│ │ │ │ └── roi_align.py
│ │ │ ├── __init__.py
│ │ │ ├── make.sh
│ │ │ ├── modules
│ │ │ │ ├── __init__.py
│ │ │ │ └── roi_align.py
│ │ │ └── src
│ │ │ ├── roi_align_cuda.c
│ │ │ ├── roi_align_cuda.h
│ │ │ ├── roi_align_kernel.cu
│ │ │ └── roi_align_kernel.h
│ │ ├── roi_crop
│ │ │ ├── build.py
│ │ │ ├── _ext
│ │ │ │ ├── crop_resize
│ │ │ │ │ └── __init__.py
│ │ │ │ ├── __init__.py
│ │ │ │ ├── __pycache__
│ │ │ │ │ └── __init__.cpython-36.pyc
│ │ │ │ └── roi_crop
│ │ │ │ ├── __init__.py
│ │ │ │ ├── __pycache__
│ │ │ │ │ └── __init__.cpython-36.pyc
│ │ │ │ └── _roi_crop.so
│ │ │ ├── functions
│ │ │ │ ├── crop_resize.py
│ │ │ │ ├── gridgen.py
│ │ │ │ ├── __init__.py
│ │ │ │ ├── __pycache__
│ │ │ │ │ ├── __init__.cpython-36.pyc
│ │ │ │ │ └── roi_crop.cpython-36.pyc
│ │ │ │ └── roi_crop.py
│ │ │ ├── __init__.py
│ │ │ ├── make.sh
│ │ │ ├── modules
│ │ │ │ ├── gridgen.py
│ │ │ │ ├── __init__.py
│ │ │ │ └── roi_crop.py
│ │ │ ├── __pycache__
│ │ │ │ └── __init__.cpython-36.pyc
│ │ │ └── src
│ │ │ ├── roi_crop.c
│ │ │ ├── roi_crop_cuda.c
│ │ │ ├── roi_crop_cuda.h
│ │ │ ├── roi_crop_cuda_kernel.cu
│ │ │ ├── roi_crop_cuda_kernel.cu.o
│ │ │ ├── roi_crop_cuda_kernel.h
│ │ │ └── roi_crop.h
│ │ ├── roi_pooling
│ │ │ ├── build.py
│ │ │ ├── _ext
│ │ │ │ ├── __init__.py
│ │ │ │ ├── __pycache__
│ │ │ │ │ └── __init__.cpython-36.pyc
│ │ │ │ └── roi_pooling
│ │ │ │ ├── __init__.py
│ │ │ │ ├── __pycache__
│ │ │ │ │ └── __init__.cpython-36.pyc
│ │ │ │ └── _roi_pooling.so
│ │ │ ├── functions
│ │ │ │ ├── __init__.py
│ │ │ │ ├── __pycache__
│ │ │ │ │ ├── __init__.cpython-36.pyc
│ │ │ │ │ └── roi_pool.cpython-36.pyc
│ │ │ │ └── roi_pool.py
│ │ │ ├── __init__.py
│ │ │ ├── modules
│ │ │ │ ├── __init__.py
│ │ │ │ └── roi_pool.py
│ │ │ ├── __pycache__
│ │ │ │ └── __init__.cpython-36.pyc
│ │ │ └── src
│ │ │ ├── roi_pooling.c
│ │ │ ├── roi_pooling_cuda.c
│ │ │ ├── roi_pooling_cuda.h
│ │ │ ├── roi_pooling.cu.o
│ │ │ ├── roi_pooling.h
│ │ │ ├── roi_pooling_kernel.cu
│ │ │ └── roi_pooling_kernel.h
│ │ └── utils
│ │ ├── __init__.py
│ │ └── net_utils.py
│ ├── modeling
│ │ ├── collect_and_distribute_fpn_rpn_proposals.py
│ │ ├── fast_rcnn_heads.py
│ │ ├── FPN.py
│ │ ├── generate_anchors.py
│ │ ├── generate_proposal_labels.py
│ │ ├── generate_proposals.py
│ │ ├── __init__.py
│ │ ├── keypoint_rcnn_heads.py
│ │ ├── mask_rcnn_heads.py
│ │ ├── model_builder.py
│ │ ├── __pycache__
│ │ │ ├── collect_and_distribute_fpn_rpn_proposals.cpython-36.pyc
│ │ │ ├── fast_rcnn_heads.cpython-36.pyc
│ │ │ ├── FPN.cpython-36.pyc
│ │ │ ├── generate_anchors.cpython-36.pyc
│ │ │ ├── generate_proposal_labels.cpython-36.pyc
│ │ │ ├── generate_proposals.cpython-36.pyc
│ │ │ ├── __init__.cpython-36.pyc
│ │ │ ├── keypoint_rcnn_heads.cpython-36.pyc
│ │ │ ├── mask_rcnn_heads.cpython-36.pyc
│ │ │ ├── model_builder.cpython-36.pyc
│ │ │ ├── ResNet.cpython-36.pyc
│ │ │ └── rpn_heads.cpython-36.pyc
│ │ ├── ResNet.py
│ │ ├── roi_xfrom
│ │ │ ├── __init__.py
│ │ │ ├── __pycache__
│ │ │ │ └── __init__.cpython-36.pyc
│ │ │ └── roi_align
│ │ │ ├── build.py
│ │ │ ├── _ext
│ │ │ │ ├── __init__.py
│ │ │ │ ├── __pycache__
│ │ │ │ │ └── __init__.cpython-36.pyc
│ │ │ │ └── roi_align
│ │ │ │ ├── __init__.py
│ │ │ │ ├── __pycache__
│ │ │ │ │ └── __init__.cpython-36.pyc
│ │ │ │ └── _roi_align.so
│ │ │ ├── functions
│ │ │ │ ├── __init__.py
│ │ │ │ ├── __pycache__
│ │ │ │ │ ├── __init__.cpython-36.pyc
│ │ │ │ │ └── roi_align.cpython-36.pyc
│ │ │ │ └── roi_align.py
│ │ │ ├── __init__.py
│ │ │ ├── make.sh
│ │ │ ├── modules
│ │ │ │ ├── __init__.py
│ │ │ │ └── roi_align.py
│ │ │ ├── __pycache__
│ │ │ │ └── __init__.cpython-36.pyc
│ │ │ └── src
│ │ │ ├── roi_align_cuda.c
│ │ │ ├── roi_align_cuda.h
│ │ │ ├── roi_align_kernel.cu
│ │ │ ├── roi_align_kernel.cu.o
│ │ │ └── roi_align_kernel.h
│ │ └── rpn_heads.py
│ ├── nn
│ │ ├── functional.py
│ │ ├── __init__.py
│ │ ├── init.py
│ │ ├── modules
│ │ │ ├── affine.py
│ │ │ ├── __init__.py
│ │ │ ├── normalization.py
│ │ │ ├── __pycache__
│ │ │ │ ├── affine.cpython-36.pyc
│ │ │ │ ├── __init__.cpython-36.pyc
│ │ │ │ ├── normalization.cpython-36.pyc
│ │ │ │ └── upsample.cpython-36.pyc
│ │ │ └── upsample.py
│ │ ├── parallel
│ │ │ ├── data_parallel.py
│ │ │ ├── _functions.py
│ │ │ ├── __init__.py
│ │ │ ├── parallel_apply.py
│ │ │ ├── __pycache__
│ │ │ │ ├── data_parallel.cpython-36.pyc
│ │ │ │ ├── _functions.cpython-36.pyc
│ │ │ │ ├── __init__.cpython-36.pyc
│ │ │ │ ├── parallel_apply.cpython-36.pyc
│ │ │ │ ├── replicate.cpython-36.pyc
│ │ │ │ └── scatter_gather.cpython-36.pyc
│ │ │ ├── replicate.py
│ │ │ └── scatter_gather.py
│ │ └── __pycache__
│ │ ├── functional.cpython-36.pyc
│ │ ├── __init__.cpython-36.pyc
│ │ └── init.cpython-36.pyc
│ ├── roi_data
│ │ ├── data_utils.py
│ │ ├── fast_rcnn.py
│ │ ├── __init__.py
│ │ ├── keypoint_rcnn.py
│ │ ├── loader.py
│ │ ├── mask_rcnn.py
│ │ ├── minibatch.py
│ │ ├── __pycache__
│ │ │ ├── data_utils.cpython-36.pyc
│ │ │ ├── fast_rcnn.cpython-36.pyc
│ │ │ ├── __init__.cpython-36.pyc
│ │ │ ├── keypoint_rcnn.cpython-36.pyc
│ │ │ ├── loader.cpython-36.pyc
│ │ │ ├── mask_rcnn.cpython-36.pyc
│ │ │ ├── minibatch.cpython-36.pyc
│ │ │ └── rpn.cpython-36.pyc
│ │ └── rpn.py
│ ├── setup.py
│ └── utils
...
├── Outputs
│ └── e2e_panet_R-50-FPN_2x_mask
├── res
│ └── 0L8A0470.jpg
├── tools
│ ├── download_imagenet_weights.py
│ ├── infer_simple.py
│ ├── _init_paths.py
│ ├── __pycache__
│ │ └── _init_paths.cpython-36.pyc
│ ├── test_net.py
│ ├── train_net.py
│ └── train_net_step.py
└── 启动脚本
tools/train_net_step.py中第163行 把分类书改为自己的分类数+1
我的有两类 那个位置就写3
配置文件 configs/panet/e2e_panet_R-50-FPN_2x_mask.ymal
我用的这个 所以就用这个作为事例
第6行 你有几个GPU就写几
第13行 根据自己情况来确定学习率的变化 比如我的
MAX_ITER: 58000
STEPS: [0, 12000,22000,32000,42000,52000]
第36/41行 设为自己的图片尺寸
第2个配置文件 lib/core/config.py
第51行 我的GPU是1080Ti 图像尺寸1440*960 只能跑一张 我就设为1
#从头开始训练
python tools/train_net_step.py --dataset coco2014 --cfg configs/panet/e2e_panet_R-50-FPN_2x_mask.yaml --use_tfboard
#继续上次训练
这里有个问题 我猜应该是
python tools/train_net_step.py --dataset coco2014 --cfg configs/panet/e2e_panet_R-50-FPN_2x_mask.yaml --start_step 要恢复的Epoch数 --resume
-------------批量推斷 自己的
python tools/infer_simple.py --dataset coco2017 --cfg configs/panet/e2e_panet_R-50-FPN_2x_mask.yaml --load_ckpt /media/yang/56c81da5-109b-42e1-9e51-0f9e1396fa9d/yang/PANet-master/Outputs/e2e_panet_R-50-FPN_2x_mask/Jun24-17-02-29_yang-desktop_step/ckpt/model_step17999.pth --image_dir /media/yang/56c81da5-109b-42e1-9e51-0f9e1396fa9d/yang/PANet-master/images/ --output_dir /media/yang/56c81da5-109b-42e1-9e51-0f9e1396fa9d/yang/PANet-master/res/ --merge_pdfs ture
-------------单张推断 自己的
python tools/infer_simple.py --dataset coco2017 --cfg configs/panet/e2e_panet_R-50-FPN_2x_mask.yaml --load_ckpt /media/yang/56c81da5-109b-42e1-9e51-0f9e1396fa9d/yang/PANet-master/Outputs/e2e_panet_R-50-FPN_2x_mask/Jun24-17-02-29_yang-desktop_step/ckpt/model_step17999.pth --images /media/yang/56c81da5-109b-42e1-9e51-0f9e1396fa9d/yang/PANet-master/images/0L8A0470.jpg --output_dir /media/yang/56c81da5-109b-42e1-9e51-0f9e1396fa9d/yang/PANet-master/res/
换成自己的权重就行
实测效果比maskrcnn好了不少 和HTC不相上下