Soil Classification

EfficientNetB0 transfer-learning classifier for alluvial, black, clay, and red soil images. Test F1 0.9876.

View on GitHub

Tech Stack

PythonPyTorchEfficientNetB0Matplotlibscikit-learn

Overview:

This project implements a deep learning solution for the Soil Classification Challenge, aiming to classify soil images into four categories: Alluvial soil, Black Soil, Clay soil, and Red soil. The solution uses a pre-trained EfficientNetB0 model with a custom classifier head, trained on a dataset of soil images. The code includes data preprocessing, model training, evaluation, and prediction generation for a test set.

- Data Preprocessing: Loads and prepares image data with augmentation for training and normalization for validation/testing.

- Model: Utilizes EfficientNetB0 with transfer learning, fine-tuning the last 20 layers and adding a custom classifier head.

- Class Imbalance Handling: Implements weighted random sampling and class-weighted loss to address class imbalance.

- Training: Trains the model with AdamW optimizer, cosine annealing learning rate scheduler, and cross-entropy loss.

- Evaluation: Computes F1 scores per class, generates a confusion matrix, and plots training history (loss and F1 score).

- Prediction: Generates predictions for the test set and saves them in a submission-ready CSV file.

Achieved F1 score: 0.9876.