Skip to content

ertugruldmr/MNIST_ImageClassifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MNIST Image Classification

Table Of Content

Brief

Project

  • This is a classification project that uses the MNIST dataset to classify the images.
  • The goal is build a deep learning image classification model that accurately classifying the images based on the features.
  • The performance of the model is evaluated using several metrics loss and accuracy metrics.

Overview

  • This project involves building a deep learning model to classfy the images. The dataset contains 70.000 (28,28,1) images with 10 class which includes from 0 to 9 numbers. 60.000 train and 10.000 test. The models selected according to model tuning results, the progress optimized respectively the previous tune results. The project uses Python and several popular libraries such as Pandas, NumPy, tensorflow.

Demo

  • Description
    • classify the images .
    • Usage: Set the feature values through sliding the radio buttons then use the button to predict.
  • Embedded Demo window from HuggingFace Space
<iframe src="https://ertugruldemir-mnist-imageclassifier.hf.space" frameborder="0" width="850" height="450" ></iframe>

Data

  • The Black Friday Dataset from kaggle platform.
  • The dataset contains 70.000 images (28,28,1) images with 10 class which includes from 0 to 9 numbers.
  • The dataset contains the following features:
Data Info
Stats

tfds.core.DatasetInfo( name='mnist', full_name='mnist/3.0.1', description=""" The MNIST database of handwritten digits. """, homepage='http://yann.lecun.com/exdb/mnist/', data_path='/root/tensorflow_datasets/mnist/3.0.1', file_format=tfrecord, download_size=11.06 MiB, dataset_size=21.00 MiB, features=FeaturesDict({ 'image': Image(shape=(28, 28, 1), dtype=uint8), 'label': ClassLabel(shape=(), dtype=int64, num_classes=10), }), supervised_keys=('image', 'label'), disable_shuffling=False, splits={ 'test': , 'train': , }, citation="""@article{lecun2010mnist, title={MNIST handwritten digit database}, author={LeCun, Yann and Cortes, Corinna and Burges, CJ}, journal={ATT Labs [Online]. Available: http://yann.lecun.com/exdb/mnist}, volume={2}, year={2010} }""", )

Problem, Goal and Solving approach

  • This is a Image classification problem that uses the MNIST dataset to classfy the number images into 0-10 numbers.
  • The goal is to build a model that accurately classfy the number images into 0-10 numbers.
  • Solving approach is that using the supervised deep learning models.

Study

The project aimed predict the house prices using the features. The study includes following chapters.

  • (A) Dependencies: Installations and imports of the libraries.
  • (B) Dataset: Downloading and loading the dataset. Preparing the dataset via tensorflow dataset api. Configurating the dataset performance and related pre-processes.
  • (C) Modelling: It includes .
    • Basic Modelling
      • Custom Fully Connected Deep learning models as classifier.
    • Transfer Learning
      • Adapting the state of art models into current dataset.
    • Fine-Tuning
      • Setting the hyperparams and inner params of selected layers from state of art models.
    • Model Saving
      • Saving the model architecture with weights.
  • (D) Deployment as web demo app: Creating Gradio Web app to Demostrate the project.Then Serving the demo via huggingface as live.

results

  • The final model is Custom Classifier Network because of the results and less complexity.
model loss accuracy
Custom Classifier 0.03269 0.9904

Details

Abstract

  • MNIST dataset is used to classify the number images into 0-10 number. The dataset has 70.000 records. The problem is supervised learning task as image classification. The goal is classifying the number images into number classes using through supervised custom deep learning algorithms with transfer learning and fine-tuning approachs.The study includes creating the environment, getting the data, preprocessing the data, exploring the data, modelling the data, saving the results, deployment as demo app. Training phase of the models implemented through tensorflow callbacks. Model selection processes implemented through transfer learning and fine-tuning approachs . Selected the basic and more succesful model. Tuned Custom Classifier Network model has 0.03269 loss , 0.9904 acc, other metrics are also found the results section. Created a demo at the demo app section and served on huggingface space.

File Structures

  • File Structure Tree
├── demo_app
│   ├── app.py
│   ├── BasicModel
│   │   ├── assets
│   │   ├── fingerprint.pb
│   │   ├── keras_metadata.pb
│   │   ├── saved_model.pb
│   │   └── variables
│   │       ├── variables.data-00000-of-00001
│   │       └── variables.index
│   └── sample_images
├── docs
│   └── images
├── env
│   ├── env_installation.md
│   └── requirements.txt
├── LICENSE
├── readme.md
├── requirements.txt
└── study.ipynb
  • Description of the files
    • demo_app/
      • Includes the demo web app files, it has the all the requirements in the folder so it can serve on anywhere.
    • demo_app/component_configs.json :
      • It includes the web components to generate web page.
    • demo_app/BasicModel:
      • The trained custom fully connected neural network model.
    • demo_app/requirements.txt
      • It includes the dependencies of the demo_app.
    • docs/
      • Includes the documents about results and presentations
    • env/
      • It includes the training environmet related files. these are required when you run the study.ipynb file.
    • LICENSE.txt
      • It is the pure apache 2.0 licence. It isn't edited.
    • readme.md
      • It includes all the explanations about the project
    • study.ipynb
      • It is all the studies about solving the problem which reason of the dataset existance.

Explanation of the Study

(A) Dependencies:

  • The libraries which already installed on the environment are enough. You can create an environment via env/requirements.txt. Create a virtual environment then use hte following code. It is enough to satisfy the requirements for runing the study.ipynb which training pipeline.
  • Dataset can download from tensoflow.

(B) Dataset:

  • Downloading the MNIST dataset via tensorflow dataset api.
  • The dataset has 70.000 iamges with 10 class which includes from 0 to 9 numbers.
  • Preparing the dataset via resizing, scaling into 0-1 value range and etc image preprocessing processes.
  • Creating the tensorflow dataset object then configurating.
  • Example Dataset
  • Data Augmentation

(C) Modelling:

  • The processes are below:
    • Basic Modelling
    • Transfer Learning
      • Implementing the state of art models into dataset.
    • Fine-Tuning
      • Model Tuning the selected model through hyperparams and inner params.
    • Saving the project and demo studies.
    • trained model BasicModel.sav as pickle format.

(D) Deployment as web demo app:

  • Creating Gradio Web app to Demostrate the project.Then Serving the demo via huggingface as live.
  • Desciption
    • Project goal is classifiying the images into numbers.
    • Usage: upload or selec the image for classfying then use the button to predict.
  • Demo
    • The demo app in the demo_app folder as an individual project. All the requirements and dependencies are in there. You can run it anywhere if you install the requirements.txt.
    • You can find the live demo as huggingface space in this demo link as full web page or you can also us the embedded demo widget in this document.

License

  • This project is licensed under the Apache 2.0 License. See the LICENSE file for details.

Connection Links

About

Image Classification task. MNIST image classification portfolio project

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors