Code Monkey home page Code Monkey logo

binary-image-classifier's Introduction

binary-image-classifier

Data

Data for training the binary classifier is stored in:

./data/train

There are two numpy files named class_a.npy and class_b.npy. These numpy arrays store image data to train the classifier.

Visualization

As data is in the numpy array we need a simple script to visualize it. To see images in each numpy array run the script

./src/Visualize.py

Sample images from each array are shown below:

Class A Class B Test Image

Dependencies

This code is implemented in Keras using Tensorflow API r1.0 backend. You can follow the online instructions to install Tensorflow 1.0. Other dependencies like numpy, scikit-image and matplotlib can be installed by pip.


Training

Model can be trained right off the bat using ./src/Train.py . Labels are manually encoded using a small script. After training the model is saved in the ./model directory and the variable is deleted. Special evaluation metrics are used while training the model for better optimization. They are explained as follows:

  • Matthews Correlation: Matthews_correlation is often regarded as the best measure for binary classification as latest versions of keras removed this useful metrics, I have written a version following source code of previous versions of keras A value close to 1 is often regarded as best.

  • F1 Score: F1 score is often a good measure to gauge a model performance The function below calculates precision and recall and then calculates F1 score using the formula mentioned in the return method

Model is compiled on Catergorical Crossentropy and Adam optimizer.


Prediction

Saved model can be used for prediction purpose. To predict labels for all images in field.npy run the script:

./src/To_predict.py

Predicted labels are saved in Labels_predicted_by_trained_model.csv

Results

Results are shown below:

binary-image-classifier's People

Contributors

sameerkmarathe avatar frompingutoboo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.