AI-Powered Soil Crop Recommendation & Pathogen Detection Inspiration
In rural communities across Nigeria, farmers often rely on guesswork to decide what crops to plant or how to treat diseased plants. Many lose income due to low yields caused by poor soil–crop matching or crop loss from undiagnosed diseases. I was inspired to create a system that puts expert agricultural knowledge in the hands of everyday farmers — powered by Artificial Intelligence (AI) , to recommend suitable crops and detect plant diseases from images.
What it does
The system is a simple web-based platform with two powerful features:
Soil-Based Crop Recommendation: Users input soil parameters Nitrogen (N), Phosphorus (P), Potassium (K), pH, temperature, moisture, etc. — and the system recommends the most suitable crop using a trained AI model.
Leaf Disease Detection and Solution: Farmers can upload an image of a diseased plant leaf. The system uses a Convolutional Neural Network (CNN) to:
Detect the disease (e.g., tomato blight, rust, etc.).
Recommend immediate treatment or prevention solutions.
The result is shown as: Disease Name | Recommended Action
How we built it
1. Model Training:
Crop recommender: Trained using a dataset with over 2,000 soil–crop records.
Disease detection: Used TensorFlow and Keras to train a CNN on labeled leaf images.
2. Model Deployment:
Saved the trained model as model.h5.
Created a Python script (predict_disease.py) that takes image input and outputs predictions in real time.
3. Web Interface:
Built with PHP and HTML, hosted using XAMPP.
Connected PHP to Python via shell execution for real-time AI predictions.
Designed a user-friendly interface to display predictions and recommended actions.
Challenges we ran into
Model Compatibility Issues: Some .h5 models failed to load due to naming conflicts or incompatible TensorFlow versions.
- PHP–Python Integration: Ensuring smooth communication between backend PHP and Python prediction script required careful debugging and output parsing.
- Offline Usage: Optimizing the system to run without internet access, including reducing model and dependency size.
- Limited Hardware: The model had to run efficiently on devices without GPUs or high specs.
Accomplishments that we're proud of
Successfully deployed a dual-function system (recommendation + detection).
- Achieved over 95% accuracy in leaf disease classification.
- Built a working prototype that runs offline and can be used in resource-limited settings.
- Created a tool with real-world potential to improve agriculture and food security.
What we learned
1. How to preprocess and use real-world datasets for machine learning.
2. How to build and deploy CNN models in TensorFlow/Keras.
3. How to bridge AI models with web platforms using PHP and Python.
4. Realized the importance of model optimization for low-resource environments.
What's next for AI-Powered Soil Crop Recommendation & Pathogen Detection
1. Mobile App Version for wider adoption in rural areas.
2. Multilingual Voice Assistant to assist non-literate farmers.
3. Realtime Weather + Soil Sensor Integration using IoT.
4. Expand to include more crops and diseases.
5. Pilot testing in farming communities to collect feedback and improve accuracy.
Problem Definition and Identified Constraints:-
Rural farmers and small-scale agricultural communities in Africa face two major challenges:
- Lack of tailored crop recommendations based on local soil conditions.
- Limited access to early plant disease diagnosis tools, often resulting in poor yields. Identified constraints included:
- Low budget and limited infrastructure (e.g., no internet in remote areas)
- Need for a user-friendly interface for non-technical users
- Unpredictable weather and soil conditions requiring flexible, adaptable models
Alternative Design Explorations and Final Decisions:
Explorations:
- Tested cloud-based platforms but abandoned them due to internet dependency.
- Considered using a fully mobile solution but storage and processing limitations made it impractical for image-based ML.
Final decisions:
- A web-based PHP front-end with Python back-end AI modules was selected for its balance of accessibility and offline support.
- Used a pre-trained CNN model (.h5) for leaf disease detection and a rule-based recommendation system for crops.
Tools and Technologies Used:-
AI/ML:
- Convolutional Neural Networks (CNN) for image-based plant disease detection
- Scikit-learn for preliminary data analysis and model development
IoT (planned future integration):
- Soil sensors for live NPK, pH, and moisture monitoring
Technologies:
- PHP + MySQL – web interface and local data storage
- Python (TensorFlow, NumPy, Pillow) – AI model execution and image processing
- XAMPP – for offline server setup
Technical Implementation Details and Performance Benchmarks:-
- Crop Recommender: Based on NPK, pH, and rainfall input from users
- Leaf Disease Detection: Accepts uploaded images, resizes them to 128x128, and predicts class with a trained CNN
Performance Benchmarks:
- Leaf classification model achieved ~95% accuracy on validation set
- Prediction time: < 1.5 seconds per image
- Designed to run on basic Windows PC with Python 3.9 and no GPU
Log in or sign up for Devpost to join the conversation.