Can i finetune deeplab to a custom dataset in tensorflow?

On Deeplab official tutorial page, the training commands looks like this:

python deeplab/train.py \
    --logtostderr \
    --training_number_of_steps=30000 \
    --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=1 \
    --dataset="pascal_voc_seg" \
    --tf_initial_checkpoint=${PATH_TO_INITIAL_CHECKPOINT} \
    --train_logdir=${PATH_TO_TRAIN_DIR} \
    --dataset_dir=${PATH_TO_DATASET}

By changing dataset_dir and dataset and a few lines in segmentation_dataset.py, you can train on your own dataset.

  • dataset_dir: path points to your tfrecord folder.

    Inside this folder, you should have train-%05d-of-%05d.tfrecord and val-%05d-of-%05d.tfrecord created by build_voc2012_data.py or other scripts in datasets.

    Accordingly, if you want to use train.tfrecord for training, set train_split to train; if you want to evaluate on your evaluation data, set train_split to val.

  • dataset: any self defined name, say "donkey_monkey"

  • Inside segmentation_dataset.py

    create DatasetDescriptor for your own dataset:

    _DONKEY_MONKEY_INFORMATION = DatasetDescriptor(
    splits_to_sizes={
        'train': 1464,  # number of training examples in train data
        'trainval': 2913,  # number of examples for train+eval
        'val': 1449,  # number of eval examples 
        },
        num_classes=21, # note: should be number of class + background
        ignore_label=255,  # label pixels to ignore
    )
    
    

    change below code (line 112)

    _DATASETS_INFORMATION = {
        'cityscapes': _CITYSCAPES_INFORMATION,
        'pascal_voc_seg': _PASCAL_VOC_SEG_INFORMATION,
        'ade20k': _ADE20K_INFORMATION,
        'donkey_monkey': _DONKEY_MONKEY_INFORMATION, # newly added
     }
    
    

Yes you should follow one of these tutorials, depending on the dataset format you have, where you get how to convert datasets to TFrecord format, and train model.

If you use Pascal voc 2012 format, there is a complete example here, including all the steps for training, evaluation, visualize results, and export model.