{"id":26372710,"url":"https://github.com/bits-bytes-nn/state-farm-detection","last_synced_at":"2025-03-17T01:18:58.527Z","repository":{"id":201279711,"uuid":"463014931","full_name":"bits-bytes-nn/state-farm-detection","owner":"bits-bytes-nn","description":"State Farm Distracted Driver Detection via Image Classification","archived":false,"fork":false,"pushed_at":"2022-08-05T15:37:57.000Z","size":46669,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-19T12:28:21.814Z","etag":null,"topics":["albumentations","image-classification","tensorflow-addons","tensorflow-hub","tensorflow2","wandb"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bits-bytes-nn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-02-24T05:02:35.000Z","updated_at":"2023-12-19T17:10:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"16e9013d-7346-452b-aa4c-99ed0e1a5943","html_url":"https://github.com/bits-bytes-nn/state-farm-detection","commit_stats":null,"previous_names":["aldente0630/state-farm-detection","bits-bytes-nn/state-farm-detection"],"tags_count":null,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bits-bytes-nn%2Fstate-farm-detection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bits-bytes-nn%2Fstate-farm-detection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bits-bytes-nn%2Fstate-farm-detection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bits-bytes-nn%2Fstate-farm-detection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bits-bytes-nn","download_url":"https://codeload.github.com/bits-bytes-nn/state-farm-detection/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243955783,"owners_count":20374373,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["albumentations","image-classification","tensorflow-addons","tensorflow-hub","tensorflow2","wandb"],"created_at":"2025-03-17T01:18:58.028Z","updated_at":"2025-03-17T01:18:58.509Z","avatar_url":"https://github.com/bits-bytes-nn.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# State Farm Distracted Driver Detection\n## Goals\n* 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.\n* Build a high-speed and efficient data pipeline using the *TFRecord* file format, *Dataset* API, and the `albumentations` library.\n* 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.\n* (Optional) Effectively manage experiments through the `wandb` library.\n  \n## Requirements\n* The dataset can be downloaded from [this Kaggle competition](https://www.kaggle.com/c/state-farm-distracted-driver-detection).\n* In addition to the [Anaconda](https://www.anaconda.com) libraries, you need to install `tensorflow`, `tensorflow-addons`, `tensorflow-hub`, `albumentations` and `wandb`.\n\n## Experimental Setup\n* [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.\n* The batch size was set to 32, the number of epochs was set to 500, and an early stopping option was applied.\n* [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.\n* 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.\n\n![Augmentation](./imgs/state-farm-detection1.jpg)\n\n## Experiment Result\n* The evaluation criterion for this Kaggle competition is multi-class logarithmic loss.\n* 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.\n\n|                                                                                                        Treatment                                                                                                        | Public Score | Private Score |\n|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:------------:|:-------------:|\n|                                                                                        [RAdam](https://arxiv.org/abs/1908.03265)                                                                                        |    1.0260    |    0.6792     |\n|                                                                                        [AdamW](https://arxiv.org/abs/1711.05101)                                                                                        |    0.9117    |    0.7140     |\n|                                                                                     RAdam + [SWA](https://arxiv.org/abs/1803.05407)                                                                                     |    1.1547    |    0.7527     |\n|                                                                                    RAdam + [Mixup](https://arxiv.org/abs/1710.09412)                                                                                    |    0.8331    |    0.6423     |\n|                                                                            RAdam + [Label Smoothing](https://arxiv.org/abs/1906.02629) (0.1)                                                                            |    0.9047    |    0.7891     |\n|                                                                                              RAdam + Mixup + TTA (3 times)                                                                                              |    0.7434    |    0.5777     |\n|                                                                                     RAdam + Mixup + TTA + 5-fold CV Ensemble (OOF)                                                                                      |    0.6877    |    0.5419     |\n| [Pseudo Labeling](https://www.researchgate.net/publication/280581078_Pseudo-Label_The_Simple_and_Efficient_Semi-Supervised_Learning_Method_for_Deep_Neural_Networks) (\u003e 0.9) + RAdam + Mixup + TTA + 5-fold CV Ensemble |    0.6504    |    0.5169     |\n\n### Model Explainability with Grad-CAM\n* 20 samples were randomly selected from the test set and visualized using the Grad-CAM technique. Labels shown are predicted.\n![Grad-CAM](./imgs/state-farm-detection2.jpg)\n\n## Model Serving\n### TF Serving\n* 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*.\n### SageMaker \n* *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.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbits-bytes-nn%2Fstate-farm-detection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbits-bytes-nn%2Fstate-farm-detection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbits-bytes-nn%2Fstate-farm-detection/lists"}