Skip to content

Commit

Permalink
Merge pull request #19 from am15h/update_0.2.0
Browse files Browse the repository at this point in the history
Update 0.2.0
  • Loading branch information
am15h authored May 11, 2020
2 parents 560d450 + 0e23897 commit add359a
Show file tree
Hide file tree
Showing 10 changed files with 163 additions and 72 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/flutter_drive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
# environment.
matrix:
device:
- "iPhone 11 Pro Max (13.3)"
- "iPhone 11 Pro Max (13.4.1)"
# When set to true, GitHub cancels all in-progress jobs if any
# matrix job fails.
fail-fast: false
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.2.0
* Direct conversion support for more TfLiteTypes
* int16, float16, int8, int64
* Pre-built tf 2.2.0 stable binaries

## 0.1.3
* update usage instructions

Expand Down
Binary file added example/assets/test/int64.bin
Binary file not shown.
12 changes: 2 additions & 10 deletions example/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
cd "$(dirname "$(readlink -f "$0")")"

URL="https://github.com/am15h/tflite_flutter_plugin/releases/download/"
TAG="v0.1.0"
TAG="v0.2.0"

ANDROID_DIR="android/app/src/main/jniLibs/"
ANDROID_LIB="libtensorflowlite_c.so"
Expand All @@ -15,8 +15,6 @@ ARM_64="libtensorflowlite_c_arm64.so"
X86="libtensorflowlite_c_x86.so"
X86_64="libtensorflowlite_c_x86_64.so"

#IOS="https://github.com/am15h/tflite_flutter_plugin/releases/download/v0.1.0/TensorFlowLiteC.framework_fat.zip"

delegate=0

while getopts "d" OPTION
Expand Down Expand Up @@ -47,10 +45,4 @@ download ${ARM_64} "arm64-v8a"
fi

download ${X86} "x86"
download ${X86_64} "x86_64"

#ios
#wget "$IOS"
#unzip TensorFlowLiteC.framework_fat.zip
#rm TensorFlowLiteC.framework_fat.zip
#mv TensorFlowLiteC.framework ios/
download ${X86_64} "x86_64"
47 changes: 34 additions & 13 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ packages:
name: _fe_analyzer_shared
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.3"
version: "2.2.0"
analyzer:
dependency: transitive
description:
name: analyzer
url: "https://pub.dartlang.org"
source: hosted
version: "0.39.4"
version: "0.39.7"
archive:
dependency: transitive
description:
Expand Down Expand Up @@ -70,7 +70,7 @@ packages:
name: coverage
url: "https://pub.dartlang.org"
source: hosted
version: "0.13.6"
version: "0.13.9"
crypto:
dependency: transitive
description:
Expand Down Expand Up @@ -98,7 +98,7 @@ packages:
name: e2e
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.4+2"
version: "0.4.0"
ffi:
dependency: transitive
description:
Expand Down Expand Up @@ -167,7 +167,7 @@ packages:
name: http_parser
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.3"
version: "3.1.4"
image:
dependency: transitive
description:
Expand All @@ -188,7 +188,7 @@ packages:
name: io
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.3"
version: "0.3.4"
js:
dependency: transitive
description:
Expand Down Expand Up @@ -265,7 +265,7 @@ packages:
name: package_config
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.9.3"
package_resolver:
dependency: transitive
description:
Expand All @@ -286,7 +286,21 @@ packages:
name: path_provider
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.1"
version: "1.6.5"
path_provider_macos:
dependency: transitive
description:
name: path_provider_macos
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.4"
path_provider_platform_interface:
dependency: transitive
description:
name: path_provider_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
pedantic:
dependency: transitive
description:
Expand All @@ -308,6 +322,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.1"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
pool:
dependency: transitive
description:
Expand Down Expand Up @@ -439,13 +460,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.15"
tflite_flutter_plugin:
dependency: "direct dev"
tflite_flutter:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
version: "0.0.1"
version: "0.1.3"
typed_data:
dependency: transitive
description:
Expand Down Expand Up @@ -480,7 +501,7 @@ packages:
name: watcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.7+13"
version: "0.9.7+14"
web_socket_channel:
dependency: transitive
description:
Expand All @@ -503,5 +524,5 @@ packages:
source: hosted
version: "2.2.0"
sdks:
dart: ">=2.6.0 <3.0.0"
dart: ">=2.7.0 <3.0.0"
flutter: ">=1.10.0 <2.0.0"
5 changes: 3 additions & 2 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ dependencies:
flutter:
sdk: flutter

tflite_flutter: ^0.1.2
tflite_flutter:
path: ../
path_provider:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
Expand All @@ -20,8 +21,8 @@ dev_dependencies:
sdk: flutter
flutter_driver:
sdk: flutter
e2e:
test:
e2e: ^0.2.4+2

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
Expand Down
81 changes: 47 additions & 34 deletions example/test/tflite_flutter_plugin_example_e2e.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ final missingFileName = 'missing.tflite';
final badFileName = 'bad_model.tflite';
final quantFileName = 'mobilenet_quant.tflite';
final intFileName = 'int32.bin';
final int64FileName = 'int64.bin';
final multiInputFileName = 'multi_add.bin';
final addFileName = 'add.bin';

