Kaggle Vision Competition Project - Part 2
Part 2 of this Kaggle competition will explore the power of data augmentation.
Kaggle Vision Competition Project - Part 2
Part 2 of this Kaggle competition will explore the power of data augmentation.
Sign Language Image Classification part 2
Data Augmentation entails change of shape, color, and orientation to make our models better at generalization. I will be also using the ConvNeXt model. this model is more accurate than the resnet model we used in part 1.
Data
File descriptions:
- train.csv — the training set
- test.csv — the test set
- submit.csv — a sample submission file in the correct format
Data fields:
- id — an image name
- label — a label of the image
- predict — a result of the image prediction [1]
Methodology: Preprocessing experiments
- Notebook setup
- Train function
- New model: ConvNext
- Preprocessing experiments
- Crop
- Squish
- Padding
-
Test time Augmentation(TTA)
-
Scaling up
-
Submit to kaggle
Analysis
Notebook setup:
The basic installation and imports we will use for the competition
[embed]
(#4) [Path('sign-language-image-classification/train.csv'),Path('sign-language-image-classification/submit.csv'),Path('sign-language-image-classification/test.csv'),Path('sign-language-image-classification/images')]
training data:

test data:

submission format: the format we will use to make our submissions to kaggle. NaN will be filled with our model predictions.

We then display the path to the image files we will use to train the model. We will display an image from the training data.
[embed]

Train function:
This train function will be used for rest of our model iterations.
[embed]
test the train function with a small resnet26d model.
[embed]

New model: ConvNext
[embed]

Accuracy is slightly better while the training time remains the same. This is the main ideal of testing different data augmentations. We need our model to be accurate and train in a very short time so we can conduct as many experiments as we want.
This model is more powerful than the resnet26dmodel and has fast iteration times. Normally we would have to resize our images to make them smaller, thus iteration time will be faster. In this competion the images are allready small so we can use the dataset as is.
This is how we would resize our train data if we desired to:
[embed]
This will give us 192x256px images.
Preprocessing experiments:
We will try 3 types of data augmentation and choose the one that gives the best result.
Crop:
In fastai when we train a model and do not specify the data augmentation, by default fastai applies the cropping augmentation.
[embed]
Our result will be the same as the previous example. Accuracy = 0.867500.
Squish:
[embed]
| epoch | train_loss | valid_loss | accuracy | time |
|-------|------------|------------|----------|-------|
| 0 | 3.529737 | 1.826587 | 0.442500 | 00:26 |
| epoch | train_loss | valid_loss | accuracy | time |
|-------|------------|------------|----------|-------|
| 0 | 2.045850 | 1.352373 | 0.580000 | 00:27 |
| 1 | 1.655862 | 0.761877 | 0.775000 | 00:26 |
| 2 | 1.293677 | 0.522106 | 0.852500 | 00:26 |
| 3 | 1.004253 | 0.448577 | 0.870000 | 00:26 |
| 4 | 0.846791 | 0.445248 | 0.862500 | 00:26 |
There is no significant improvement to the model.
Padding:
first we can show what a padded dataset looks like. We are padding with zeros(black bars).
[embed]

Lets add padding to our train function
[embed]
| epoch | train_loss | valid_loss | accuracy | time |
|-------|------------|------------|----------|-------|
| 0 | 3.626732 | 1.680467 | 0.457500 | 00:30 |
| epoch | train_loss | valid_loss | accuracy | time |
| 0 | 2.188343 | 1.398221 | 0.565000 | 00:25 |
| 1 | 1.821120 | 0.835657 | 0.742500 | 00:26 |
| 2 | 1.446886 | 0.538521 | 0.835000 | 00:26 |
| 3 | 1.148121 | 0.458037 | 0.877500 | 00:26 |
| 4 | 0.958698 | 0.442475 | 0.875000 | 00:26 |
There is a slight improvement on the training accuracy. So for the rest of the project we will use padding as our image augmentation.
Test time Augmentation:
To improve the models accuracy we apply test time augmentation(TTA). It is defined as:
During inference or validation, creating multiple versions of each image, using data augmentation, and then taking the average or maximum of the predictions for each augmented version of the image.[2]
First lets view our models accuracy before we apply TTA.
[embed]
Lets view what TTA does to our images.
[embed]

as we can see the images are rotated, color is changed and focus on image is adjusted.
TTA on the validation data:
[embed]
accuracy improved from 0.875 to 0.915.
Scaling up:
Now we add eveything together.
- the convnext model
- padding the data
- TTA
- Training the model for 12 epochs not 5 epochs.
[embed]
| epoch | train_loss | valid_loss | accuracy | time |
|-------|------------|------------|----------|-------|
| 0 | 3.622475 | 1.727693 | 0.422500 | 00:25 |
| epoch | train_loss | valid_loss | accuracy | time |
| 0 | 2.312848 | 1.507595 | 0.515000 | 00:26 |
| 1 | 2.028456 | 1.122176 | 0.677500 | 00:25 |
| 2 | 1.684351 | 0.713377 | 0.765000 | 00:26 |
| 3 | 1.342860 | 0.508483 | 0.835000 | 00:26 |
| 4 | 1.041549 | 0.346994 | 0.890000 | 00:26 |
| 5 | 0.799597 | 0.292256 | 0.900000 | 00:26 |
| 6 | 0.631141 | 0.231880 | 0.930000 | 00:26 |
| 7 | 0.512751 | 0.222379 | 0.930000 | 00:25 |
| 8 | 0.415084 | 0.197974 | 0.932500 | 00:25 |
| 9 | 0.351059 | 0.196635 | 0.947500 | 00:25 |
| 10 | 0.318564 | 0.189326 | 0.952500 | 00:25 |
| 11 | 0.292881 | 0.191111 | 0.950000 | 00:25 |
Before TTA accuracy is 0.950.
TTA on validation set
[embed]
Slight improvement on the accuracy. In a kaggle competition all improves add up to a better model and ranking on the leaderboard.
Submit to kaggle:
We get the test image paths in alphabetical order. This makes it easier to create a .csv file to submit to kaggle.

create test dataloader from tst_files. Also apply TTA on the test data. How well our model does will be seen when we submit our results to kaggle.
[embed]
add results to .csv
[embed]
id,predict
5f3540c43f86dab2c9a7c87834311ee3.jpg,4
7f14db51f1994bce42972c7fe111f5cd.jpg,18
092908960a3d4dccbe06a60b71dcdd98.jpg,19
542ed4f107f9472457b47a436ec55e60.jpg,5
c125af0d467cffe584728aad4b426d53.jpg,1
dac637220376b2f834447c515148e301.jpg,6
c94daf6d789e53fd933cb26cedf00678.jpg,15
559cbbb343a27ec2839477c53b0ba65b.jpg,2
4a6bd7247218fe3cd2001a634b1fd6df.jpg,8
Conclusion
submit .csv to kaggle
if not iskaggle:
from kaggle import api
api.competition_submit_cli('submission2.csv', 'v5 test_dl_fix victor convnext small 128px', comp)
- Score: 0.93085
- Public score: 0.94414
- POS: 25/41
This is a big improvement from the first model. In part 3 we will use ensembling to improve our predictions even futher.
References
[1] https://www.kaggle.com/competitions/sign-language-image-classification/data
[3]
[4] Github notebook
메타데이터
- post_id
- 4b5023ffb3cb
- slug
- kaggle-vision-competition-project-part-2-4b5023ffb3cb
- url
- https://medium.com/@victorbahlangene96/kaggle-vision-competition-project-part-2-4b5023ffb3cb
- canonical_url
- https://medium.com/@victorbahlangene96/kaggle-vision-competition-project-part-2-4b5023ffb3cb
- author_url
- https://medium.com/@victorbahlangene96
- status
- ok
- fetched_at
- 2026-06-28 10:39:35