Documentation

Installation Guide

SmartFarm AI: Crop Disease Detection, Yield Prediction and Farmer Community, a Python Final Year Project with Source Code

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

Installation Guide: SmartFarm AI

This takes about 15 to 20 minutes, and most of that is TensorFlow downloading. Keep your internet on and don't close the terminal halfway through.

Prerequisites

  • Python 3.10.11: Grab it from python.org. Don't use 3.12 or 3.13 for this one, because TensorFlow can be picky. On Windows, tick "Add Python to PATH" during install. Missing that checkbox causes half the "python is not recognized" errors we see.
  • A code editor: VS Code works well.
  • Git (optional): Only needed if you're cloning instead of using the zip we send.
  • About 3 GB free disk space for TensorFlow and the model files.

Step-by-Step Setup

  1. Get the project folder. Unzip SmartFarm-AI somewhere simple, like D:\Projects\SmartFarm-AI. Avoid folders with spaces or very long paths. Then open a terminal inside that folder (in VS Code: Terminal, then New Terminal).

  2. Check your Python version. Run python --version. You want to see 3.10.x. If it shows something else and you have several Pythons installed, use py -3.10 in the next step on Windows.

  3. Create a virtual environment. This keeps the project's packages separate from everything else on your laptop.

    python -m venv venv

  4. Activate it.

    Windows: .\venv\Scripts\activate

    macOS/Linux: source venv/bin/activate

    You'll see (venv) at the start of the terminal line. If you don't see it, the next step will install everything in the wrong place.

  5. Upgrade pip, then install dependencies.

    python -m pip install --upgrade pip

    pip install -r requirements.txt

    This pulls in Flask 2.3.3, scikit-learn 1.3.0, TensorFlow, OpenCV, Pillow and the rest. TensorFlow is big, so let it finish.

  6. Check the models folder. Open models/ and confirm these files are there: yield_prediction_model.pkl, disease_prediction_model.pkl, weather_model.pkl, fertilizer_recommender.pkl, leaf_disease_model.h5, crop_cnn_model.keras, the scaler and encoder .pkl files, and labels.json. You don't need to train anything. Skip the notebooks for now.

  7. Run the app.

    python app.py

    On the first run, database.py creates smartfarm.db automatically. No database setup needed.

  8. Open it in your browser. Go to http://127.0.0.1:5000/.

Common Issues and Fixes

  • "No matching distribution found for tensorflow" or the .keras model fails to load: This is almost always the Python version. Delete the venv folder, recreate it with Python 3.10, and run the install again.

  • "Address already in use" on port 5000: Something else is using that port. On macOS it's often AirPlay Receiver, which you can turn off in System Settings. Or change the port at the bottom of app.py to app.run(debug=True, port=5001) and open http://127.0.0.1:5001/ instead.

  • "ModuleNotFoundError: No module named cv2": Your venv probably wasn't active when you installed. Activate it and run pip install opencv-python.

How to Verify It's Working

  1. Log in with the default admin account: admin@smartfarmai.com / admin123. The admin dashboard should show platform stats.
  2. Register a new account as a Farmer and log in with it.
  3. Open Plant Disease Detection and upload a clear photo of a tomato or potato leaf. You should get a disease name, a confidence percentage and treatment suggestions within a few seconds.
  4. Run a Yield Prediction with any rainfall, pesticide and temperature values, then open your dashboard. The prediction should appear in your history.
  5. Post a question in the forum and create a marketplace listing, then check both show up from the admin panel.

If all five work, you're done. Change the admin password before you demo it to anyone.

Need Help?

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

Chat with Us