# 163rd place report and code repository

This competition was very special for me, it's my first competition medal, I worked and learned a lot, thanks for all that shared valuable information.
A brief report (I won't get into too many details because wasn't anything special)
Data:
Old data was sampled to a more balanced distribution, was used only 25% of samples from class 0.
Each fold had all sampled old data and 20% of new data.
Training set: All sampled old data and 80% of new data (15770 samples from old data and 2929 samples from new data).
Validation set: 20% of new data (733 samples).
Model:
EfficientNetB5
Imagenet pre-trained weights.
Replaced top head with GlobalAveragePooling2D and a Dense layer as linear output.
Training
Parameters:
Batch size: 32
Warm-up step:
Freeze all layers except the last 2.
Learning rate: 4e-3, Adam optimizer and Cosine & Warm-up learning rate scheduler (2 epochs warm-up and hold base LR for 2 epochs).
Train for 5 epochs.
Fine-tunning step:
Unfreeze all layers.
Early stopping monitoring validation loss for 5 epochs.
Learning rate: 4e-4, Adam optimizer and Cosine & Warm-up learning rate scheduler (5 epochs warm-up and hold base LR for 3 epochs).
Train for 20 epochs.
Preprocess:
This step was applied before modeling to make training faster.
Convert image to RGB channels.
Circle crop image. This crop was used to remove black areas from original square images, and also crop a circular area based on the image center.
Resize image to 224x224. The original images size were reduced to 224, I have tried many others but this worked best, also made possible to train with larger batch size (32).
Augmentation:
All augmentations were from Keras ImageDataGenerator.
Rescale (divide by 255).
Random rotation 360°.
Random flip (horizontal and vertical).
Inference:
Test time augmentation (TTA) x10, using the same augmentations of the training step.
Averaged all the 5 models and their TTA predictions.
Threshold: [0.5, 1.5, 2.5, 3.5]
I usually take some extra effort and create
[repositories](https://github.com/dimitreOliveira/APTOS2019BlindnessDetection)
for my competitions, there you can find a more
[detailed report and my solution stack](https://github.com/dimitreOliveira/APTOS2019BlindnessDetection/tree/master/Best%20solution%20%28Bronze%20medal%20-%20175th%20place%29%20)
.
For me, it was a lot more work to put everything together in an organized way, but I think it worth it, also would be nice to see something similar for some top submissions, for beginner see the way that more experienced people structure and build their workflow is really important.