Skip to content

DariusTorabian/image-classifier

Repository files navigation

Contributors Forks Stargazers Issues MIT License LinkedIn


Logo

Image Classifier

Utilizing a Convolutional-Neural-Network to perform image classification on fruits.

Report Bug · Request Feature

Table of Contents

About The Project

Project Preview

In this project, I've built a neural-network powered image classifier, that utilizes the users webcam to predict the type of fruit in the frame.

Of course this project doesn't have any real-world impact by itself. But similar machine-learning methods for image classification tasks are already revolutionizing fields with a much higher real-world impact like e.g. the classification of different cancer types or to make split-second decisions in the realm of autonomous driving.

The used dataset for training and validation has been manually shot and merged by my fellow data scientists Malte Bonart, Samuel McGuire and myself. It consists of 140 images of oranges, 91 images of apples and 46 images of bananas. I'm using a 80% training, 20% validation split. Even though it is a relative small and imbalanced dataset with only 277 images in total, the trained model performs quite well after training and achieves a validation accuracy in the high 90s.

The architecture of the neural-network I've chosen has 2,797,795 total trainable params. It is a CNN (Convolutional-Neural-Network) with multiple units comprised of 2D convolutional layer and MaxPooling2D layer with a pool size of (2, 2). After three of those units, the output is then flattened and put in a Dense layer, followed by a Dropout layer to aid with preventing overfitting, followed by another Dense layer. All hidden layers are utilizing a ReLU activation function, while the output-layer utilizes a Softmax activation function. As this is a multi-class classification task, I'm using the categorical_crossentropy loss function.

The model has been trained locally on a Macbook Pro 13-inch with a 2,3 GHz Quad-Core Intel Core i5.

Take a look at the neural-network architecture here:

CNN architecture

I've also built an easy-to-use interface to test out the model utilizing your webcam. After following the instructions below, you can hold up an apple, banana or orange and after pressing 'p', the model will predict the fruit you're holding.

Built With

Getting Started

To get a local copy up and running follow these simple steps.

Prerequisites

I'd advice you to create an own virtual environment for this project. I'm using Anaconda.

Installation & Usage

  1. Clone the repo
git clone https://github.com/dariustorabian/image-classifier.git
  1. Install dependencies with the requirements.txt
conda create --name <NameOfEnvironment> --file requirements.txt
  1. Run capture.py in the command line and your webcam will open up. My pretrained model will automatically be loaded in. If you'd like to know how it was created, you can take a look at the code in the Jupyter Notebook model_selftrained.ipynb.

  2. Press the p key while holding an apple, orange or banana to let the model tell you which fruit you are holding. Press Space to take a picture and q to close the window. Pictures will be saved in ./out/ if not specified otherwise per command-line argument while runing capture.py.

Roadmap

Currently, there are no new features in planning. This could change though, so feel free to check back again.

You can also always take a look at the open issues for a list of proposed features (and known issues).

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Darius Torabian

Project Link: https://github.com/dariustorabian/image-classifier

Acknowledgements

  • Netron - Great tool to visualize NN-architectures

  • OpenSansEmoji - Great font that is capable of displaying Emoji symbols.

About

Utilizing a Convolutional-Neural-Network to perform image classification on fruits.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published