Documentation

Installation Guide

AgriSmart: AI-Powered Crop Yield Prediction and Agricultural Advisory System

Step-by-step Setup Verified Instructions Chat Support
Back to Project
Complete Guide

Installation and Setup Guide

Follow the steps below to set up AgriSmart on your local machine. The entire process takes approximately 10 to 15 minutes depending on your internet speed and system configuration.

System Requirements

  • Python 3.8 or above
  • pip (Python package manager)
  • Minimum 4 GB RAM (8 GB recommended for model training)
  • Internet connection for dataset download
  • Any modern browser (Chrome, Firefox, Edge)
01

Clone or Extract the Project

Download the project ZIP from CodeAj Marketplace and extract it, or clone the repository using the command below. Navigate into the project folder after extraction.

git clone <repository_url>
cd "Crop Yield Prediction"
02

Download the Dataset

The dataset files are hosted externally due to their size. Click the button below to download the dataset from Google Drive. Once downloaded, extract the contents and place all CSV files inside the dataset/ folder in the project root.

Dataset folder should contain:
  dataset/
  ├── pesticides.csv
  ├── rainfall.csv
  ├── temp.csv
  ├── yield_df.csv
  └── yield.csv
Download Dataset from Google Drive
03

Create a Python Virtual Environment

It is strongly recommended to create an isolated virtual environment before installing dependencies. This prevents conflicts with other Python projects on your system.

python -m venv venv
04

Activate the Virtual Environment

Activate the virtual environment based on your operating system before proceeding to install dependencies.

Windows
.\venv\Scripts\activate
macOS / Linux
source venv/bin/activate

Once activated, you will see (venv) appear at the beginning of your terminal prompt, confirming the environment is active.

05

Install All Dependencies

Run the following command to install all required Python libraries including Flask, scikit-learn, Keras, TensorFlow, NumPy, Pandas, Matplotlib, and Seaborn in one step.

pip install -r requirements.txt

This step may take 3 to 8 minutes depending on your internet connection as it downloads TensorFlow and other large libraries.

06

Verify Pre-trained Model Files

The pre-trained machine learning models are included in the models/ directory and are ready to use without any additional training. Verify that the following files are present.

models/
  ├── yield_prediction_model.pkl     (Random Forest — crop yield)
  ├── yield_scaler.pkl               (scaler for yield inputs)
  ├── disease_prediction_model.pkl   (CNN — plant disease detection)
  ├── disease_scaler.pkl             (scaler for disease inputs)
  ├── disease_encoder.pkl            (label encoder for diseases)
  └── weather_model.pkl              (Linear Regression — rainfall)

The fertilizer_recommender.pkl file is optional. If not present, the system automatically falls back to a built-in rule-based recommendation engine. This is expected behavior and does not affect functionality.

07

Retrain Models (Optional)

If you want to retrain the models from scratch or explore the training process for your project presentation, open the Jupyter Notebook and execute all cells in order.

jupyter notebook training.ipynb

Running the full training notebook will overwrite the existing model files in the models/ directory with newly trained versions. Skip this step if you want to use the pre-trained models.

08

Run the Flask Application

Start the AgriSmart web server using the command below. The application will launch on your local machine and be accessible through your browser.

python app.py

Once running, open your browser and go to:

http://127.0.0.1:5000/
09

Navigate the Application

Use the following URLs to access each module of AgriSmart directly from your browser.

Module URL
Home Dashboard http://127.0.0.1:5000/
Crop Yield Prediction http://127.0.0.1:5000/yield-prediction
Disease Detection http://127.0.0.1:5000/disease-prediction
Fertilizer Recommendation http://127.0.0.1:5000/fertilizer-recommendation
Weather Prediction http://127.0.0.1:5000/weather-prediction
About http://127.0.0.1:5000/about
10

API Endpoints (For Developers)

AgriSmart also exposes REST API endpoints that accept POST requests, allowing programmatic access to all four AI modules. Refer to app.py for the exact request payload and response structure for each endpoint.

POST  /api/predict-yield
POST  /api/predict-disease
POST  /api/recommend-fertilizer
POST  /api/predict-weather

Common Issues and Fixes

TensorFlow installation fails on Windows

Make sure you are using Python 3.8 to 3.11. TensorFlow does not officially support Python 3.12 and above on some platforms. Consider using Python 3.10 for best compatibility.

fertilizer_recommender.pkl not found warning

This is not an error. The system automatically uses the built-in rule-based fallback engine if this file is absent. All fertilizer recommendations will still work correctly.

Dataset files not found error on startup

Ensure all five CSV files from the Google Drive download are placed inside the dataset/ folder. The folder must be in the same directory as app.py.

Port 5000 already in use

Another application is using port 5000. You can run Flask on a different port using: python app.py --port 5001 or change the port inside app.py.

Need Help With Setup?

CodeAj offers a dedicated Project Setup and Source Code Explanation service. Our team will guide you through the complete installation process, walk you through every module of the code, and ensure you are fully prepared for your final year project submission and viva. Visit our services page to know more.

Need Help?

Our team is here to assist you with installation and setup.

Chat with Us
Chat with us