TensorFlow Lite for Android (Coding TensorFlow)
Key Takeaways
The video demonstrates how to use TensorFlow Lite to deploy a trained model on an Android app, allowing for low-latency inference on mobile devices. It covers the basics of TensorFlow Lite, including its support for Android and iOS, and how to use the Java wrapper for Android devices.
Full Transcript
[Applause] hi and welcome to coding tensorflow where you'll learn all about coding machine learning and AI apps using tensorflow I'm Laurence Moroney a developer advocate for tensorflow and today I'll be looking at tensorflow Lite and getting it to run models on Android tensorflow light is tensor flows lightweight solution for mobile and embedded devices and lets you run machine learn models on mobile devices with low latency quickly so you can take advantage of them to do classification regression or anything else you might want to do without necessarily incurring a round trip to a server it's presently supported on Android and iOS via a C++ API as well as a Java wrapper for Android devices on devices that support it the interpreter can also use the Android neural networks API for hardware acceleration otherwise it will default to using the CPU here you can see me running the app on my Android device and using it to classify a number of objects it's quite fun to play with and note how the interpretation of a mouse changes as I move the camera around or the first mug has a high handle which kind of makes it look like a picture so that shows up as a possibility finally my Google mug is broad and looks a bit like a mixing bowl and the app detects that so how does all of this work well let's first talk about the model the app is built using a mobile net model mobile nets are small low latency low-power models that are designed to meet a number of use cases such as object detection face attributes fine grained classification and landmark recognition what's nice about them is that there are a number of different ones that are pre-trained including the model at this link which works for image classification that is compatible with tensorflow lite download that file and you learn zip it to see two files a dot TF Lite file describing the model and a labels file describing the labels that the model is trained for as you can see because your model is already in the TF Lite format it's ready to be run on tensorflow lite so let's take a look at the api's for that in fact i would recommend that you stick with built models for the time being as tensorflow light is a Developer Preview it doesn't support all the operations of tensorflow yet and you might encounter some issues with unsupported ones when you're converting your model to the TF light format okay let's get down to looking at it on a mobile now first of all to use tensorflow light in your android app you need to include the tensorflow light libraries you do this by editing your build up Gradle file to include them once you've done that in synced you'll be able to import a tensorflow interpreter an interpreter loads a model and allows you to run it by providing it with a set of inputs tensorflow light will then execute the model and write the outputs it's really as simple as that of course you have to load the model and the API makes that very straightforward now a good place to store your model is in your app assets the code will then read the model directly from there it doesn't have to be there of course you can load a model from just about anywhere but make sure you get your powers right once you've done that you can instantiate an interpreter and in this case I called it tensorflow light and loaded the model into it let's look at the app again now what's going on here is that it's reading frames from the camera and turning those into images it then uses those images as an input to the model which in turn outputs values these values are an index to the appropriate label and the value for that label the probability that the image matches that label will pick the top three and will write them to the user interface let's take a look at the code first you can see is the input we're getting the image data which is received from the camera as a bitmap we convert that bitmap into a byte buffer which the model can read this buffer is called IMG data remember that we'll come back to it in a moment when you downloaded the model you also had a TF Lite file and a txt file containing labels these labels are a list of all of the objects that the model can recognize here's the first view so for example labeled zero is background label two is goldfish and so on remember the image data from a moment ago well we'll load into our tensorflow light interpreter and we'll get an output called label proper ray it's probably easiest if we look at that in the debugger so here you can see I had a breakpoint on looking at a picture of my mug as you can see the top elements unless the goldfish etc have very very low probability indeed it's like 1.7 nine times 10 to the minus 5 but when you scroll through the output lists you'll see for example that label 505 has a relatively high priority and number 505 corresponds to coffee cup which as you'll remember from the video that's what I was looking at if you want to try an app for yourself that does all of this you can get it on github at this link and that's a starter intensive flow light for Android this exciting technology will let you load all your models onto an Android device taking advantage of onboard hardware and allow you to execute them I showed an example using image recognition in a video stream but of course you're not limited to that at the moment tensorflow light is in Developer Preview so you may encounter some restrictions in operations that are supported but we're updating it all the time finally if you want to learn more including how to retrain the model I showed in this video to tailor it for specific scenarios check out the tensor flow for poet code labs on the Google developer site I can't wait to see what you build on mobile with tensorflow Lite and don't forget to hit that subscribe button for more great coding with tensorflow videos Cheers don't forget to click the subscribe button for more great videos like these what's
Original Description
In this episode of Coding TensorFlow, Laurence Moroney, Developer Advocate for TensorFlow at Google, talks us through how TensorFlow Lite works on Android. You'll see how to deploy a trained model to an Android App, and how you can run inference with it in Java.
“Building TensorFlow on Android” article → https://goo.gl/B8SV2d
TensorFlow Lite Demo for Android → https://goo.gl/nWAipo
Subscribe to the channel to catch new episodes of Coding TensorFlow → https://goo.gl/ht3WGe
Watch more Coding TensorFlow episodes here → https://goo.gl/cezxSW
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from TensorFlow · TensorFlow · 32 of 60
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
▶
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
The TensorFlow YouTube Channel is Here!
TensorFlow
Answering Your TF Questions #AskTensorFlow
TensorFlow
Chatting With the TensorFlow Community (TensorFlow Meets)
TensorFlow
All About TensorFlow Code (Coding TensorFlow)
TensorFlow
TensorFlow: an ML platform for solving impactful and challenging problems
TensorFlow
Keynote (TensorFlow Dev Summit 2018)
TensorFlow
tf.data: Fast, flexible, and easy-to-use input pipelines (TensorFlow Dev Summit 2018)
TensorFlow
Eager Execution (TensorFlow Dev Summit 2018)
TensorFlow
Machine Learning in JavaScript (TensorFlow Dev Summit 2018)
TensorFlow
Training Performance: A user’s guide to converge faster (TensorFlow Dev Summit 2018)
TensorFlow
The Practitioner's Guide with TF High Level APIs (TensorFlow Dev Summit 2018)
TensorFlow
Distributed TensorFlow (TensorFlow Dev Summit 2018)
TensorFlow
Debugging TensorFlow with TensorBoard plugins (TensorFlow Dev Summit 2018)
TensorFlow
TensorFlow Lite (TensorFlow Dev Summit 2018)
TensorFlow
Searching Over Ideas (TensorFlow Dev Summit 2018)
TensorFlow
Reconstructing Fusion Plasmas (TensorFlow Dev Summit 2018)
TensorFlow
Nucleus: TensorFlow toolkit for Genomics (TensorFlow Dev Summit 2018)
TensorFlow
Open Source Collaboration (TensorFlow Dev Summit 2018)
TensorFlow
Swift for TensorFlow - TFiwS (TensorFlow Dev Summit 2018)
TensorFlow
TensorFlow Hub (TensorFlow Dev Summit 2018)
TensorFlow
Applied AI at The Coca-Cola Company (TensorFlow Dev Summit 2018)
TensorFlow
Real-World Robot Learning (TensorFlow Dev Summit 2018)
TensorFlow
TensorFlow Extended (TFX) (TensorFlow Dev Summit 2018)
TensorFlow
Project Magenta (TensorFlow Dev Summit 2018)
TensorFlow
TensorFlow Dev Summit 2018 - Livestream
TensorFlow
Introducing TensorFlow Lite (Coding TensorFlow)
TensorFlow
TensorFlow Dev Summit 2018 Highlights
TensorFlow
Jeff Dean, Head of AI at Google discusses the impact of ML (TensorFlow Meets)
TensorFlow
TensorFlow Mobile vs. TF Lite and More! #AskTensorFlow
TensorFlow
Using TensorFlow to enable research & production across many fields (TensorFlow Meets)
TensorFlow
Teaching TensorFlow for Deep Learning at Stanford University (TensorFlow Meets)
TensorFlow
TensorFlow Lite for Android (Coding TensorFlow)
TensorFlow
Using the tf.data API to build input pipelines (TensorFlow Meets)
TensorFlow
Training Models in the Cloud & the Benefits of AI Toolkits #AskTensorFlow
TensorFlow
Execute operations immediately with TensorFlow's Eager Execution (TensorFlow Meets)
TensorFlow
TensorFlow Lite for iOS (Coding TensorFlow)
TensorFlow
Get started with TensorFlow's High-Level APIs (Google I/O '18)
TensorFlow
TensorFlow for JavaScript (Google I/O '18)
TensorFlow
TensorFlow in production: TF Extended, TF Hub, and TF Serving (Google I/O '18)
TensorFlow
Get started with TensorFlow's High-Level APIs in 5 mins | Google I/O 2018
TensorFlow
TensorFlow and deep reinforcement learning, without a PhD (Google I/O '18)
TensorFlow
TensorFlow Lite for mobile developers (Google I/O '18)
TensorFlow
Advances in machine learning and TensorFlow (Google I/O '18)
TensorFlow
Distributed TensorFlow training (Google I/O '18)
TensorFlow
Classification using neural networks & ML regression models #AskTensorFlow
TensorFlow
TensorFlow and Keras in R - Josh Gordon meets with J.J. Allaire (TensorFlow Meets)
TensorFlow
Focus on your experiment with TensorFlow Estimators (TensorFlow Meets)
TensorFlow
How to get started with AI/ML, retraining models, & more! #AskTensorFlow
TensorFlow
TensorFlow - the deep learning solution for mobile platforms (TensorFlow Meets)
TensorFlow
MiniGo: TensorFlow Meets Andrew Jackson (TensorFlow Meets)
TensorFlow
The growth of TensorFlow with added support for JS & Swift (TensorFlow Meets)
TensorFlow
At the intersection of TensorFlow & nuclear physics (TensorFlow Meets)
TensorFlow
NVidia TensorRT: high-performance deep learning inference accelerator (TensorFlow Meets)
TensorFlow
Try TensorFlow.js in your browser (Coding TensorFlow)
TensorFlow
TensorFlow Hub: reusing machine learning modules (TensorFlow Meets)
TensorFlow
How to use TensorFlow in PyCharm (TensorFlow Tip of the Week)
TensorFlow
Training models faster with TensorFlow Hub (TensorFlow Meets)
TensorFlow
Prepare your dataset for machine learning (Coding TensorFlow)
TensorFlow
Using ML to predict insulin use for Type 1 Diabetes (TensorFlow Meets)
TensorFlow
TFX: an end-to-end machine learning platform for TensorFlow (TensorFlow Meets)
TensorFlow
More on: AI Systems Design
View skill →
🎓
Tutor Explanation
DeepCamp AI