TensorFlow Lite text classification sample
This is an end-to-end example of movie review sentiment classification built with TensorFlow 2.0 (Keras API), and trained on IMDB dataset. The demo app processes input movie review texts, and classifies its sentiment into negative (0) or positive (1).
These instructions walk you through the steps to train and test a simple text classification model, export them to TensorFlow Lite format and deploy on a mobile app.
See Text Classification with Movie Reviews for a step-by-step instruction of building a simple text classification model.
Follow the steps below to build and run the sample Android app.
Android Studio 3.2 or later. Install instructions can be found on Android Studio website.
An Android device or an Android emulator and with API level higher than 21.
Open Android Studio, and from the Welcome screen, select Open an existing Android Studio project.
From the Open File or Project window that appears, navigate to and select the text_classification/android directory from wherever you cloned the TensorFlow Lite sample GitHub repo.
You may also need to install various platforms and tools according to error messages.
If it asks you to use Instant Run, click Proceed Without Instant Run.
You need to have an Android device plugged in with developer options enabled at this point. See here for more details on setting up developer devices.
If you already have an Android emulator installed in Android Studio, select a virtual device with API level higher than 15.
Click Run to run the demo app on your Android device.
For gradle CLI, running ./gradlew build can create APKs for both solutions under app/build/outputs/apk.