Home

Awesome

Kaggle TGS Salt Identification Challenge 2018 4th place code

This is the source code for my part of the 4th place solution to the TGS Salt Identification Challenge hosted by Kaggle.com.

image

Recent Update

2018.11.06: jigsaw python code,dirty code of handcraft rules and pseudo label training code updated.

2018.10.22: single model training code updated.

2018.10.20: We achieved the 4th place on Kaggle TGS Salt Identification Challenge.

Dependencies

Solution Development

Single model design

Single model performace

single model(10fold 7cycle)valid LBpublic LBprivare LB
model_500.8730.8730.891
model_50_slim0.8710.8720.891
model_101A0.8680.8700.889
model_101B0.8700.8710.891
model_1520.8680.8690.888
model_1540.8690.8710.890

Model ensemble performace

ensemble model(cycle voting)public LBprivare LB
50+50_slim0.8730.891
50+50_slim+101B0.8730.892
50+50_slim+101A0.8730.892
50+50_slim+101A+101B0.8740.892
50+50_slim+101A+101B+1540.8740.892
50+50_slim+101A+101B+152+1540.8740.892

Post processing

According to the 2D and 3D jigsaw results, we applied around 10 handcraft rules that gave a 0.010~0.011 public LB boost and 0.001 private LB boost.

modelpublic LBprivare LB
50+50_slim+101A+101B with post processing0.8840.893

Data distill (Pseudo Labeling)

We started to do this part since the middle of the competetion. Pseudo labeling is pretty tricky and has the risk of overfitting. I am not sure whether it would boost the private LB untill the result is published. I just post our results here, the implementation details will be updated. Steps (as the following flow chart shows):

  1. Grabing the pseudo labels provided by previous predict (with post processing).
  2. Randomly split the test set into two parts, one for training and the other for predicting.
  3. To prevent overfitting to pseudo labels, we randomly select images from training set or test set (one part) with same probability in each mini batch.
  4. Training the new dataset in three different networks with same steps as mentioned previously.
  5. Predicting the test set (the other part) by all three trained models and voting the result.
  6. Repeat step 3 to 5 except that in this time we change two test parts.

image

model with datadistillpublic LBprivare LBplacement
model_340.8770.89318
model_500.8800.89398
model_1010.8800.89467
model 34+50+1010.8790.89476
model_34 with post processing0.8850.89398
model_50 with post processing0.8860.89485
model_101 with post processing0.8860.89505
model 34+50+101 with post processing (final sub)0.8870.89534

Data Setup

save the train mask images to disk

python prepare_data.py 

Single Model Training

train model_34 fold 0:

CUDA_VISIBLE_DEVICES=0 python train.py --mode=train --model=model_34 --model_name=model_34 --train_fold_index=0

predict model_34 all fold:

CUDA_VISIBLE_DEVICES=0 python predict.py --mode=InferModel10Fold --model=model_34 --model_name=model_34

Ensemble and Jigsaw Post-processing

After you predict all 6 single models 10 fold test csv,use this two command to perform majority voting and post-processing.

a) solve Jigsaw map (only need to run for one time)

python predict.py --mode=SolveJigsawPuzzles

b) ensemble 6 model all cycles and post-processing, 'model_name_list' is the list of signle model names you train with the command above

python predict.py --mode=EnsembleModels --model_name_list=model_50A,model_50A_slim,model_101A,model_101B,model_152,model_154 ----save_sub_name=6_model_ensemble.csv

You'll get ensemble sub '6_model_ensemble.csv' and ensembel+jigsaw sub '6_model_ensemble-vertical-empty-smooth.csv'

Pseudo label training

After you get ensemble+jigsaw results, use command below to train with pseudo label. We randomly split the test set into two parts. For each model, we train twice with 50% pseudo labels each.

train model_34 with 6model output pseudo label:

a) part0 fold 0

python train.py --mode=train --model=model_34 --model_name=model_34_pseudo_part0 --pseudo_csv=6_model_ensemble-vertical-empty-smooth.csv --pseudo_split=0 --train_fold_index=0

b) part1 fold 0

python train.py --mode=train --model=model_34 --model_name=model_34_pseudo_part1 --pseudo_csv=6_model_ensemble-vertical-empty-smooth.csv --pseudo_split=1 --train_fold_index=1

Final Ensemble

python predict.py --mode=EnsembleModels --model_name_list=model_34_pseudo_part0,model_34_pseudo_part1,model_50A_slim_pseudo_part0,model_50A_slim_pseudo_part1,model_101A_pseudo_part0,model_101A_pseudo_part1 ----save_sub_name=final_sub.csv

The "final_sub-vertical-empty-smooth.csv" is all you need.

Reference