Hifumi-daisuki / SegFix_custom

This is unofficial code for SegFix that has been modified to be used with custom datasets
0 stars 0 forks source link

SegFix_custom

This is unofficial code for SegFix that has been modified to be used with custom datasets.

1. Requirements

H/W

S/W

Configuration

Before executing any scripts, your should first fill up the config file config.profile at project root directory. There are two items you should specify:

2. SegFix

2.1. Data Preparation

The dataset directory should look like:

$DATA_ROOT
├── cityscapes
│   ├── train
│   │   ├── image
│   │   └── label
│   ├── val
│   │   ├── image
│   │   └── label
│   ├── test
│   │   └── image

Place images and labels at appropriate location.

2.2. Generate ground truth offsets

Before generate offsets, revise label_list first to fit custom datasets.

python ./lib/datasets/preprocess/cityscapes/dt_offset_generator.py

2.3. Download ImageNet pretrained mode

Before starting training, you should download the corresponding ImageNet pretrained models to ./pretrained_model. hrnet18, hrnet32, hrnet48, hrnet2x20

2.4. Train Config

You should revise ./config/cityscapes/H_SEGFIX.json such as num_classes, label_list, colorlist, loss_weight to fit custom datasets.
Also you need to properly adjust batch sizes to utilize your resources effectively.
Lastly, check export dt_num_classes of ./scripts/cityscapes/segfix/run_h_48_d_4_segfix

2.5. SegFix Training

bash scripts/cityscapes/segfix/<script>.sh train 1

2.6. Offset Generation

# Predict offsets for val set and save to path
bash scripts/cityscapes/segfix/run_h_48_d_4_segfix.sh segfix_pred_val 1

2.7. Refinement

You can use scripts/cityscapes/segfix.py to apply SegFix on your own label files.

python scripts/cityscapes/segfix.py \
  --input <path/to/your/label/dir> \
  --split <SPLIT> \
  [ --offset <OFFSET_DIR>] \
  [ --out <OUT_DIR>]

where