{"id":13480907,"url":"https://github.com/androidthings/sample-tensorflow-imageclassifier","last_synced_at":"2025-03-27T11:31:09.377Z","repository":{"id":97075482,"uuid":"81471487","full_name":"androidthings/sample-tensorflow-imageclassifier","owner":"androidthings","description":"Classify camera images locally using TensorFlow models","archived":false,"fork":false,"pushed_at":"2021-05-26T17:55:37.000Z","size":32075,"stargazers_count":622,"open_issues_count":10,"forks_count":186,"subscribers_count":48,"default_branch":"master","last_synced_at":"2024-10-30T14:42:45.171Z","etag":null,"topics":["android-things","tensorflow"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/androidthings.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS"}},"created_at":"2017-02-09T16:40:34.000Z","updated_at":"2024-10-02T20:08:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"3e45f805-e54f-4aaf-908c-3dfb1bbd081b","html_url":"https://github.com/androidthings/sample-tensorflow-imageclassifier","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/androidthings%2Fsample-tensorflow-imageclassifier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/androidthings%2Fsample-tensorflow-imageclassifier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/androidthings%2Fsample-tensorflow-imageclassifier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/androidthings%2Fsample-tensorflow-imageclassifier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/androidthings","download_url":"https://codeload.github.com/androidthings/sample-tensorflow-imageclassifier/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245836059,"owners_count":20680310,"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-things","tensorflow"],"created_at":"2024-07-31T17:00:46.450Z","updated_at":"2025-03-27T11:31:08.660Z","avatar_url":"https://github.com/androidthings.png","language":"Java","readme":"# TensorFlow Lite IoT Image Classifier\n\nThis sample demonstrates how to run TensorFlow Lite inference on Android Things.\nPush a button to capture an image with the camera, and TensorFlow Lite will tell\nyou what it is!\nFollow the [Image Classifier Codelab](https://codelabs.developers.google.com/codelabs/androidthings-classifier)\nstep-by-step instructions on how to build a similar sample.\n\n\u003e **Note:** The Android Things Console will be turned down for non-commercial\n\u003e use on January 5, 2022. For more details, see the\n\u003e [FAQ page](https://developer.android.com/things/faq).\n\n## Introduction\n\nWhen a button is pushed or when the touchscreen is touched, the current image is captured from the\ncamera. The image is then converted and piped into a TensorFlow Lite classifier model that\nidentifies what is in the image. Up to three results with the highest confidence returned by the\nclassifier are shown on the screen, if there is an attached display. Also, the result is spoken out\nloud using Text-To-Speech to the default audio output.\n\nThis project is based on the\n[TensorFlow Android Camera Demo TF_Classify app](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/android/)\nand was adapted to use [TensorFlow Lite](https://www.tensorflow.org/mobile/tflite/), a lightweight version of TensorFlow targeted at mobile\ndevices. The TensorFlow classifier model is\n[MobileNet\\_v1](https://github.com/tensorflow/models/blob/master/research/slim/nets/mobilenet_v1.md)\npre-trained on the [ImageNet ILSVRC2012](http://www.image-net.org/challenges/LSVRC/2012/) dataset.\n\nThis sample uses the [TensorFlow Lite inference library](https://bintray.com/google/tensorflow/tensorflow-lite)\nand does not require any native build tools. You can add the TensorFlow Lite inference library to\nyour project by adding a dependency in your `build.gradle`, for example:\n```\ndependencies {\n    compile 'org.tensorflow:tensorflow-lite:0.1.1'\n}\n```\n\nNote: this sample requires a camera. Find an appropriate board in the\n[documentation](https://developer.android.com/things/hardware/developer-kits.html).\n\n## Screenshots\n\n![TensorFlow Lite image classifier sample demo][demo-gif]\n\n[(Watch the demo on YouTube)][demo-yt]\n\n## Pre-requisites\n\n- Android Things compatible board and an attached camera\n- Android Studio 2.2+\n- The following **optional** components:\n    - one button and one resistor for triggering the camera\n    - one LED and one resistor for the \"ready\" indicator\n    - speaker or headphones for Text-To-Speech results\n    - touchscreen or display for showing results\n\n## Schematics\n\n![Schematics](rpi3_schematics_tf.png)\n\n## Run on Android Things Starter Kit\n\nIf you have an Android Things Starter Kit, you can easily run this sample on your i.MX7D development board from the [Android Things Toolkit](https://play.google.com/store/apps/details?id=com.google.android.things.companion\u0026hl=en) app.\n\nTo run the sample on your i.MX7D development board:\n  1. Set up your device using Toolkit\n  2. Navigate to the Apps tab\n  3. Select Run next to the Image Classifier sample.\n  4. Press the \"A\" button on your Rainbow HAT or tap on the display to take a photo.\n\n![Running Image Classifier Sample on Toolkit][toolkit-jpg]\n\n## Build and Install\n\nOn Android Studio, click on the \"Run\" button.\nIf you prefer to run on the command line, type\n```bash\n./gradlew installDebug\nadb shell am start com.example.androidthings.imageclassifier/.ImageClassifierActivity\n```\n\nIf you have everything set up correctly:\n\n1. Wait until the LED turns on\n1. Point the camera to something like a dog, cat or a furniture\n1. Push the button to take a picture\n1. The LED should go off while running. In a Raspberry Pi 3, it takes about 500 millisecond to\n   capture the picture and run it through TensorFlow, and some extra time to speak the results\n   through Text-To-Speech\n1. Inference results will show in logcat and, if there is a display connected,\n   both the image and the results will be shown\n1. If a speaker or headphones are connected, the results will be spoken via\n   text to speech\n\n## Enable auto-launch behavior\n\nThis sample app is currently configured to launch only when deployed from your\ndevelopment machine. To enable the main activity to launch automatically on boot,\nadd the following `intent-filter` to the app's manifest file:\n\n```xml\n\u003cactivity ...\u003e\n\n   \u003cintent-filter\u003e\n       \u003caction android:name=\"android.intent.action.MAIN\"/\u003e\n       \u003ccategory android:name=\"android.intent.category.HOME\"/\u003e\n       \u003ccategory android:name=\"android.intent.category.DEFAULT\"/\u003e\n   \u003c/intent-filter\u003e\n\n\u003c/activity\u003e\n```\n\n## License\n\nCopyright 2018 The Android Things Samples Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n  http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\nWARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the\nLicense for the specific language governing permissions and limitations under\nthe License.\n\n[demo-yt]: https://www.youtube.com/watch?v=8kxYlI9R2xo\u0026list=PLWz5rJ2EKKc-GjpNkFe9q3DhE2voJscDT\u0026index=11\n[demo-gif]: demo1.gif\n[toolkit-jpg]: toolkit_tensorflowsample.jpg\n\n","funding_links":[],"categories":["Useful links"],"sub_categories":["Sample apps and libraries"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandroidthings%2Fsample-tensorflow-imageclassifier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandroidthings%2Fsample-tensorflow-imageclassifier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandroidthings%2Fsample-tensorflow-imageclassifier/lists"}