Skip to content

Latest commit

 

History

History

Readme.md

Usage

Get the pretrained models 🔥

  1. Download the pretrained models

    ./get_premodel.sh
  2. Change pretrained models into the same format as DenseCL (We use the same setting as DenseCL in Semantic Segmentation)

    The framework listed below are covered in this python script:

    # In this python script, we remove weights of projection and prototype 
    # Also, all the unecessary module names are removed
    python modify_models.py --pretrained ${ORG_Model} --model ${Dense_Model} --newmodel ${MODIFY_Model}

    ${ORG_Model} : path of the original pretrained model

    ${Dense_Model} : path of the DenseCL pretrained model (this file is used for format checking)

    ${MODIFY_Model} : path of the Modified models


Prerequisites

  • Linux

  • Python 3.6+

  • PyTorch 1.3+

  • CUDA 9.2+ (Use nvcc --version to check)

  • GCC 5+

  • mmcv-full 1.3.0

  • mmsegmentation

    Commands for setting up all the packages and data root: Reference

    conda create -n seg python=3.7 -y
    conda activate seg
    
    conda install pytorch=1.6.0 torchvision cudatoolkit=10.1 -c pytorch
    pip install mmcv-full==1.3.0 -f https://download.openmmlab.com/mmcv/dist/cu92/torch1.6.0/index.html
    git clone https://github.com/open-mmlab/mmsegmentation.git
    cd mmsegmentation
    pip install -e .
    
    mkdir data
    ln -s $DATAROOT/VOCdevkit ./data

Semantic Segmentation Finetuning

VOC12+aug

  1. First, get the dataset by

    bash get_VOC.sh $DATAROOT
  2. Organize the dataset structure as the same as Reame.md

    ⚠️ Remember to use the following command to concatenate VOC_aug and VOC_2012

        cd mmsegmentation
        # --nproc means 8 process for conversion, which could be omitted as well.
        python tools/convert_datasets/voc_aug.py data/VOCdevkit data/VOCdevkit/VOCaug --nproc 8
  3. create links between mmsegmentation/data and your $DATAROOT

        cd mmsegmentation
        ln -s $DATAROOT/VOCdevkit ./data

Start FineTuning

You can also refer to DenseCL

  1. cd mmsegmentation
  2. Then, modify the pretrained model path in configs
  3. Modify the learning rate in schedule
  4. Modify the settings in shell scripts
  5. Start Training
    bash Segmentation_train.sh