Documentation

Installation Guide

LeafLens: AI Plant Disease Detection from Leaf Photos | Python Final Year Project with Source Code

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

Setting Up LeafLens on Your Laptop

This should take about 15 minutes. Most of that is waiting for TensorFlow to download. You don't need a GPU, you don't need to train anything, and you don't need a database server.

Prerequisites

  • Python 3.10.11. Grab it from python.org. Don't use Python 2.7, and avoid 3.13 too, because TensorFlow 2.18 won't install on it. On Windows, tick the "Add Python to PATH" box on the first install screen. People miss this all the time.
  • pip, which comes with Python. Check with pip --version.
  • A browser such as Chrome, Edge or Firefox.
  • About 2 GB of free disk space for TensorFlow and its friends.
  • Optional: a free Groq API key from console.groq.com and a free OpenWeatherMap key from openweathermap.org. Without them the app still detects diseases. You just won't see the AI advice and weather sections.

Step-by-Step Setup

  1. Open the project folder. Extract the zip you got from CodeAj (or clone the repo if you were given one). Open a terminal or Command Prompt and go into the backend folder:
    cd LeafLens_Project_Architecture/backend
  2. Create a virtual environment. This keeps LeafLens's libraries separate from everything else on your system.
    python -m venv venv
    Then activate it.
    Windows: venv\Scripts\activate
    macOS / Linux: source venv/bin/activate
    You'll see (venv) at the start of your terminal line once it works.
  3. Install the dependencies.
    pip install -r requirements.txt
    This installs Flask 3.1.0, TensorFlow 2.18.0, Pillow, Groq, requests and NumPy. TensorFlow alone is a few hundred MB, so on slow Wi-Fi go make chai.
  4. Add your API keys (optional). Skip this step if you just want detection.
    Windows (Command Prompt):
    set GROQ_API_KEY=your_groq_api_key
    set OPENWEATHER_API_KEY=your_openweather_api_key
    Windows (PowerShell):
    $env:GROQ_API_KEY="your_groq_api_key"
    $env:OPENWEATHER_API_KEY="your_openweather_api_key"
    macOS / Linux:
    export GROQ_API_KEY="your_groq_api_key"
    export OPENWEATHER_API_KEY="your_openweather_api_key"
    These only last for the current terminal window. Open a new one and you'll have to set them again.
  5. Start the server.
    python app.py
    The first start takes a few seconds because the model is loading. When the terminal shows the server running, move on.
  6. Open the app. Go to http://localhost:5001 in your browser. You should see the LeafLens home page.

How to Verify It's Working

  1. Open http://localhost:5001/api/health. You should see {"status": "ok", "service": "LeafLens API"}. If you do, the backend is fine.
  2. Go to the Detect page and upload any image from dataset/raw_dataset/, for example a Snake Plant Anthracnose photo.
  3. Type a city name like "Delhi" and click Analyze.
  4. You should get the plant name, condition, a confidence percentage, tabs for symptoms, treatment, prevention and care basics, and (if your keys are set) a weather box plus an AI recommendation card.

Common Issues

  • "No matching distribution found for tensorflow==2.18.0"
    Your Python version is wrong, almost always 3.13 or a 32-bit install. Run python --version. Uninstall it, install Python 3.10.11 (64-bit), delete the venv folder, and redo steps 2 and 3.
  • Model file not found / FileNotFoundError on startup
    You probably ran python app.py from the wrong folder. The paths in config.py expect you to be inside backend/. Run cd into it and try again.
  • Port 5001 already in use
    Another app is using that port. Close it, or open app.py, change the port number to something like 5002, and use that in the browser instead.
  • Detection works but there's no AI advice or weather
    Your environment variables aren't set in the terminal that's running the server. Stop the server with Ctrl + C, set the keys again in that same window, and restart.

Still stuck? Message us with a screenshot of the error and we'll get on a call and sort it out.

Need Help?

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

Chat with Us