Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# MobileNetV3 Model for Plant Classification
|
| 2 |
+
|
| 3 |
+
## Model Description
|
| 4 |
+
This model is a fine-tuned **MobileNetV3Small** trained to classify different types of plants. It was trained using transfer learning on a dataset obtained from Kaggle.
|
| 5 |
+
|
| 6 |
+
- **Base Model:** MobileNetV3Small (pretrained on ImageNet)
|
| 7 |
+
- **Dataset:** [Plants Classification Dataset](https://www.kaggle.com/datasets/marquis03/plants-classification)
|
| 8 |
+
- **Accuracy:** 88%
|
| 9 |
+
- **Fine-Tuning:** Last 20 layers of MobileNetV3Small were unfrozen for fine-tuning.
|
| 10 |
+
|
| 11 |
+
## Dataset
|
| 12 |
+
The dataset consists of images of various plant species, divided into training and validation sets:
|
| 13 |
+
- **Training Images:** Preprocessed with data augmentation (rotation, shifting, zoom, brightness adjustment, etc.)
|
| 14 |
+
- **Validation Images:** Rescaled without augmentation
|
| 15 |
+
|
| 16 |
+
## Model Training
|
| 17 |
+
The model was trained using **TensorFlow** and **Keras**, with categorical crossentropy loss and the Adam optimizer. The training process involved:
|
| 18 |
+
|
| 19 |
+
1. **Data Augmentation** using `ImageDataGenerator`.
|
| 20 |
+
2. **Transfer Learning** by leveraging MobileNetV3Small's pretrained weights.
|
| 21 |
+
3. **Fine-Tuning** of the last 20 layers.
|
| 22 |
+
4. **Learning Rate Scheduling** using `ReduceLROnPlateau`.
|
| 23 |
+
5. **Evaluation** using classification reports and a confusion matrix.
|
| 24 |
+
6. **Exporting the Model** as a `.tflite` file for mobile deployment.
|
| 25 |
+
|
| 26 |
+
## Model Performance
|
| 27 |
+
- **Training Accuracy:** 88%
|
| 28 |
+
- **Validation Accuracy:** 88%
|
| 29 |
+
- **Loss Function:** Categorical Crossentropy
|
| 30 |
+
- **Optimizer:** Adam (learning rate = 0.0001)
|
| 31 |
+
|
| 32 |
+
## Usage
|
| 33 |
+
To use the model for inference, load it using TensorFlow:
|
| 34 |
+
|
| 35 |
+
```python
|
| 36 |
+
import tensorflow as tf
|
| 37 |
+
from tensorflow.keras.models import load_model
|
| 38 |
+
|
| 39 |
+
# Load the model
|
| 40 |
+
model = load_model("mobilenetv3_tanaman.h5")
|
| 41 |
+
|
| 42 |
+
# Preprocess an input image
|
| 43 |
+
import numpy as np
|
| 44 |
+
from tensorflow.keras.preprocessing import image
|
| 45 |
+
|
| 46 |
+
img_path = "path_to_image.jpg"
|
| 47 |
+
img = image.load_img(img_path, target_size=(224, 224))
|
| 48 |
+
img_array = image.img_to_array(img) / 255.0
|
| 49 |
+
img_array = np.expand_dims(img_array, axis=0)
|
| 50 |
+
|
| 51 |
+
# Make a prediction
|
| 52 |
+
predictions = model.predict(img_array)
|
| 53 |
+
class_idx = np.argmax(predictions)
|
| 54 |
+
print(f"Predicted class: {class_idx}")
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
## Deployment
|
| 58 |
+
This model can be deployed for:
|
| 59 |
+
- Mobile applications (converted to `.tflite` for TensorFlow Lite compatibility)
|
| 60 |
+
- Web-based applications
|
| 61 |
+
- Embedded AI systems for plant classification
|
| 62 |
+
|
| 63 |
+
## License
|
| 64 |
+
This model is provided for research and educational purposes. Please ensure to cite the original dataset from Kaggle if used in any publication.
|
| 65 |
+
|
| 66 |
+
## Citation
|
| 67 |
+
If you use this model, please cite:
|
| 68 |
+
```
|
| 69 |
+
@misc{PlantClassification2024,
|
| 70 |
+
title={MobileNetV3 Model for Plant Classification},
|
| 71 |
+
author={Ade Maulana},
|
| 72 |
+
year={2024},
|
| 73 |
+
url={https://huggingface.co/your-huggingface-repo}
|
| 74 |
+
}
|
| 75 |
+
```
|
| 76 |
+
|