GithubHelp home page GithubHelp logo

potentiak / justadogidentificationservice Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 9.9 MB

ML + MobileApp = JaDIS

License: Apache License 2.0

Kotlin 70.14% Python 29.86%
android kotlin mobile-app stanford-dogs-dataset tensorflow tensorflow-lite classification convolutional-neural-networks machine-learning python

justadogidentificationservice's Introduction

Just a Dog Identification Service [JaDIS]

app logo

ML + MobileApp = JaDIS

This repo contains an implementation of a tensorflow model which is then compiled into tensorflow lite model and finally used on an android application to identify dog breeds

Preview

Here are some examples of the final project:

Some examples of the App

The dataset

For training the convolutional neural network I have used the Stanford Dogs Dataset which contains around 20k images of 120 different dog breeds.

all the breed on single image

Neural network model lupus_omni_die.py

For the final project I have only trained a model using transfer learning method. The reason why transfer learning was necessary in final implementation is because of the sheer diversity and size of the dataset, training a reliable network which would have acceptable accuracy would require quite a complex architecture which would take an extremely long time on the hardware I have at my disposal. The est accuracy I was able to achieve with standard models was near 30% mark and at that time training the network already took about 5 hours, at which point I have made the decision to try transfer learning which at the end was able to achieve 80% accuracy within only 4 hours of training*.

[*] as you can see on the training chart I could have easily acheived similar acc. within 5 epoch (about 1-hour of training), but I kept it going to see whether my model would achieve better acc. on validation data which wasn't the case.

Network architecture(s)

I have decided to use Densenet201[1][2] pretrained model on imagenet dataset as part of the final model which is used in the android APP. After densenet comes a densely connected layer of 4096 neurons with 50% dropout, at the end there is 120 softmax layer corresponding to every breed of the dataset

Training summary

training with transfer learning

As we can see by the examples above the transfer learning model was able to achieve about 80% accuracy after only 5 epochs and after them accuracy on the validation dataset did not increase substantially.

TFLite model summary

Lastly the model is compiled using TFLite compiler into a .tflite file which then is easily accessed by android app. The trained model loses some accuracy due to compression but is still nonetheless accurate as seen in all the previews

METADATA INFORMATION OF THE TFLITE MODEL

TFLite metadata

Android App Implementation JustADogIdentificationApp

The final part of the project is the android implementation which actively uses the trained and compiled model to classify a breed of dog currently in front of the device's camera. The app consists of one activity which implements CameraX for live image data which is displayed on preview and fed into the TFLite model which den return predictions which are displayed just below the preview window as a recycler view list. The app only diplays 10 most probable guesses. As of writing this project there was no internal method for easy conversion of image from Yuv to RGB hence I have used a method found on another repo as writing the app wasn't the main point of this project, only implementing a tensorflow trained model into an android app was.

app layout:

Conclusion

The following project demonstrated power of using pretrained NN for training a new model on dataset that is diversified and contains many classes. Transfer learning allowed to drastically shorten training time and allowed to achieve acceptable accuracy on validation data without huge computational power requirements. The project also works as a proof-of-concept of integrating machine learning models trained with tensorflow library into android application.

justadogidentificationservice's People

Contributors

ar621 avatar

Stargazers

 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.