|
| 1 | + |
| 2 | +# Panoptic DeepLab |
| 3 | + |
| 4 | +基于PaddlePaddle实现[Panoptic Deeplab](https://arxiv.org/abs/1911.10194)全景分割算法。 |
| 5 | + |
| 6 | +Panoptic DeepLab首次证实了bottem-up算法能够达到state-of-the-art的效果。Panoptic DeepLab预测三个输出:Semantic Segmentation, Center Prediction 和 Center Regression。实例类别像素根据最近距离原则聚集到实例中心点得到实例分割结果。最后按照majority-vote规则融合语义分割结果和实例分割结果,得到最终的全景分割结果。 |
| 7 | +其通过将每一个像素赋值给每一个类别或实例达到分割的效果。 |
| 8 | + |
| 9 | + |
| 10 | +## Model Baselines |
| 11 | + |
| 12 | +### Cityscapes |
| 13 | +| Backbone | Batch Size |Resolution | Training Iters | PQ | SQ | RQ | AP | mIoU | Links | |
| 14 | +|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:| |
| 15 | +|ResNet50_OS32| 8 | 2049x1025|90000|58.35%|80.03%|71.52%|25.80%|79.18%|[model](https://bj.bcebos.com/paddleseg/dygraph/pnoptic_segmentation/panoptic_deeplab_resnet50_os32_cityscapes_2049x1025_bs1_90k_lr00005/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/pnoptic_segmentation/panoptic_deeplab_resnet50_os32_cityscapes_2049x1025_bs1_90k_lr00005/train.log)| |
| 16 | +|ResNet50_OS32| 64 | 1025x513|90000|60.32%|80.56%|73.56%|26.77%|79.67%|[model](https://bj.bcebos.com/paddleseg/dygraph/pnoptic_segmentation/panoptic_deeplab_resnet50_os32_cityscapes_1025x513_bs8_90k_lr00005/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/pnoptic_segmentation/panoptic_deeplab_resnet50_os32_cityscapes_1025x513_bs8_90k_lr00005/train.log)| |
| 17 | + |
| 18 | +## 环境准备 |
| 19 | + |
| 20 | +1. 系统环境 |
| 21 | +* PaddlePaddle >= 2.0.0 |
| 22 | +* Python >= 3.6+ |
| 23 | +推荐使用GPU版本的PaddlePaddle版本。详细安装教程请参考官方网站[PaddlePaddle](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/windows-pip.html) |
| 24 | + |
| 25 | +2. 下载PaddleSeg repo |
| 26 | +```shell |
| 27 | +git clone https://github.com/PaddlePaddle/PaddleSeg |
| 28 | +``` |
| 29 | + |
| 30 | +3. 安装paddleseg |
| 31 | +```shell |
| 32 | +cd PaddleSeg |
| 33 | +pip install -e . |
| 34 | +``` |
| 35 | + |
| 36 | +4. 进入PaddleSeg/contrib/PanopticDeepLab目录 |
| 37 | +```shell |
| 38 | +cd contrib/PanopticDeepLab |
| 39 | +``` |
| 40 | + |
| 41 | +## 数据集准备 |
| 42 | + |
| 43 | +将数据集放置于`data`目录下。 |
| 44 | + |
| 45 | +### Cityscapes |
| 46 | + |
| 47 | +前往[CityScapes官网](https://www.cityscapes-dataset.com/)下载数据集并整理成如下结构: |
| 48 | + |
| 49 | +``` |
| 50 | +cityscapes/ |
| 51 | +|--gtFine/ |
| 52 | +| |--train/ |
| 53 | +| | |--aachen/ |
| 54 | +| | | |--*_color.png, *_instanceIds.png, *_labelIds.png, *_polygons.json, |
| 55 | +| | | |--*_labelTrainIds.png |
| 56 | +| | | |--... |
| 57 | +| |--val/ |
| 58 | +| |--test/ |
| 59 | +| |--cityscapes_panoptic_train_trainId.json |
| 60 | +| |--cityscapes_panoptic_train_trainId/ |
| 61 | +| | |-- *_panoptic.png |
| 62 | +| |--cityscapes_panoptic_val_trainId.json |
| 63 | +| |--cityscapes_panoptic_val_trainId/ |
| 64 | +| | |-- *_panoptic.png |
| 65 | +|--leftImg8bit/ |
| 66 | +| |--train/ |
| 67 | +| |--val/ |
| 68 | +| |--test/ |
| 69 | +
|
| 70 | +``` |
| 71 | + |
| 72 | +安装CityscapesScripts |
| 73 | +```shell |
| 74 | +pip install git+https://github.com/mcordts/cityscapesScripts.git |
| 75 | +``` |
| 76 | + |
| 77 | +`*_panoptic.png` 生成命令(需找到`createPanopticImgs.py`文件): |
| 78 | +```shell |
| 79 | +python /path/to/cityscapesscripts/preparation/createPanopticImgs.py \ |
| 80 | + --dataset-folder data/cityscapes/gtFine/ \ |
| 81 | + --output-folder data/cityscapes/gtFine/ \ |
| 82 | + --use-train-id |
| 83 | +``` |
| 84 | + |
| 85 | +## 训练 |
| 86 | +```shell |
| 87 | +export CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 # 根据实际情况进行显卡数量的设置 |
| 88 | +python -m paddle.distributed.launch train.py \ |
| 89 | + --config configs/panoptic_deeplab/panoptic_deeplab_resnet50_os32_cityscapes_1025x513_bs8_90k_lr00005.yml \ |
| 90 | + --do_eval \ |
| 91 | + --use_vdl \ |
| 92 | + --save_interval 5000 \ |
| 93 | + --save_dir output |
| 94 | +``` |
| 95 | + |
| 96 | +**note:** 使用--do_eval会影响训练速度及增加显存消耗,根据选择进行开闭。 |
| 97 | + |
| 98 | +更多参数信息请运行如下命令进行查看: |
| 99 | +```shell |
| 100 | +python train.py --help |
| 101 | +``` |
| 102 | + |
| 103 | +## 评估 |
| 104 | +```shell |
| 105 | +python val.py \ |
| 106 | + --config configs/panoptic_deeplab/panoptic_deeplab_resnet50_os32_cityscapes_1025x513_bs8_90k_lr00005.yml \ |
| 107 | + --model_path output/iter_90000/model.pdparams |
| 108 | +``` |
| 109 | +你可以直接下载我们提供的模型进行评估。 |
| 110 | + |
| 111 | +更多参数信息请运行如下命令进行查看: |
| 112 | +```shell |
| 113 | +python val.py --help |
| 114 | +``` |
| 115 | + |
| 116 | +## 预测及可视化结果保存 |
| 117 | +```shell |
| 118 | +export CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 # 根据实际情况进行显卡数量的设置 |
| 119 | +python -m paddle.distributed.launch predict.py \ |
| 120 | + --config configs/panoptic_deeplab/panoptic_deeplab_resnet50_os32_cityscapes_1025x513_120k.yml \ |
| 121 | + --model_path output/iter_90000/model.pdparams \ |
| 122 | + --image_path data/cityscapes/leftImg8bit/val/ \ |
| 123 | + --save_dir ./output/result |
| 124 | +``` |
| 125 | +你可以直接下载我们提供的模型进行预测。 |
| 126 | + |
| 127 | +更多参数信息请运行如下命令进行查看: |
| 128 | +```shell |
| 129 | +python predict.py --help |
| 130 | +``` |
| 131 | +全景分割结果: |
| 132 | +<center> |
| 133 | + <img src="docs/visualization_panoptic.png"> |
| 134 | +</center> |
| 135 | + |
| 136 | +语义分割结果: |
| 137 | +<center> |
| 138 | + <img src="docs/visualization_semantic.png"> |
| 139 | +</center> |
| 140 | + |
| 141 | +实例分割结果: |
| 142 | +<center> |
| 143 | + <img src="docs/visualization_instance.png"> |
| 144 | +</center> |
0 commit comments