How achuabhijith2003/ai-based-crop-disease-detection works
1. This repository is a small Flask-based plant disease recognition app with a supporting machine-learning workflow. The runtime app is in app.py, while model training/testing logic lives under core/ and the UI is rendered from templates/.
2. The main user-facing boundary is the Flask web layer:
- templates/index.html and templates/dashboard.html define the pages.
- templates/static/scripts.js and templates/static/style.css provide client-side behavior and styling.
- The README hints at a camera/photo interaction flow, so the UI likely supports uploading or capturing a plant image and then showing a diagnosis/result.
3. The application entrypoint is app.py. It is the central orchestration layer that connects:
- HTTP requests from the browser,
- template rendering,
- image/disease prediction logic,
- and disease detail lookup/storage.
4. The ML subsystem is split into two parts:
- core/train_plant_disease.py for training the disease classification model,
- core/test_plant.py for running inference on new plant images.
The Jupyter notebooks Train_plant_disease.ipynb and Test_Plant_Disease.ipynb appear to be exploratory or interactive versions of those same workflows.
5. The dependency set in req.txt shows the system is built around:
- Flask for the web server,
- TensorFlow and NumPy for model inference/training,
- OpenCV for image handling,
- pandas and openpyxl for tabular/Excel-based disease metadata,
- matplotlib likely for training visualization or notebook analysis.
6. Disease knowledge is stored separately from the model:
- disease_details.xlsx exists at the repository root,
- and there is another copy under DB/.
This suggests the app uses an external disease-reference dataset to map predicted classes to human-readable treatment or symptom details.
7. There is a small persistence layer under core/db_operation.py, backed by DB/Treatment.db. This indicates the app is not purely stateless; it likely reads and/or writes treatment or disease records to SQLite for lookup, history, or metadata management.
8. The data flow is probably:
- user loads the dashboard,
- captures or uploads a plant image,
- Flask receives the request,
- core/test_plant.py classifies the image,
- the predicted disease label is matched against Excel/SQLite disease details,
- the result is rendered back into the dashboard template.
9. The repository also contains the training assets needed to reproduce or update the classifier. That makes the architecture two-phase:
- offline model development/training via notebook or core/train_plant_disease.py,
- online inference via the Flask app and core/test_plant.py.
The deployed web app depends on the output of the training pipeline, even if the exact model artifact file is not listed here.
10. The DB/ folder is an important boundary: it separates application code from persisted data assets. In an architecture diagram, this would sit alongside the ML model artifact and disease metadata as external resources consumed by the Flask app rather than part of the request-handling code itself.
11. The README’s Flask setup instructions imply a local development deployment, not a cloud-native service. The system appears to run as a single-process local web app with filesystem-backed assets, rather than a distributed architecture.
12. Overall, the repository is best drawn as four layers:
- browser/UI,
- Flask application/controller layer,
- ML inference + disease lookup layer,
- persistent assets/data layer (model-related files, SQLite DB, Excel metadata).
The key integration point is app.py, which coordinates all of them.
Main entry points: app.py Flask app · test_plant.py Inference · train_plant_disease.py Training · index.html Home page
Components 16
Browser UI
User-facing pages and client-side assets
- User · Person using the crop disease app
- Home page · Landing page and upload/capture entry point
templates/index.html - Dashboard · Results and diagnosis view
templates/dashboard.html - Client script · Browser interaction and UI behavior
templates/static/scripts.js - Stylesheet · UI styling for pages
templates/static/style.css
Flask App
Request handling and orchestration
ML Pipeline
Training and inference logic
- Inference · Classifies plant images into disease labels
core/test_plant.py - Training · Builds or updates the disease classifier
core/train_plant_disease.py - Train notebook · Interactive training workflow
Train_plant_disease.ipynb - Test notebook · Interactive inference workflow
Test_Plant_Disease.ipynb
Persistent Data
Models, databases, and disease reference data
- Disease sheet · Excel disease metadata at repo root
disease_details.xlsx - DB sheet · Excel disease metadata copy under DB
DB/disease_details.xlsx - Treatment DB · Persistent treatment or disease records
DB/Treatment.db - Model assets · Trained classifier consumed by inference
- Dependencies · Flask, TensorFlow, OpenCV, NumPy, pandas, Excel support
req.txt
Connections 19
- User → Home page: opens · Starts at the home page
- Home page → Client script: loads · Browser loads client behavior
- Home page → Stylesheet: styles · Browser loads page styling
- Client script → Flask app: submit image · Uploads or captures plant image to Flask
- User → Dashboard: views · Receives diagnosis results
- Flask app → Home page: renders · Serves the entry page
- Flask app → Dashboard: renders · Serves diagnosis and result page
- Flask app → Inference: predicts · Delegates image classification
- Flask app → DB ops: looks up · Fetches disease or treatment details
- Inference → Model assets: loads · Uses trained weights or model files
- Inference → Disease sheet: matches · Maps prediction to human-readable details
- Inference → DB sheet: matches · Alternative disease reference source
- DB ops → Treatment DB: queries · Reads or writes persistent records
- Training → Model assets: produces · Trains the classifier artifact
- Training → Disease sheet: uses data · Consumes labeled disease metadata or training references
- Train notebook → Training: explores · Notebook version of training workflow
- Test notebook → Inference: explores · Notebook version of inference workflow
- Flask app → Dependencies: depends on · Runtime package set for the web app
- Training → Dependencies: depends on · Training stack and scientific libraries