https://github.com/bits-bytes-nn/state-farm-detection
State Farm Distracted Driver Detection via Image Classification
https://github.com/bits-bytes-nn/state-farm-detection
albumentations image-classification tensorflow-addons tensorflow-hub tensorflow2 wandb
Last synced: 7 months ago
JSON representation
State Farm Distracted Driver Detection via Image Classification
- Host: GitHub
- URL: https://github.com/bits-bytes-nn/state-farm-detection
- Owner: bits-bytes-nn
- Created: 2022-02-24T05:02:35.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-08-05T15:37:57.000Z (about 3 years ago)
- Last Synced: 2025-01-19T12:28:21.814Z (9 months ago)
- Topics: albumentations, image-classification, tensorflow-addons, tensorflow-hub, tensorflow2, wandb
- Language: Jupyter Notebook
- Homepage:
- Size: 44.5 MB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# State Farm Distracted Driver Detection
## Goals
* Experiment with various modern deep learning techniques from the paper, [Bag of Tricks for Image Classification with Convolutional Neural Networks](https://arxiv.org/abs/1812.01187) through an image classification task.
* Build a high-speed and efficient data pipeline using the *TFRecord* file format, *Dataset* API, and the `albumentations` library.
* Explain the model via [Grad-CAM](https://arxiv.org/abs/1610.02391) and host it using *TF Serving* or *SageMaker* to enable real-time inference.
* (Optional) Effectively manage experiments through the `wandb` library.
## Requirements
* The dataset can be downloaded from [this Kaggle competition](https://www.kaggle.com/c/state-farm-distracted-driver-detection).
* In addition to the [Anaconda](https://www.anaconda.com) libraries, you need to install `tensorflow`, `tensorflow-addons`, `tensorflow-hub`, `albumentations` and `wandb`.## Experimental Setup
* [EfficientNet-B0](https://arxiv.org/abs/1905.11946) was used as the base model. On top of that, fully connected layers and dropout layers were added.
* The batch size was set to 32, the number of epochs was set to 500, and an early stopping option was applied.
* [A Cosine Decay Schedule with Restarts](https://arxiv.org/pdf/1608.03983.pdf) was used. In this case, the initial learning rate was set to 0.001 and the first decay step was set to 1,000.
* The images were resized to 224 x 224 and image data augmentation through rotation, scaling, and shifting was applied. Below are examples of data augmentation.
## Experiment Result
* The evaluation criterion for this Kaggle competition is multi-class logarithmic loss.
* As the validation set, 25% of the images were randomly assigned. However, in the case of the 5-fold CV ensemble, the dataset was divided into 5 equal parts.| Treatment | Public Score | Private Score |
|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:------------:|:-------------:|
| [RAdam](https://arxiv.org/abs/1908.03265) | 1.0260 | 0.6792 |
| [AdamW](https://arxiv.org/abs/1711.05101) | 0.9117 | 0.7140 |
| RAdam + [SWA](https://arxiv.org/abs/1803.05407) | 1.1547 | 0.7527 |
| RAdam + [Mixup](https://arxiv.org/abs/1710.09412) | 0.8331 | 0.6423 |
| RAdam + [Label Smoothing](https://arxiv.org/abs/1906.02629) (0.1) | 0.9047 | 0.7891 |
| RAdam + Mixup + TTA (3 times) | 0.7434 | 0.5777 |
| RAdam + Mixup + TTA + 5-fold CV Ensemble (OOF) | 0.6877 | 0.5419 |
| [Pseudo Labeling](https://www.researchgate.net/publication/280581078_Pseudo-Label_The_Simple_and_Efficient_Semi-Supervised_Learning_Method_for_Deep_Neural_Networks) (> 0.9) + RAdam + Mixup + TTA + 5-fold CV Ensemble | 0.6504 | 0.5169 |### Model Explainability with Grad-CAM
* 20 samples were randomly selected from the test set and visualized using the Grad-CAM technique. Labels shown are predicted.
## Model Serving
### TF Serving
* You need to download and run the *Docker* image via `scripts/run.sh` file. Then, you can test model inference through a locally hosted *TF Serving*.
### SageMaker
* *SageMaker* allows you to train TensorFlow models and deploy endpoints for serving. You can also use the *SageMaker* *Estimator*'s *Pipe* mode to train a model without downloading a dataset directly.