Machine Learning for Planitorium
https://www.kaggle.com/datasets/mdfikri/planitorium-dataset
This repository contains a deep learning pipeline designed for detecting plant diseases, focusing specifically on maize (corn) leaves. The solution includes data preprocessing, model training, evaluation, and deployment using TensorFlow.js.
- Image Data Preprocessing: Using
ImageDataGeneratorfor data augmentation. - Model Training: A custom Convolutional Neural Network (CNN) built with TensorFlow's Sequential API.
- Callbacks: Includes
EarlyStoppingandLearningRateSchedulerto optimize training. - Evaluation:
- Confusion Matrix
- Classification Report
- ROC AUC Analysis
- Deployment: Conversion of trained model to TensorFlow.js for web-based applications.
To run the code, you need the following dependencies:
pip install tensorflow numpy matplotlib scikit-learn-
Data Preprocessing
- Utilizes
ImageDataGeneratorfor real-time data augmentation. - Splits the dataset into training, validation, and testing subsets.
- Utilizes
-
Model Architecture
- Custom CNN with layers like
Conv2D,MaxPooling2D,Flatten, andDense. - Optimized with Adam optimizer and a learning rate scheduler.
- Custom CNN with layers like
-
Training
- Incorporates
EarlyStoppingto avoid overfitting. - Visualizes training and validation loss/accuracy.
- Incorporates
-
Evaluation
- Generates confusion matrix and classification report.
- Plots ROC curves for multi-class classification.
-
Model Conversion
- Converts the trained TensorFlow model to TensorFlow.js format for web deployment.
-
Data Preparation Place your dataset in a folder structure as follows:
dataset/ Antraknose/ Karat Daun Jagung/ .... -
Run Training Execute the script to train the CNN model:
model.fit() -
Evaluate Model The evaluation results, including confusion matrix and ROC AUC, will be saved in the output directory.
-
Convert to TFJS Convert the trained model to TensorFlow.js format:
tensorflowjs_converter --input_format=tf_saved_model <saved_model_dir> <output_dir>
-
Deploy on Web Use the exported TensorFlow.js model in your web application.
-
Training Accuracy and Loss: Displays graphs of training and validation accuracy/loss over epochs.
-
Confusion Matrix: Visualizes model performance on the test set.
-
ROC Curves: Demonstrates the model's ability to differentiate between classes.
- Expand disease detection to include other crops.
- Improve model accuracy with more sophisticated architectures.
- Add features like personalized crop reminders and an integrated marketplace for farmers.
This project is licensed under the MIT License. Feel free to use and modify the code for your needs.
- TensorFlow for the deep learning framework.
- Open datasets for providing labeled plant disease images.
If you encounter any issues or have suggestions for improvement, feel free to raise an issue or contribute to the repository!