A deep learning project to classify diseases in fruits and vegetables using CNNs and traditional ML models (SVM, KNN, Random Forest).
Note: This project is designed to be adaptable for any CNN-based classification dataset, making it a versatile tool for various image classification tasks.
This project aims to:
- Detect Diseases: Classify fruits/vegetables as healthy or diseased (e.g.,
Apple_Healthyvs.Apple_Rotten). - Compare Models: Evaluate CNN performance against traditional ML models (SVM, KNN, Random Forest).
Key Features:
- Data preprocessing and augmentation.
- CNN model training with TensorFlow/Keras.
- Traditional ML pipelines with scikit-learn.
- Model accuracy comparison and visualization.
- Confusion matrix and classification report generation.
The dataset is downloaded from Kaggle:
Fruit and Vegetable Disease Dataset
Structure:
- Images of fruits and vegetables categorized as
HealthyorDiseased. - Split into training, validation, and test sets during preprocessing.
Follow these steps to set up the project:
- Clone the Repository:
git clone https://github.com/SecurDrgorP/Model_Crafter_Project.git cd Fruits-and-Vegetables-Disease-Detection
To run the project, follow these steps:
-
Prepare the Dataset:
- Ensure the dataset is downloaded and placed in the
data/rawdirectory. - Run the main script to clean and preprocess the dataset:
python main.py
- Ensure the dataset is downloaded and placed in the
-
Train the CNN Model:
- During training, you will be prompted to choose whether to use the custom checkpoint logic:
Do you want to use the custom checkpoint logic? (y/n): - Type
yto enable saving the model based on the lowest difference between training and validation accuracy and the lowest validation loss.
- During training, you will be prompted to choose whether to use the custom checkpoint logic:
-
Evaluate Models:
- The pipeline will automatically evaluate both CNN and traditional ML models and save the results in the
results/directory.
- The pipeline will automatically evaluate both CNN and traditional ML models and save the results in the
-
View Results:
- Check the classification reports, confusion matrix, and model comparison CSV in the
results/directory.
- Check the classification reports, confusion matrix, and model comparison CSV in the
- Custom Checkpoint Logic: Save the CNN model based on the lowest difference between training and validation accuracy and the lowest validation loss.
- Traditional ML Models: Compare CNN performance with SVM, KNN, and Random Forest.
- Visualization: Generate confusion matrices and classification reports for better insights.
- Data Augmentation: Automatically applies augmentation to improve model generalization.
- CNN Model: Achieved high accuracy in detecting diseases in fruits and vegetables.
- Traditional ML Models: Performance varies depending on the dataset and preprocessing.
- Comparison: Results are saved in
results/f1_comparison.pngfor easy analysis.