Git Product home page Git Product logo

tgs-salt-identification's Introduction

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

  • opencv-python==3.4.2
  • scikit-image==0.14.0
  • scikit-learn==0.19.1
  • scipy==1.1.0
  • torch==0.3.1
  • torchvision==0.2.1

Solution Development

Single model design

  • input: 101 random pad to 128*128, random LRflip;
  • encoder: resnet34, se-resnext50, resnext101_ibna, se-resnet101, se-resnet152, se resnet154;
  • decoder: scse, hypercolumn (not used in network with resnext101_ibna, se_resnext101 backbone), ibn block, dropout;
  • Deep supervision structure with Lovasz softmax; We designed 6 single models for the final submission;

Single model performace

single model(10fold 7cycle) valid LB public LB privare LB
model_50 0.873 0.873 0.891
model_50_slim 0.871 0.872 0.891
model_101A 0.868 0.870 0.889
model_101B 0.870 0.871 0.891
model_152 0.868 0.869 0.888
model_154 0.869 0.871 0.890

Model ensemble performace

ensemble model(cycle voting) public LB privare LB
50+50_slim 0.873 0.891
50+50_slim+101B 0.873 0.892
50+50_slim+101A 0.873 0.892
50+50_slim+101A+101B 0.874 0.892
50+50_slim+101A+101B+154 0.874 0.892
50+50_slim+101A+101B+152+154 0.874 0.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.

model public LB privare LB
50+50_slim+101A+101B with post processing 0.884 0.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 datadistill public LB privare LB placement
model_34 0.877 0.8931 8
model_50 0.880 0.8939 8
model_101 0.880 0.8946 7
model 34+50+101 0.879 0.8947 6
model_34 with post processing 0.885 0.8939 8
model_50 with post processing 0.886 0.8948 5
model_101 with post processing 0.886 0.8950 5
model 34+50+101 with post processing (final sub) 0.887 0.8953 4

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

tgs-salt-identification's People

Contributors

dependabot[bot] avatar seutao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tgs-salt-identification's Issues

有关iou的指标

你好 我最近在跑你的代码 我做了一些改动 其中将metrics里面iou也显示出来 并且得到了max_iou但是我在运行单模型的时候 iou并没有随着训练而变得更好一直停顿于0.5左右 得到的precision的threshold是浮动的 这样得到准确值是否能代表真实的准确值 对于val的平均iou一直维持在0.5左右没有想明白 希望您能帮我解决一下疑惑 万分的感谢啦

Some questions

Congrats! Thanks for sharing.

I have some questions:
1、How to do "Data distill (Pseudo Labeling)" and Post processing?
2、Does the model101 in "Data distill (Pseudo Labeling)" means se-resnet101 or resnext101_ibna or se-resnext101_ibna?
3、Where is ibnb ?
4、How to ensemble 10 folds of single model? Average? Choose best? (It seems just voting across all cycles of each fold and then choose best fold of 10 folds?)
5、 Based 4, if u choose best fold of single model and then average different models?

Thanks.

TypeError: expected Long (got Bool)

在训练单模型的时候 现实class_lbls = self.to_var(torch.LongTensor(is_empty))中的TypeError 这个该如何解决 我用的是pytorch1.4版本 是版本的问题的吗 谢谢拉

第一个步骤

打扰你了
save the train mask images to disk

python prepare_data.py 这一个步骤的意义是什么 谢谢啦

单模型 运行报错

你好,我最近在精读你们的代码,我在运行单模型训练时“CUDA_VISIBLE_DEVICES=0 python train.py --mode=train --model=model_34 --model_name=model_34 --train_fold_index=0”,代码报错不存在 0.8935_for_pseudo_label.csv,pandas无法读取,请问这个文件是数据蒸馏生成的测试集伪标签数据的图片名吗,项目文件里没有。

Single 预测中的有关pth的问题

不好意思打扰您啦 我最近在看您的代码 其中在single训练中得到了许多pth的文件 但是在在预测10fold的时候采用的是哪一个pth文件 我看代码感觉预测10fold采用的还是model_34的原始模型 谢谢啦

Hello,I have a question want to know?

Hi,I want to use this project to other dataset,but I don't how to generate the 10 flod .csv file.Can you tell me how to generate the 10 csv file?Thank you very much!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.