A deep learning web application built with TensorFlow, FastAPI, and LangChain that classifies potato leaf diseases and provides an AI-powered agricultural chatbot for farmers and researchers.
The app predicts whether a potato leaf is:
- Early Blight 🍂
- Late Blight 🧫
- Healthy ✅
- 📷 Image Upload & Real-Time Disease Prediction
- 💬 RAG-based Agricultural Chatbot integrated using LangChain
- 🎨 Clean and responsive frontend (HTML, CSS, JS)
- 🌆 Background image with blur effect
- 🧠 Convolutional Neural Network (CNN) for disease classification
- ⚡ FastAPI Backend for prediction and chatbot APIs
- 🔒
.envfile support for secret keys (e.g., Hugging Face token)
- Input Shape:
256x256x3 - Architecture:
- 6 × Conv2D layers (ReLU activation)
- MaxPooling for downsampling
- Dense layers for classification
- Softmax output layer
- Model File:
potatoes.h5 - Framework: TensorFlow / Keras
Alongside disease prediction, this project includes a Retrieval-Augmented Generation (RAG) chatbot that answers agricultural queries related to potato diseases, treatment methods, and farming practices.
-
Knowledge Base Creation
- Collected domain-specific text documents about potato diseases and farming techniques.
- Loaded using
TextLoaderfrom LangChain.
-
Text Processing
- Split into smaller chunks using
RecursiveCharacterTextSplitterfor efficient retrieval.
- Split into smaller chunks using
-
Vector Store
- Created embeddings using:
model_name = "sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2"
- Stored embeddings in FAISS (Facebook AI Similarity Search) for high-speed retrieval.
- Created embeddings using:
-
RAG Chain
- Combined retriever + Hugging Face language model for contextual question answering.
- Deployed via FastAPI endpoints alongside the disease classification API.
Watch the full project demo on YouTube: 👉 https://youtu.be/ZknDwnZHyRk
bash git clone https://github.com/aliahmad552/potato_disease_recognition.git cd Potato-Disease-Classification
bash Copy Edit pip install -r requirements.txt
bash Copy Edit python app.py Now visit: http://127.0.0.1:5000
Custom dataset with three classes (Early Blight, Late Blight, Healthy)
Train/Validation/Test split handled using ImageDataGenerator
Image size: 256x256, normalized between 0-1
Ali Ahmad BS Software Engineering – The Islamia University of Bahawalpur GitHub: aliahmad552