Expand Down Expand Up @@ -184,18 +185,21 @@ void main() {
});
});

group('quantization', () {
tfl.Interpreter interpreter;
setUp(() async {
interpreter = await tfl.Interpreter.fromAsset('test/$quantFileName');
});
tearDown(() => interpreter.close());
test('params', () {
interpreter.allocateTensors();
final tensor = interpreter.getInputTensor(0);
print(tensor.params);
if (Platform.isAndroid) {
group('quantization', () {
tfl.Interpreter interpreter;
setUp(() async {
interpreter =
await tfl.Interpreter.fromAsset('test/$quantFileName');
});
tearDown(() => interpreter.close());
test('params', () {
interpreter.allocateTensors();
final tensor = interpreter.getInputTensor(0);
print(tensor.params);
});
});
});
}
});
});

Expand All @@ -219,8 +223,9 @@ void main() {
});
test('multiple input', () async {
tfl.Interpreter interpreter;
interpreter =
await tfl.Interpreter.fromAsset('test/$multiInputFileName');
interpreter = await tfl.Interpreter.fromAsset(
'test/$multiInputFileName',
);
final inputTensors = interpreter.getInputTensors();
expect(inputTensors.length, 4);
expect(inputTensors[0].type, tfl.TfLiteType.float32);
Expand Down Expand Up @@ -291,6 +296,23 @@ void main() {
expect(output[0][0][0], [3, 7, -4, 3, 7, -4, 3, 7, -4, 3, 7, -4]);
interpreter.close();
});
test('with int64', () async {
tfl.Interpreter interpreter;
final path = await getPathOnDevice(int64FileName);
interpreter = tfl.Interpreter.fromFile(File(path));
print(interpreter.getInputTensor(0));
final oneD = <int>[3, 7, -4];
final twoD = List.filled(8, oneD);
final threeD = List.filled(8, twoD);
final fourD = List.filled(2, threeD);

var output = List(2 * 4 * 4 * 12).reshape([2, 4, 4, 12]);

interpreter.run(fourD, output);

expect(output[0][0][0], [3, 7, -4, 3, 7, -4, 3, 7, -4, 3, 7, -4]);
interpreter.close();
});
if (Platform.isAndroid) {
test('using set use NnApi', () async {
tfl.Interpreter interpreter;
Expand Down Expand Up @@ -329,29 +351,20 @@ void main() {
});

// Unable to create interpreter
/*test('using GpuDelegateV2 android', () async {
tfl.Interpreter interpreter;
final gpuDelegate = tfl.GpuDelegateV2();
var interpreterOptions = tfl.InterpreterOptions()
..addDelegate(gpuDelegate);
interpreter = await tfl.Interpreter.fromAsset('test/$addFileName',
options: interpreterOptions);
var o = [1.23, 6.54, 7.81];
var two = [o, o, o, o, o, o, o, o];
var three = [two, two, two, two, two, two, two, two];
var four = [three];
var output = List(1 * 8 * 8 * 3).reshape([1, 8, 8, 3]);
interpreter.run(four, output);
var exp = '';
if (output[0][0][0][0] is double) {
exp = (output[0][0][0][0] as double).toStringAsFixed(2);
}
expect(exp, '3.69');
interpreter.close();
});*/
test('using GpuDelegateV2 android', () async {
tfl.Interpreter interpreter;
final gpuDelegate = tfl.GpuDelegateV2();
var interpreterOptions = tfl.InterpreterOptions()
..addDelegate(gpuDelegate);
interpreter = await tfl.Interpreter.fromAsset(
'text_classification.tflite',
options: interpreterOptions);
expect(interpreter, isNotNull);
interpreter.close();
});

if (Platform.isIOS) {
test('using GpuDelegateV2 android', () async {
test('using GpuDelegateV2 iOS', () async {
tfl.Interpreter interpreter;
final gpuDelegate = tfl.GpuDelegateV2();
var interpreterOptions = tfl.InterpreterOptions()
Expand Down
12 changes: 2 additions & 10 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
cd "$(dirname "$(readlink -f "$0")")"

URL="https://github.com/am15h/tflite_flutter_plugin/releases/download/"
TAG="v0.1.0"
TAG="v0.2.0"

ANDROID_DIR="android/app/src/main/jniLibs/"
ANDROID_LIB="libtensorflowlite_c.so"
Expand All @@ -15,8 +15,6 @@ ARM_64="libtensorflowlite_c_arm64.so"
X86="libtensorflowlite_c_x86.so"
X86_64="libtensorflowlite_c_x86_64.so"

#IOS="https://github.com/am15h/tflite_flutter_plugin/releases/download/v0.1.0/TensorFlowLiteC.framework_fat.zip"

delegate=0

while getopts "d" OPTION
Expand Down Expand Up @@ -47,10 +45,4 @@ download ${ARM_64} "arm64-v8a"
fi

download ${X86} "x86"
download ${X86_64} "x86_64"

#ios
#wget "$IOS"
#unzip TensorFlowLiteC.framework_fat.zip
#rm TensorFlowLiteC.framework_fat.zip
#mv TensorFlowLiteC.framework ios/
download ${X86_64} "x86_64"
Loading

0 comments on commit add359a

Please sign in to comment.