预处理的DeepLabV3,DeepLabV3+用于Pascal VOC和CityScapes。
| DeepLabv3 | deeplabv3+ |
|---|---|
| DeepLabv3_Resnet50 | deeplabv3plus_resnet50 |
| DeepLabv3_Resnet101 | deeplabv3plus_resnet101 |
| deeplabv3_mobilenet | deeplabv3plus_mobilenet |
| deeplabv3_hrnetv2_48 | deeplabv3plus_hrnetv2_48 |
| deeplabv3_hrnetv2_32 | deeplabv3plus_hrnetv2_32 |
| deeplabv3_xception | deeplabv3plus_xception |
有关所有模型条目,请参阅网络/建模。
下载预估计的型号:Dropbox,Tencent Weiyun
注意:HRNET主链由@timophymyl贡献。 Google Drive可以使用预训练的骨干。
model = network . modeling . __dict__ [ MODEL_NAME ]( num_classes = NUM_CLASSES , output_stride = OUTPUT_SRTIDE )
model . load_state_dict ( torch . load ( PATH_TO_PTH )[ 'model_state' ] ) outputs = model ( images )
preds = outputs . max ( 1 )[ 1 ]. detach (). cpu (). numpy ()
colorized_preds = val_dst . decode_target ( preds ). astype ( 'uint8' ) # To RGB images, (N, H, W, 3), ranged 0~255, numpy array
# Do whatever you like here with the colorized segmentation maps
colorized_preds = Image . fromarray ( colorized_preds [ 0 ]) # to PIL Image注意:本仓库中的所有预训练模型均经过训练,没有可分离的卷积。
在此存储库中支持了可分离的卷积。我们提供nn.Conv2d简单的工具network.convert_to_separable_conv AtrousSeparableConvolution如果需要,请用' - separable_conv'运行main.py。有关更多详细信息,请参见“ main..py”和“网络/_deeplab.py”。
单图:
python predict.py --input datasets/data/cityscapes/leftImg8bit/train/bremen/bremen_000000_000019_leftImg8bit.png --dataset cityscapes --model deeplabv3plus_mobilenet --ckpt checkpoints/best_deeplabv3plus_mobilenet_cityscapes_os16.pth --save_val_results_to test_results图像文件夹:
python predict.py --input datasets/data/cityscapes/leftImg8bit/train/bremen --dataset cityscapes --model deeplabv3plus_mobilenet --ckpt checkpoints/best_deeplabv3plus_mobilenet_cityscapes_os16.pth --save_val_results_to test_results有关如何添加新骨干的更多详细信息,请参考此提交(Xception)。
您可以在自己的数据集上训练DeepLab模型。您的torch.utils.data.Dataset应该提供一种解码方法,将您的预测转换为有色图像,就像VOC数据集一样:
class MyDataset ( data . Dataset ):
...
@ classmethod
def decode_target ( cls , mask ):
"""decode semantic mask to RGB image"""
return cls . cmap [ mask ]培训:513x513随机作物
验证:513x513中心作物
| 模型 | 批量大小 | 拖鞋 | 火车/瓦尔操作系统 | miou | Dropbox | 腾讯Weiyun |
|---|---|---|---|---|---|---|
| DeepLabv3-Mobilenet | 16 | 6.0g | 16/16 | 0.701 | 下载 | 下载 |
| DeepLabv3-Resnet50 | 16 | 51.4g | 16/16 | 0.769 | 下载 | 下载 |
| DeepLabv3-Resnet101 | 16 | 72.1g | 16/16 | 0.773 | 下载 | 下载 |
| deeplabv3plus-mobilenet | 16 | 17.0g | 16/16 | 0.711 | 下载 | 下载 |
| deeplabv3plus-resnet50 | 16 | 62.7g | 16/16 | 0.772 | 下载 | 下载 |
| deeplabv3plus-resnet101 | 16 | 83.4克 | 16/16 | 0.783 | 下载 | 下载 |
培训:768x768随机作物
验证:1024x2048
| 模型 | 批量大小 | 拖鞋 | 火车/瓦尔操作系统 | miou | Dropbox | 腾讯Weiyun |
|---|---|---|---|---|---|---|
| deeplabv3plus-mobilenet | 16 | 135克 | 16/16 | 0.721 | 下载 | 下载 |
| deeplabv3plus-resnet101 | 16 | N/A。 | 16/16 | 0.762 | 下载 | N/A。 |

















pip install -r requirements.txt您可以使用“ - 下载”选项运行train.py,以下载和提取Pascal VOC数据集。 defaut路径是'./datasets/data':
/datasets
/data
/VOCdevkit
/VOC2012
/SegmentationClass
/JPEGImages
...
...
/VOCtrainval_11-May-2012.tar
...
参见[2]的第4章
The original dataset contains 1464 (train), 1449 (val), and 1456 (test) pixel-level annotated images. We augment the dataset by the extra annotations provided by [76], resulting in 10582 (trainaug) training images. The performance is measured in terms of pixel intersection-over-union averaged across the 21 classes (mIOU).
./datasets/data/train_aug.txt包含10582 trainaug图像的文件名(不包括val图像)。请从Dropbox或Tencent Weiyun下载其标签。这些标签来自Drsleep的回购。
提取Trainaug标签(SemmentationClassaug)到VOC2012目录。
/datasets
/data
/VOCdevkit
/VOC2012
/SegmentationClass
/SegmentationClassAug # <= the trainaug labels
/JPEGImages
...
...
/VOCtrainval_11-May-2012.tar
...
启动视觉切割以进行可视化。如果不需要可视化,请删除“ -enable_vis”。
# Run visdom server on port 28333
visdom -port 28333运行main.py,使用“ - 年度2012_AUG”在8月2日在Pascal VOC2012上训练您的模型。您也可以在4 GPU上与'-GPU_ID 0,1,2,3'在4 GPU上平行培训
注意:此存储库中没有Syncbn,因此使用多个GPU和小批量尺寸的培训可能会降低性能。有关Syncbn的更多详细信息,请参见pytorch编码
python main.py --model deeplabv3plus_mobilenet --enable_vis --vis_port 28333 --gpu_id 0 --year 2012_aug --crop_val --lr 0.01 --crop_size 513 --batch_size 16 --output_stride 16使用' - continue_training'运行main.py,以从your_ckpt恢复优化器和调度程序的状态。
python main.py ... --ckpt YOUR_CKPT --continue_training结果将保存在./ results。
python main.py --model deeplabv3plus_mobilenet --enable_vis --vis_port 28333 --gpu_id 0 --year 2012_aug --crop_val --lr 0.01 --crop_size 513 --batch_size 16 --output_stride 16 --ckpt checkpoints/best_deeplabv3plus_mobilenet_voc_os16.pth --test_only --save_val_results /datasets
/data
/cityscapes
/gtFine
/leftImg8bit
python main.py --model deeplabv3plus_mobilenet --dataset cityscapes --enable_vis --vis_port 28333 --gpu_id 0 --lr 0.1 --crop_size 768 --batch_size 16 --output_stride 16 --data_root ./datasets/data/cityscapes [1]重新思考对语义图像分割的静置卷积
[2]用可分离的卷积编码器进行编码,以进行语义图像分割