Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
.cm
README.md
benchmark.h
classification.cpp
preprocess-next.py

README.md

TensorFlow Lite image classification program

This program uses a statically linked TensorFlow Lite library.

Prerequisites

SciPy

# apt install liblapack-dev libatlas-dev
# python -m pip install scipy

TensorFlow library

$ ck install package:lib-tflite-0.1.7-src-static [--target_os=android23-arm64]

NB: Use --target_os=android23-arm64 to build for Android API 23 (v6.0 "Marshmallow") or similar.

TensorFlow models

Install a model providing a graph as tflite file e.g.:

$ ck install package:tensorflowmodel-mobilenet-v1-1.0-224-2018_02_22-py
$ ck install package:tensorflowmodel-mobilenet-v2-1.0-224-py

ImageNet dataset

$ ck install package --tags=small_dataset,imagenet,raw,val
$ ck install package:imagenet-2012-aux 

Build

$ ck compile program:image-classification-tflite [--target_os=android23-arm64]

Run

$ ck run program:image-classification-tflite [--target_os=android23-arm64]

Program parameters

Input image parameters

CK_IMAGE_FILE

If set, the program will classify a single image instead of iterating over a dataset. When only the name of an image is specified, it is assumed that the image is in the ImageNet dataset.

$ ck run program:image-classification-tflite --env.CK_IMAGE_FILE=/tmp/images/path-to-image.jpg
$ ck run program:image-classification-tflite --env.CK_IMAGE_FILE=ILSVRC2012_val_00000011.JPEG

CK_RECREATE_CACHE

If set to YES, then all previously cached images will be erased.

Default: NO.

Input preprocessing parameters

CK_TMP_IMAGE_SIZE

The size of an intermediate image. If this preprocessing parameter is set to a value greater than the input image size defined by the model, input images will be first scaled to this size and then cropped to the input size.

For example, if --env.CK_TMP_IMAGE_SIZE=256 is specified for MobileNets models with the input image resolution of 224, then input images will be first resized to 256x256 and then cropped to 224x224.

Default: 0.

CK_CROP_PERCENT

The percentage of the central image region to crop. If this preprocessing parameter is set to a value between 0 and 100, then loaded images will be cropped according this percentage and then scaled to the input image size defined by the model.

Default: 87.5.

NB: If CK_TMP_IMAGE_SIZE is set and valid, this parameter is not used.

CK_SUBTRACT_MEAN

If set to YES, then the mean value will be subtracted from the input image.

Default: YES.

You can’t perform that action at this time.