Machine-Learning-App

View on GitHub

SGPA Sem - 5 Project

A Flutter application in which user can know What is Machine Learning, How Models are Train and Deployment of these Trained Models.

Abstract

Building a machine Learning model is an easy task nowadays as most algorithms are available and by using these Algorithm we can implement Models. The main task is to known how we can deploy the model in Application. So by using tensorflow tflite model I have deploy Some basic ML models in a single Android Application.

Introduction a

Only a small fraction of real-world ML systems is composed of the ML code, as shown by the small black box in the middle (see diagram below). The required surrounding infrastructure is vast and complex. Machine Learning Systems

Useful Courses books

I have enrolled in some coursera courses but these courses help me a lot for building this application

Differnet Models to Train and Delop them in single Application (Custom Based - offline)

Project Flow flow

Dataset Collection memo

Training - Testing man_technologist

Converting film_strip

# Converting a SavedModel to a TensorFlow Lite model.
converter = tf.lite.TFLiteConverter.from_saved_model(saved_model_dir)
tflite_model = converter.convert()
# Converting a tf.Keras model to a TensorFlow Lite model.
converter = tf.lite.TFLiteConverter.from_keras_model(model)
tflite_model = converter.convert()
# Converting ConcreteFunctions to a TensorFlow Lite model.
converter = tf.lite.TFLiteConverter.from_concrete_functions([func])
tflite_model = converter.convert()

Deployment cyclone

Add tflite package in pubspec.yaml

dependencies:
  tflite: ^1.1.1

Every tensorflow (tflite) model gives 3 different output that are

  1. index
  2. label
  3. confidence.

The dog and cat model and flower recognition model both are deployed by using tflite package function runModelOnImage()

var output = await Tflite.runModelOnImage(
      path: image.path,
      numResults: 2,
      threshold: 0.5,
      imageMean: 127.5,
      imageStd: 127.5,
    );

For MNIST model I have used canvas to create an image which will be resized to 28x28px that is the same size of image we used to train our model. Then will convert this image to list of Uint8 and run runModelOnBinary() method.

var output = await Tflite.runModelOnBinary(
      binary: imageToByteListFloat32(image, 224, 127.5, 127.5),// required
      numResults: 6,    // defaults to 5
      threshold: 0.05,  // defaults to 0.1
      asynch: true      // defaults to true
);

For Color Detection model I have used method runModelOnFrame() as this model is real-time based and image is changing every frame by frame.

var output = await Tflite.runModelOnFrame(
      bytesList: img.planes.map((plane) {return plane.bytes;}).toList(),// required
      imageHeight: img.height,
      imageWidth: img.width,
      imageMean: 127.5,   // defaults to 127.5
      imageStd: 127.5,    // defaults to 127.5
      rotation: 90,       // defaults to 90, Android only
      numResults: 2,      // defaults to 5
      threshold: 0.1,     // defaults to 0.1
      asynch: true        // defaults to true
);

Gif tada

Machine Learning App Gif