# A simple approach based on baseline notebooks (6th place solution)

Thanks to the organizers for a very interesting competition, my teammates (
[@yasushiyui](https://www.kaggle.com/yasushiyui)
and
[@kotaiizuka](https://www.kaggle.com/kotaiizuka)
) for effort, and all the kagglers who worked hard together.  And special thanks to
[@its7171](https://www.kaggle.com/its7171)
, the author of great baseline notebooks.
There are already many great top solutions out there, but we would like to share ours as an example of how just a few tweaks to the baseline can increase your score.
Please feel free to comment if you notice anything or would like to know more details.
Summary
Basically, we used the baseline notebook processing pipeline.
Similar to the Public 1st place solution, three neighboring frames were converted to grayscale and combined in the channel direction for using temporal information. We believe that this idea was probably crucial for our solution to enter the public gold medal zone.
We applied the techniques usually used in competitions (high resolution images, modification of loss function, custom data augmentation, ensemble, TTA, etc.).
Using three neighboring frames
The figure below shows the flow of this technique. To avail temporal information and to use the same processing pipeline as for RGB image input, three adjacent images were converted to grayscale and combined in the channel direction. Most experiments used time_stride=1. In one of the final submissions, we ensembled the models trained with time_stride=1, 2, and 3, respectively, to take advantage of the longer temporal information.
![](assets/bcc11dcca270a57f69cd1c8a.png)
Parameter settings
Training
dataset
fold0: 3c993bd2_0, 3c993bd2_1
fold1: 1606b0e6_0, 1606b0e6_1
fold2: 35bd9041_0, 35bd9041_1
input_size: (3, 720, 1280)
time_stride: 1, 2, 3
amp: True
20 epochs (cooldown_epochs=0)
evaluation metrics: mAP
model
tf_efficientnet_b0_ap
tf_efficientnet_b1_ap
loss: 4-class binary cross entropy
dropout: 0.2
data augmentation
RandomAffine, RandomPerspective, RandomHorizontalFlip, ColorJitter(brightness, contrast), Mixup
Averaging checkpoints
default settings for avg_checkpoints.py in timm
Inference
interpolation method for resize: cv2.INTER_AREA
crop_pct: 0.875 (default setting for tf_efficientnet_b0_ap)
3-models ensemble with horizontal flip tta
inference once every 2 frames for speedup (predictions for frames not inferred are generated by linear interpolation)
custom data loader to prefetch images behind the GPU inference process
parameter tunings for window_size and ignore_width in
make_sub
function
Scores for each experiment
The table below shows the settings and scores of baseline notebooks and our main experiments.
Our public LB best (0.784) model was not selected for the final submission because it almost exceeded the time limit.
ID
description
model
Val AP
LB
1
tito's baseline
b5_ap
0.215
0.249
2
+ TTA
b5_ap
N/A
0.255
3
+ Fix label error
b5_ap
0.242
0.283
4
+ Use three neighboring frames
with time_stride=1
b5_ap
0.312
0.425
5
+ 960x540 input and inference
once every 2 frames
(without tta)
b5_ap
0.554
0.563
6
+ 4-class bce loss
b5_ap
0.609
0.618
7
+ Custom data loader
b5_ap
0.625
0.634
8
+ Custom data augmentation
b5_ap
0.700
0.703
9
+ Replace b5 model
with b0 model and
predict with 4-fold ensemble
b0_ap
(4-fold)
0.669
0.720
10
+ Generate predictions
for frames not inferred
using linear interpolation
b0_ap
(4-fold)
0.686
0.740
11
+ 1280x720 input and
3-fold ensemble prediction
b0_ap
(3-fold)
0.722
0.772
12
+ Mixup augmentation
b0_ap
(3-fold)
0.747
0.761
13
+ Replace one b0 model
with b1 model
b0_ap (2-fold)
b1_ap (1-fold)
0.751
0.768
14
+ Replace three models
with 3 full-fit models
(each model uses
three neighboring frames
with time_stride=1, 2, and 3,
respectively)
b0_ap (full-fit,
time_stride=1, 2, 3)
0.753
0.782
Reference
Baseline notebooks
[DFL benchmark training | Kaggle](https://www.kaggle.com/code/its7171/dfl-benchmark-training)
[DFL benchmark inference | Kaggle](https://www.kaggle.com/code/its7171/dfl-benchmark-inference)
Fix label erros
[DFL benchmark training + fix label error | Kaggle](https://www.kaggle.com/code/kmizunoster/dfl-benchmark-training-fix-label-error)
[DFL benchmark inference + tta + fix label error | Kaggle](https://www.kaggle.com/code/kmizunoster/dfl-benchmark-inference-tta-fix-label-error)