{"id":19519237,"url":"https://github.com/nex3z/tflite-mnist-android","last_synced_at":"2025-05-08T21:25:53.745Z","repository":{"id":80408863,"uuid":"124550747","full_name":"nex3z/tflite-mnist-android","owner":"nex3z","description":"MNIST with TensorFlow Lite on Android","archived":false,"fork":false,"pushed_at":"2020-09-16T13:54:08.000Z","size":668,"stargazers_count":227,"open_issues_count":0,"forks_count":69,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-02-02T03:54:44.953Z","etag":null,"topics":["android","mnist","tensorflow","tensorflow-lite"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nex3z.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-09T14:27:47.000Z","updated_at":"2024-12-13T18:13:29.000Z","dependencies_parsed_at":"2023-05-04T00:04:52.366Z","dependency_job_id":null,"html_url":"https://github.com/nex3z/tflite-mnist-android","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nex3z%2Ftflite-mnist-android","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nex3z%2Ftflite-mnist-android/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nex3z%2Ftflite-mnist-android/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nex3z%2Ftflite-mnist-android/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nex3z","download_url":"https://codeload.github.com/nex3z/tflite-mnist-android/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238044095,"owners_count":19407128,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","mnist","tensorflow","tensorflow-lite"],"created_at":"2024-11-11T00:17:05.070Z","updated_at":"2025-02-10T02:10:10.428Z","avatar_url":"https://github.com/nex3z.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MNIST with TensorFlow Lite on Android\n\n[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/nex3z/tflite-mnist-android/blob/master/model.ipynb)\n\nThis project demonstrates how to use [TensorFlow Lite](https://www.tensorflow.org/lite) on Android for handwritten digits classification from MNIST.\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"image/demo.gif\" heigit=\"500\"/\u003e\n\u003c/div\u003e\n\nPrebuilt APK can be downloaded from [here](https://github.com/nex3z/tflite-mnist-android/releases/download/v1.0.0/tflite-mnist.apk).\n\n\n## How to build from scratch\n\n### Environment\n\n- Python 3.7\n- tensorflow 2.3.0\n- tensorflow-datasets 3.2.1\n\n\n### Step 1. Train and convert the model to TensorFlow Lite FlatBuffer\n\nRun all the code cells in [model.ipynb](https://github.com/nex3z/tflite-mnist-android/blob/master/model.ipynb). \n\n- If you are running Jupyter Notebook locally, a `mnist.tflite` file will be saved to the project directory.\n- If you are running the notebook in [Google Colab](https://colab.research.google.com/), a `mnist.tflite` file will be downloaded.\n\n### Step 2. Build Android app\n\nCopy the `mnist.tflite` generated in Step 1 to `/android/app/src/main/assets`, then build and run the app. A prebuilt APK can be downloaded from [here](https://github.com/nex3z/tflite-mnist-android/releases/download/v1.0.0/tflite-mnist.apk).\n\nThe [Classifer](https://github.com/nex3z/tflite-mnist-android/blob/master/android/app/src/main/java/com/nex3z/tflite/mnist/classifier/Classifier.kt) reads the `mnist.tflite` from `assets` directory and loads it into an [Interpreter](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/java/src/main/java/org/tensorflow/lite/Interpreter.java) for inference. The Interpreter provides an interface between TensorFlow Lite model and Java code.\n\nIf you are building your own app, remember to add the following code to [build.gradle](https://github.com/nex3z/tflite-mnist-android/blob/master/android/app/build.gradle#L24) to prevent compression for model files.\n\n```\naaptOptions {\n    noCompress \"tflite\"\n    noCompress \"lite\"\n}\n```\n\n## Credits\n\n- The basic model architecture comes from [tensorflow-mnist-tutorial](https://github.com/GoogleCloudPlatform/tensorflow-without-a-phd/tree/master/tensorflow-mnist-tutorial).\n- The official TensorFlow Lite [examples](https://github.com/tensorflow/examples/tree/master/lite/examples).\n- The [FingerPaint](https://android.googlesource.com/platform/development/+/master/samples/ApiDemos/src/com/example/android/apis/graphics/FingerPaint.java) from Android API demo.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnex3z%2Ftflite-mnist-android","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnex3z%2Ftflite-mnist-android","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnex3z%2Ftflite-mnist-android/lists"}