Documentation

Installation Guide

AI-Powered Plant Disease Detection System Using CNN and Flask — Final Year Project with Source Code

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

Installation Guide

Follow the steps below to set up the PlantAI Plant Disease Detection project on your local machine. This guide covers environment setup, dependency installation, API configuration, and running the application.

Prerequisites

  • Python 3.10 or higher installed on your system
  • pip (comes bundled with Python 3.10+)
  • Git installed and configured
  • Active internet connection for initial model download

Step 1: Clone the Repository

git clone <your-repository-url>
cd leaf-health-detector-main

Step 2: Create and Activate a Virtual Environment

On macOS and Linux:

python3 -m venv .venv
source .venv/bin/activate

On Windows:

python -m venv .venv
.venv\Scripts\activate

Step 3: Upgrade pip

pip install --upgrade pip

Step 4: Install Project Dependencies

pip install -r requirements.txt
pip install stripe

Note: The stripe package is not currently listed in requirements.txt, so it must be installed separately using the command above.

Step 5: Configure Your API Keys

Open app.py in any code editor. Locate the inline Groq API key and Stripe secret key and replace them with your own credentials. Before deploying publicly, move these values to environment variables:

import os
GROQ_API_KEY = os.environ.get("GROQ_API_KEY")
STRIPE_SECRET_KEY = os.environ.get("STRIPE_SECRET_KEY")

Step 6: Verify the Trained Model File

Check that the file plant_disease_model_1_latest.pt is present in the root project directory. If it is missing, the application will attempt to download it automatically from Google Drive using gdown when you first start the server.

Step 7: Run the Development Server

python3 app.py

The application will start at:

http://127.0.0.1:5001

Step 8: Run with Gunicorn (Production Mode)

gunicorn app:app --bind 0.0.0.0:5001

Step 9: Verify Syntax Before Deployment

python3 -m py_compile app.py CNN.py

This checks that both Python files parse correctly. It does not validate API credentials or external service connectivity.

Deploying to Render

A render.yaml configuration file is included in the repository. To deploy:

  • Push the repository to GitHub
  • Connect the repository to your Render account
  • Add GROQ_API_KEY and STRIPE_SECRET_KEY as environment variables in the Render dashboard under Environment settings
  • Render will use the following start command automatically: gunicorn app:app --bind 0.0.0.0:$PORT

Important Notes on CSV File Alignment

The disease_info.csv and supplement_info.csv files must remain index-aligned with the 39 class definitions in CNN.py. If you reorder rows in either CSV file, update the class list in CNN.py accordingly, otherwise predictions will map to incorrect disease entries.

Upload Directory Permissions

Uploaded leaf images are stored in the static/uploads/ directory. Ensure this folder exists and that the web server process has write permissions to it on your deployment environment.

Need Help?

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

Chat with Us
Chat with us