This portal has been archived. Explore the next generation of this technology.

Image classification • MLPerf inference • TFLite CPU • Mobilenets • Linux • Android • webcam

solution:demo-image-classification-tflite-cpu-mobilenets-linux-android (v1.6.0)

Portable solution description  

Install and run this solution on your platform in several simple steps. Our goal is to make it simpler to reproduce results from research papers, participate in crowd-benchmarking, and enable "live" papers.
Don't hesitate to get in touch if you encounter any issues or would like to discuss this community project!

Check the prerequisites for your system  

Install manually from the command line (to be automated in the future):
Sources:
* https://github.com/mlperf/inference/tree/master/v0.5/classification_and_detection/optional_harness_ck/classification

This CK solution demo was prepared by Grigori Fursin and Hervé Guillou.

Requred Ubuntu packages:

 sudo apt update
 sudo apt install git wget libz-dev curl cmake
 sudo apt install gcc g++ autoconf autogen libtool

 Android SDK and NDK:
  sudo apt install android-sdk
  sudo apt install google-android-ndk-installer

 We tested the solution with Android NDK GCC though LLVM should work too ...

========================
The tricky part if you use Windows with Ubuntu virtual machine (we plan to automate in the future).
You need to first connect your Android device via adb on Windows and then use adb in Linux to connect to Windows adb server.
In such case you need to make sure that both adb version are the same!

For example, you can test adb version on Windows as follows:
 C:> adb version
 Android Debug Bridge version version 1.0.41

Then on Linux:
 adb version

 Android Debug Bridge version 1.0.39

Since versions are different, we should install correct adb version on Linux into the Python environment of this solution:

  wget https://dl.google.com/android/repository/platform-tools_r29.0.3-linux.zip
  unzip platform-tools_r29.0.3-linux.zip
  cd platform-tools
  mv * ../venv/bin
  cd ..

Now check that adb version is correct:
  which adb

  adb version

 > Android Debug Bridge version 1.0.41
 > Version 29.0.3-5806383

 If you don't see devices, kill the adb server in Linux:

  adb kill-server

 Start it in Windows
 C:> adb start-server

 And then check devices:

  adb devices
========================

 Finally, add adb to the CK env:
 $ ck detect soft:tool.adb --full_path=$PWD/venv/bin/adb

Install cBench (docs)

Install cBench from the command line (a small Python library to manage CK solutions):
pip3 install cbench
 or 
python3 -m pip install cbench
 or
pip install cbench 
Note that you may need to add the --user flag if you install in your user space, i.e. "python3 -m pip install cbench --user"

Init this solution with the portable workflow on your machine

Run manually from your command line (cBench will attempt to automatically adapt this workflow to your system - you may need to press Enter several times to select default answers for some questions):
cb init demo-image-classification-tflite-cpu-mobilenets-linux-android

Start cBench (status: disconnected)

cb start

Run this workflow locally

or start local run manually from the command line:
cb run demo-image-classification-tflite-cpu-mobilenets-linux-android

  # Note that the following CK program pipeline will be executed:
  ck compile program:image-classification-tflite-codereef-android --cmd_key=default --speed
  ck run program:image-classification-tflite-codereef-android --cmd_key=default

Live test of this workflow via your browser

Successfully tested configuration

Host OS: linux-64 (Ubuntu 18.04.3 LTS)
Target OS: android23-arm64 (Android 9)
Target machine: SAMSUNG SM-G950F
Target CPUs:
Python version for virtual env: 3.6.8

Dependencies    

Reused CK components

These components are automatically installed by cBench from this portal:
pip install numpy
pip install opencv-python

ck pull repo:ck-mlperf

ck install package --tags=lib,python-package,numpy
ck install package --tags=lib,python-package,cv2

ck install package:imagenet-2012-val-min
ck install package:imagenet-2012-aux
ck install package:lib-rtl-xopenme

ck install package:dataset-imagenet-preprocessed-using-opencv

ck install package --tags=lib,tflite,v1.13.1,vsrc --target_os=android23-arm64

ck install package:model-tf-mlperf-mobilenet-quantized

ck compile program:image-classification-tflite-codereef-android --speed --target_os=android23-arm64

Comments  

Please log in to add your comments!
If you notice any inapropriate content that should not be here, please report us as soon as possible and we will try to remove it within 48 hours!