Skip to content

DarkMatterCompiler/LemonSort

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

LemonSort

Automating visual inspection with ML in Agriculture

This repository contains a machine learning model for classifying lemon quality based on images. The model is built using various image processing techniques and machine learning classifiers. The dataset used consists of images of lemons, which are categorized into four classes:

  • Excellent
  • Good
  • Processed Products
  • Disqualified

The repository provides code for loading and processing the dataset, extracting features from images, training multiple classifiers, and evaluating their performance.

Requirements

To run this project, you'll need to install the required dependencies. You can install them using the provided requirements.txt:

pip install -r requirements.txt

Files in this Repository

  1. lemon_classification.py: The main script for loading data, training classifiers, and evaluating their performance.
  2. requirements.txt: A list of Python dependencies required to run the project.
  3. README.md: This file, describing the project and its setup.

Dataset

The dataset used in this project contains images of lemons. The dataset is divided into two parts:

  • Training Images: Used to train the models.
  • Test Images: Used to evaluate the model's performance.

The dataset can be downloaded and extracted using the skillsnetwork library. To prepare the data, the following code is used:

await skillsnetwork.prepare("https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBM-GPXX0UEREN/hiroshima-lemon.zip", overwrite=True)

Features

The features are extracted using Haralick texture features, which capture the structural properties of the images. These features are then used to train the machine learning classifiers.

Classifiers

The following classifiers are trained and evaluated:

  • Logistic Regression
  • K-Nearest Neighbors (KNN)
  • Support Vector Classifiers (SVC) with linear and RBF kernels
  • Gaussian Process Classifier
  • Decision Tree Classifier
  • Random Forest Classifier
  • Neural Network (MLPClassifier)
  • AdaBoost Classifier
  • Naive Bayes Classifier
  • Quadratic Discriminant Analysis (QDA)

Evaluation

The models are evaluated based on their accuracy on the training and validation datasets. A confusion matrix is also generated for each classifier to visualize its performance.

Results

After training the classifiers, the results (including predictions on the test set) are saved in a CSV file. The classification results are also visualized by displaying a few test images along with their predicted class.

How to Run the Project

  1. Clone this repository:

    git clone https://github.com/your-username/lemon-classification.git
    cd lemon-classification
  2. Install the required dependencies:

    pip install -r requirements.txt
  3. Run the script:

    script.ipynb

This will train the models, evaluate them, and save the test results in results.csv.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Automating visual inspection with ML in Agriculture

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published