Skip to content

pierre-parel/cbd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Green Coffee Bean Defect Detection

A deep learning project to classify 8 types of green coffee bean defects using EfficientNetV2S and transfer learning, achieving high accuracy and precision.

Model Overview

  • Developed a deep learning model using EfficientNetV2S with transfer learning to classify 8 types of green coffee bean defects.
  • Applied advanced image augmentation techniques such as random rotation, translation, and contrast adjustment to enhance generalization and reduce overfitting.

File Descriptions

evaluate.py

Evaluates a pre-trained model on training and test datasets for green coffee bean defect classification and generates a confusion matrix (confusion_matrix.jpg).

generate_augmented_images.py

Creates augmented images (rotations) to improve model generalization and reduce overfitting.

generate_split.py

Splits the dataset into stratified training and testing sets, organizing them into directories (coffee_bean_test and coffee_bean_train).

transfer_learning.py

Trains a model using transfer learning with EfficientNetV2S and saves performance plots(accuracy.jpg and loss.jpg) and checkpoints(inside saved_models).

run.sh

Runs the full pipeline: dataset setup(unzipping downloaded .zip file), data augmentation, and training.

clean.sh

Cleans up generated files and directories, resetting the project environment.

Datasets

The dataset used for this project is a modified version of the aggregation of the following datasets:

Setting Up the Environment

Tensorflow with GPU access is no longer supported past TensorFlow 2.10. Hence, it is recommended to use WSL2. The instructions below are from NVIDIA's setup docs for CUDA in WSL.

  1. Launch your preferred Windows Terminal/Command Prompt/Powershell and install WSL:
wsl --install
  1. Ensure you have the latest WSL kernel
wsl --update
  1. Setup your Linux user info by providing a username and password.

In the future, you can open WSL by typing wsl in the search bar in the Windows start menu.

Enabling CUDA for WSL2

  1. Remove the old GPG key:
sudo apt-key del 7fa2af80
  1. Run the installation instructions one by one as indicated on the CUDA download page for WSL-Ubuntu

NOTE: It is important to check if your system meets the hardware, software, and system requirements to run TensorFlow. Please check in the official TensorFlow documentation for more details.

Getting Started

  1. Clone the repository
git clone https://github.com/pierre-parel/cbd.git
cd cbd
  1. Create virtual environment and install required modules
sudo apt install python3 python3-venv
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
  1. Download dataset.zip and place it in the root folder.
  2. Unzip the dataset, generate train/test split, and train the model using run.sh:
./run.sh

See run.sh file description

  1. To evaluate the model, modify line 8 of evaluate.py to the desired saved model and run:
python evaluate.py

TODO

  • Use GPU for faster training. See Install TensorFlow with pip and Use a GPU
  • Change from Xception to EfficientNetV2B0.
  • Use different pretrained model for comparison
  • Data augmentation
  • Prefetch dataset
  • Test multilabel classification
  • Fine-tuning of the model
  • Experiment with different layers in my_model
  • Try using other image augmentation techniques

References

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •