Smart Agriculture Web and Mobile application that provides intelligent crop recommendations, fertilizer suggestions, and plant disease classification using Machine Learning and Deep Learning.
- About the Project
- Key Features
- Concepts & Methodologies
- Tech Stack
- Project Structure
- Setup & Installation
- Running the Application
- Datasets
- Machine Learning Models
AgroPredict is an end-to-end full-stack AI platform designed to help farmers and agriculture enthusiasts make data-driven decisions. The system integrates machine learning to provide accurate crop recommendations based on soil testing and real-time weather data. Additionally, it offers a deep learning-powered visual disease classification system for plant leaves and smart fertilizer selection based on soil NPK thresholds.
The project is natively available as a Flask Web Application and a fully functional cross-platform Mobile App built with React Native (Expo).
-
Crop Recommendation 🌱
- Suggests the most suitable crop to plant based on Soil variables (Nitrogen, Phosphorous, Potassium, pH) and environmental metrics (Rainfall).
- Dynamically fetches realtime Temperature and Humidity for the provided city using the OpenWeatherMap API.
-
Fertilizer Recommendation 🧪
- Employs rule-based heuristics comparing target nutrient levels corresponding to crops and current soil NPK ratios.
- Prescribes actionable advice to raise or lower specific soil nutrient levels.
-
Plant Disease Classification 🦠
- Users can upload an image of a plant leaf.
- The application leverages a finely-tuned ResNet9 PyTorch Deep Learning model to classify the image against 38 different plant disease classes.
-
Multi-Platform & Accessibility 📱
- Functional Web Interface using Flask, HTML, CSS.
- Cross-Platform React Native App enabling mobile functionality.
- Multi-language Support (i18n) with English and Hindi translations.
- Text-to-Speech (SpeechButton) integration for better accessibility.
| Core Concept | Description |
|---|---|
| Classification (ML) | The project utilizes a Random Forest Classifier mapped over an extensively trained agricultural dataset to predict the optimal crop category. |
| Computer Vision (DL) | A convolutional neural network architecture (ResNet9) maps pixel data of crop leaves into predicted categorical distributions for disease profiling. |
| API Integrations | Incorporates the OpenWeatherMap API to compute live weather markers mapping out temperature and humidity constraints in recommendation queries. |
| Mobile Accessibility | Built with Expo SDK & React Native utilizing custom hooks, React Navigation (Tabs/Stack), native device sensors, gestures, and audio accessibility. |
| Data Imputation | Notebooks cover robust pandas operations for joining raw CP data, fertilizer, and crop metrics into clean pre-processed sets for training pipelines. |
- Python 3.x
- Flask (Web Application & API serving)
- PyTorch & Torchvision (ResNet9 Plant Disease Model Training and Inference)
- Scikit-Learn & XGBoost (Random Forest for Crop Forecasting)
- Pandas & NumPy (Data Processing)
- Jupyter Notebook (Mathematical EDA and Data Modelling pipelines)
- HTML5 & CSS3
- JavaScript
- Jinja2 (Flask Templating)
- React Native & Expo SDK 52
- Expo Router / React Navigation
- i18next (Multilingual Context - Hindi/English)
- Axios (API interfacing)
Agropredict/
│
├── app/ # Flask Web Backend and API Routes
│ ├── app.py # Core Flask application and endpoints
│ ├── config.py # Environment and API configurations
│ ├── static/ # CSS Styles and JS scripts (cities.js)
│ ├── templates/ # HTML Templates (Jinja2)
│ └── utils/ # ML processing scripts (disease.py, fertilizer.py)
│
├── MobileApp/ # React Native / Expo Mobile App codebase
│ ├── app/ # Expo Router layout & structural screens
│ ├── components/ # UI components (Collapsible, HapticTab, SpeechButton)
│ ├── constants/ # Theming (Colors) and i18n locales (en, hi)
│ ├── hooks/ # Custom React Hooks
│ ├── App config files # package.json, app.json, tsconfig.json
│
├── model-building/ # Core Jupyter Notebooks detailing algorithm choices
│ ├── Crop_Recommendation_Model.ipynb
│ └── plant-disease-classification.ipynb
│
├── models/ # Exported and Serialized ML weights
│ ├── plant_disease_model.pth # PyTorch Weights
│ └── RandomForest.pkl # Sklearn classifier (inside app/models logically)
│
├── data-prep/ # Pre-processing configurations
├── data-processed/ # Cleaned final datasets ready for regression algorithms
├── Data-raw/ # Open-source agriculture raw datasets
└── requirements.txt # Python application dependencies
Ensure you have the following installed on your local machine:
- Python 3.8+
- Node.js 18+ & npm (For Mobile App)
- OpenWeatherMap API Key.
- Clone the repository and navigate to the project directory.
- Create a virtual environment (Optional but Recommended):
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
- Install the Python dependencies:
pip install -r requirements.txt
- Configuration:
Open
app/config.pyand set your OpenWeather API Key:weather_api_key = "YOUR_API_KEY_HERE"
- Navigate into the
MobileApp/directory:cd MobileApp - Install npm packages:
npm install
- You may need to edit
MobileApp/app/config.jsor.envfiles if they possess absolute API URL properties mapping natively to your local python backend server IP network.
To spin up the FLASK server, run:
cd app
python app.pyThe web API will successfully run locally at http://127.0.0.1:5000.
To run the React Native Expo app:
cd MobileApp
npm start- Press a to open on an Android Emulator.
- Press w to open on Web.
- Alternatively, download the Expo Go application on your mobile device and scan the generated QR code.
The raw data sources reside in the Data-raw/ folder, spanning combinations of historical agricultural records encompassing crop parameters and fertilizer dependencies. The data-prep/ pipeline joins these datasets ensuring cohesive data frames generated to ./data-processed/ to be uniformly fed into the scikit-learn algorithms.
An ensemble learning algorithm. A multitude of decision trees are generated during training to account for non-linear soil permutations accurately outputting an individual nominal crop classification to minimize entropy.
Utilizes Transfer Learning on a ResNet9 infrastructure (Residual Neural Networks), tackling vanishing gradients and ensuring deep layered training. Sourced out of the PyTorch ecosystem (torch & torchvision), it accepts transposed normalized RGB images mapping inferences correctly targeting categories like 'Tomato___Bacterial_spot' or 'Healthy'.