A deep learning web application that identifies soil types from images using a MobileNetV2 convolutional neural network, built with Streamlit.
This project classifies soil images into seven categories using a fine-tuned MobileNetV2 model. The app also includes an Exploratory Data Analysis (EDA) page to explore the dataset used for training.
Soil classes:
- Alluvial Soil
- Arid Soil
- Black Soil
- Laterite Soil
- Mountain Soil
- Red Soil
- Yellow Soil
- Exploratory Data Analysis (EDA) — view the dataset overview and the image distribution across classes.
- Prediction — upload an image file or paste an image URL to classify the soil type, with a confidence score and per-class probability breakdown.
- The trained model is automatically downloaded from Google Drive on first run if it isn't already present locally.
The dataset used for training is a comprehensive soil classification dataset sourced from Kaggle (ai4a-lab/comprehensive-soil-classification-datasets). Image counts per class:
| Class | Images |
|---|---|
| Arid Soil | 284 |
| Black Soil | 255 |
| Laterite Soil | 219 |
| Mountain Soil | 201 |
| Red Soil | 109 |
| Yellow Soil | 69 |
| Alluvial Soil | 51 |
- Python
- Streamlit
- TensorFlow / Keras (MobileNetV2)
- Pandas, NumPy
- Matplotlib, Plotly, Altair
- Pillow (PIL)
- gdown
Soil-Identification/
├── README.md
├── requirements.txt
└── src/
├── streamlit_app.py # Main Streamlit entry point
├── eda.py # Exploratory Data Analysis page
├── prediction.py # Soil image prediction page
├── model_MobileNetV2.h5 # Trained model (or downloaded at runtime)
└── Original-Dataset.csv # Dataset metadata (file paths and labels)
-
Clone the repository:
git clone https://github.com/nhf14/Soil-Identification.git cd Soil-Identification -
Install the dependencies:
pip install -r requirements.txt
Run the Streamlit app from the project root:
streamlit run src/streamlit_app.pyThen open the app in your browser and choose a page from the sidebar:
- EDA — explore the dataset and class distribution.
- Prediction — upload an image or paste an image URL to get a soil type prediction.
The classification model is a MobileNetV2-based CNN trained on 224x224 RGB soil images. If the model file (model_MobileNetV2.h5) is not found locally, it will be automatically downloaded from Google Drive the first time the Prediction page is used.
- Predictions are for informational/educational purposes and should not be treated as a substitute for professional soil analysis.