This is unofficial code for SegFix that has been modified to be used with custom datasets.
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:
PYTHON
, identifying your python executable.DATA_ROOT
, the root directory of your data. It should be the parent directory of cityscapes
.The dataset directory should look like:
$DATA_ROOT
├── cityscapes
│ ├── train
│ │ ├── image
│ │ └── label
│ ├── val
│ │ ├── image
│ │ └── label
│ ├── test
│ │ └── image
Place images and labels at appropriate location.
Before generate offsets, revise label_list first to fit custom datasets.
python ./lib/datasets/preprocess/cityscapes/dt_offset_generator.py
Before starting training, you should download the corresponding ImageNet pretrained models to ./pretrained_model
.
hrnet18, hrnet32, hrnet48, hrnet2x20
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
bash scripts/cityscapes/segfix/<script>.sh train 1
# Predict offsets for val set and save to path
bash scripts/cityscapes/segfix/run_h_48_d_4_segfix.sh segfix_pred_val 1
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
<SPLIT>
is test
or val
.<OFFSET_DIR>
is the location of SegFix offsets, default to $DATA_ROOT/cityscapes/val/offset_pred/[semantic | instance]/offset_hrnext/
or $DATA_ROOT/cityscapes/test_offset/[semantic | instance]/offset_hrnext/
.<OUT_DIR>
is an optional output directory.