deeplabv3+实现代码修改

  • tfrecord的生成代码
  python deeplab/datasets/build_voc2012_data.py \
      --image_folder="/home/dsx/ccc/img" \
      --semantic_segmentation_folder="/home/dsx/ccc/mask" \
      --list_folder="/home/dsx/ccc/index" \
      --image_format="png" \
      --output_dir="/home/dsx/ccc/tfrecord" 
  • folder含义
     --image_folder=图片路径
     --semantic_segmentation_folder=图片掩码(mask)路径
     --list_folder=图片list路径
     --image_format=图片格式
     --output_dir=tfrecord路径 
  • train.py 修改
    initialize_last_layer=False
    last_layers_contain_logits_only=True
  • segmentation_dataset.py修改
_MPI_INFORMATION = DatasetDescriptor(
    splits_to_sizes={
        'train': 120,  # num of samples in images/training
        'val': 30,  # num of samples in images/validation
    },
    num_classes=3,
    ignore_label=255,
)
  • 以及在下面的_DATASETS_INFORMATION添加

以及在下面的_DATASETS_INFORMATION添加

_DATASETS_INFORMATION = {
    'cityscapes': _CITYSCAPES_INFORMATION,
    'pascal_voc_seg': _PASCAL_VOC_SEG_INFORMATION,
    'ade20k': _ADE20K_INFORMATION,
    'kitti':_KITTI_INFORMATION,
    'mpi':_MPI_INFORMATION
 }
  • 修改train_unitls.py

  • 不需要加载logits层

  # Variables that will not be restored.
  #exclude_list = ['global_step','logits']
  exclude_list = ['global_step']
  if not initialize_last_layer:
    exclude_list.extend(last_layers)
  • train.py order
python3 deeplab/train.py \
    --logtostderr \
    --training_number_of_steps=200 \
    --train_split="train" \
    --model_variant="xception_65" \
    --atrous_rates=6 \
    --atrous_rates=12 \
    --atrous_rates=18 \
    --output_stride=16 \
    --decoder_output_stride=4 \
    --train_crop_size=513 \
    --train_crop_size=513 \
    --train_batch_size=2 \
    --dataset='mpi' \
    --fine_tune_batch_norm = False \
    --tf_initial_checkpoint='/home/dsx/models/research/deeplab/datasets/mpi/exp/deeplabv3_cityscapes_train/model.ckpt' \
    --train_logdir='/home/dsx/dsx/model/research/deeplab/datasets/mpi/train' \
    --dataset_dir='/home/dsx/dsx/model/research/deeplab/datasets/mpi/tfrecord'
    --tf_initial_checkpoint='参数位置' 
    --train_logdir='train保存位置' 
    --dataset_dir='tfrecord位置'
  • eval.py order
python deeplab/eval.py \
  --logtostderr \
  --eval_split="trainval" \
  --model_variant="xception_65" \
  --atrous_rates=6 \
  --atrous_rates=12 \
  --atrous_rates=18 \
  --output_stride=16 \
  --decoder_output_stride=4 \
  --eval_crop_size=436 \
  --eval_crop_size=1024 \
  --checkpoint_dir='/home/servicer2/dsx/models/research/deeplab/datasets/mpi/train' \
  --eval_logdir='/home/servicer2/dsx/models/research/deeplab/datasets/mpi/eval' \
  --dataset_dir='/home/servicer2/dsx/models/research/deeplab/datasets/mpi/tfrecord' \
  --max_number_of_evaluations=1
  • vis.py order
python deeplab/vis.py \
    --logtostderr \
    --vis_split="trainval" \
    --model_variant="xception_65" \
    --atrous_rates=6 \
    --atrous_rates=12 \
    --atrous_rates=18 \
    --output_stride=16 \
    --decoder_output_stride=4 \
    --vis_crop_size=439 \
    --vis_crop_size=1025 \
    --dataset='mpi' \
    --checkpoint_dir='/home/servicer2/models/research/deeplab/datasets/mpi/train' \
    --vis_logdir='/home/servicer2/models/research/deeplab/datasets/mpi/vis' \
    --dataset_dir='/home/servicer2/dsx/models/research/deeplab/datasets/mpi/tfrecord'

https://www.jianshu.com/p/1a07990705ee

你可能感兴趣的:(小技巧)