This is the source code for my submission to the Airbus Ship Selection Challenge hosted by Kaggle. Placed 479th with an F2 score of 0.83313.
notebooks
: contains some tests of new features made in Jupyter notebooks (F-score, run-length encoding/decoding, Dice loss, etc.)src
: code used for this submission.
- Python 3
- pip
pip install -r requirements.txt
The top-scoring model was a combination of two models:
-
ship or no-ship classification ResNet34 replacing the last pooling layer and fully connected layer with an adaptive head based on the fast.ai ResNet models and AdaptiveConcatPool2d.
-
segmentation network based on LinkNet with the following differences:
- the ResNet18 encoder was replaced by a ResNet34;
- the kernel size of the last transposed convolution in the final block was changed from 2 to 3. This made it possible for the network to accept any input image size without changing the output padding.
The ship or no-ship model predicts which images have ships. Images with ships are then passed to the segmentation network that performs pixel-wise ship segmentation.
The classifier model was trained using binary cross entropy loss with logits (BCEWithLogitsLoss
) and the segmentation model was trained with binary cross entropy and dice with logits (BCE_BDWithLogitsLoss
)
The results can be replicated by following these steps:
python train_classifier.py -c config/train_clf_224.json
python train_classifier.py -c config/train_clf_384.json -m checkpoints/sns34_i224/sns34_i224.pth
python train_classifier.py -c config/train_clf_768.json -m checkpoints/sns34_i384/sns34_i384.pth
At this point, the classifier is trained. The next step is to generate the dataset for training with the segmentation network. We could use the classifier during the segmentation training to generate the dataset in real-time but that is computationally expensive and not time efficient. The segmentation_dataset.py
script will write the training images to a CSV instead.
python segmentation_dataset.py -c config/segmentation_dataset.json
To train the segmentation network:
python train_seg_binary.py -c config/train_seg_384.json
python train_seg_binary.py -c config/train_seg_768.json -m checkpoints/linknet34_fscore_bce_bdl_i384/linknet34_fscore_bce_bdl_i384.pth
Finally, the models are combined with ComboNet
and the submission is created:
python make_submission.py -c config/make_submission.json
- ENet gave lower performance
- Standard LinkNet (with ResNet18) performed slightly worse
- UNet by lyakaap took too much time to train.
- Ground-truth ship segmentations weren't tight, i.e. they were more akin to oriented bounding boxes. Post-processing was applied to predictions to compute the oriented bounding box of each ship and fill it completely. This resulted in much worse performance.