This repository contains a collection of resources used during the capstone project for Bangkit Machine Learning. The project focuses on building machine learning models for our application. For our machine learning needs, we have built image classifier models for plant disease detection and Soil detection.
Sandler, M., Howard, A., Zhu, M., Zhmoginov, A., & Chen, L. C. (2018). Mobilenetv2: Inverted residuals and linear bottlenecks. In Proceedings of the IEEE conference on computer vision and pattern recognition (pp. 4510-4520).
- New Plant Diseases Dataset
- Corn or Maize Leaf Disease Dataset
- Rice Leaf Disease Dataset
- Soil Type Dataset
The model architecture consists of the following layers:
- Convolutional layer with 32 filters and a ReLU activation function.
- Max pooling layer with a 2x2 pool size.
- Flatten layer to convert the 2D feature maps into a 1D feature vector.
- Dense layer with the number of units equal to the number of classes, using softmax activation.
The dataset we used consists of the Plant_Disease_Classifcation
model are images belonging to nine different classes of plant diseases, including Corn Blight, Corn Common Rust, Corn Gray Spot, Corn Healthy, Potato Blight, Potato Healthy, Rice Blight, Rice Brown Spot, and Rice Leaf Smut. While the dataset for the Soil_Types_Classification
model are images belonging to five different classes of soil types, including Black Soil, Cinder Soil, Laterite Soil, Peat Soil, and Yellow Soil.
Data augmentation techniques are applied to increase the diversity and size of the dataset. The ImageDataGenerator
class from TensorFlow is used for rescaling, rotation, zooming, flipping, shifting, shearing, and adjusting the brightness of the images.
The model is then trained using the augmented dataset. Plant_Disease_Classifcation
model training is performed for 10 epochs with a batch size of 8. While Soil_Types_Classification
model is performed for 25 epochs with a batch size of 4. Two callbacks, EarlyStopping and ReduceLROnPlateau, are used for early stopping and learning rate reduction based on validation loss.
The trained model is evaluated using the test dataset. The evaluation provides the loss and accuracy scores of the model on the test dataset. Additionally, a sample of images from the test dataset is used to demonstrate the model's predictions. The predicted class and confidence score are displayed for each image.
The trained model is saved in the HDF5 format as model.h5
for future use. To integrate the model with Android applications, the model is converted to the TensorFlow Lite (TFLite) format using the TFLite Converter. The TFLite model is saved as model.tflite
for deployment on resource-constrained devices.
In addition to the TFLite model, a metadata file (metadata.txt
) is provided. The metadata file contains information about the model, such as input and output tensor names, input and output types, and model descriptions. It serves as a reference for integrating the TFLite model into applications.
To run the notebook and utilize the model, the following dependencies are required:
- Tensorflow
- Keras
- Matplotlib
- NumPy
- PIL
- psutil
- Clone the repository
git clone github.com/Terrafarms/bangkit-machine-learning.git
- Install the required dependencies in your Google Colab/Jupyter Notebook.
pip install tensorflow keras matplotlib numpy pillow psutil
-
Navigate to the repository
Notebooks
directory and open the notebooks. -
Run the cells in the notebook to train the model and evaluate its performance.
-
Save the trained model as model.h5 for future use.
-
Convert the model to TFLite format using the provided code and save it as model.tflite.
-
Use the saved model for inference in your applications. Refer to the metadata file (metadata.txt) for integration details.
Contributions to this project are welcome. If you have any ideas, suggestions, or improvements, please submit a pull request. Make sure to follow the existing coding style and guidelines.
This project is licensed under the MIT License. Feel free to use, modify, and distribute the code as per the license terms.
For any inquiries or feedback, please contact the project team at [email protected]