diff --git a/.fvmrc b/.fvmrc new file mode 100644 index 0000000..1d77e35 --- /dev/null +++ b/.fvmrc @@ -0,0 +1,4 @@ +{ + "flutter": "3.22.0", + "flavors": {} +} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 7d0c21c..ead43ac 100644 --- a/.gitignore +++ b/.gitignore @@ -73,3 +73,6 @@ build/ !**/ios/**/default.pbxuser !**/ios/**/default.perspectivev3 !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages + +# FVM Version Cache +.fvm/ \ No newline at end of file diff --git a/.pubignore b/.pubignore new file mode 100644 index 0000000..645512a --- /dev/null +++ b/.pubignore @@ -0,0 +1,3 @@ +example/ +examples/ +build/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d2cf11..9550bb3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# [0.4.0] - Moved to tflite flutter processor +* Updated all libraries to support updated tflite_flutter package. +* fixed bug in android preventing build + # [0.3.0] - Audio Support and Task Library * Added support for audio-cases. * Task Library for Text based applications. diff --git a/README.md b/README.md index faaeb6c..db1b815 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ Sample app: [Audio Classification](https://github.com/am15h/tflite_flutter_helpe // Create a container for the result and specify that this is a quantized model. // Hence, the 'DataType' is defined as UINT8 (8-bit unsigned integer) TensorBuffer probabilityBuffer = - TensorBuffer.createFixedSize([1, 1001], TfLiteType.uint8); + TensorBuffer.createFixedSize([1, 1001], TfLiteType.kTfLiteUInt8); ``` #### Loading the model and running inference: diff --git a/android/build.gradle b/android/build.gradle index 165dd0b..77d9e7b 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,8 +1,8 @@ -group 'com.tfliteflutter.tflite_flutter_helper' +group 'com.xmartlabs.tflite_flutter_helper' version '1.0-SNAPSHOT' buildscript { - ext.kotlin_version = '1.3.50' + ext.kotlin_version = '2.0.0' repositories { google() jcenter() diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index 3c9d085..ffed3a2 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip diff --git a/android/settings.gradle b/android/settings.gradle index 1f03ec1..fd73fe9 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -1,3 +1 @@ -package android - rootProject.name = 'tflite_flutter_helper' diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index 90f3d5b..ccefbc9 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -1,4 +1,4 @@ + package="com.xmartlabs.tflite_flutter_helper"> diff --git a/android/src/main/kotlin/com/tfliteflutter/tflite_flutter_helper/TfliteFlutterHelperPlugin.kt b/android/src/main/kotlin/com/xmartlabs/tflite_flutter_helper/TfliteFlutterHelperPlugin.kt similarity index 95% rename from android/src/main/kotlin/com/tfliteflutter/tflite_flutter_helper/TfliteFlutterHelperPlugin.kt rename to android/src/main/kotlin/com/xmartlabs/tflite_flutter_helper/TfliteFlutterHelperPlugin.kt index 37b3192..25f9b2c 100644 --- a/android/src/main/kotlin/com/tfliteflutter/tflite_flutter_helper/TfliteFlutterHelperPlugin.kt +++ b/android/src/main/kotlin/com/xmartlabs/tflite_flutter_helper/TfliteFlutterHelperPlugin.kt @@ -1,4 +1,4 @@ -package com.tfliteflutter.tflite_flutter_helper +package com.xmartlabs.tflite_flutter_helper import io.flutter.embedding.engine.plugins.FlutterPlugin import io.flutter.plugin.common.MethodCall @@ -37,7 +37,7 @@ enum class SoundStreamStatus { Stopped, } -const val METHOD_CHANNEL_NAME = "com.tfliteflutter.tflite_flutter_helper:methods" +const val METHOD_CHANNEL_NAME = "com.xmartlabs.tflite_flutter_helper:methods" /** TfliteFlutterHelperPlugin */ class TfliteFlutterHelperPlugin : FlutterPlugin, @@ -46,7 +46,7 @@ class TfliteFlutterHelperPlugin : FlutterPlugin, ActivityAware { - private val LOG_TAG = "TfLiteFlutterHelperPlugin" + private val LOG_TAG = "TfliteFlutterHelperPlugin" private val AUDIO_RECORD_PERMISSION_CODE = 14887 private val DEFAULT_SAMPLE_RATE = 16000 private val DEFAULT_BUFFER_SIZE = 8192 @@ -140,14 +140,14 @@ class TfliteFlutterHelperPlugin : FlutterPlugin, } } - override fun onRequestPermissionsResult(requestCode: Int, permissions: Array?, - grantResults: IntArray?): Boolean { + override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, + grantResults: IntArray): Boolean { when (requestCode) { AUDIO_RECORD_PERMISSION_CODE -> { - if (grantResults != null) { - permissionToRecordAudio = grantResults.isNotEmpty() && - grantResults[0] == PackageManager.PERMISSION_GRANTED - } + + permissionToRecordAudio = grantResults.isNotEmpty() && + grantResults[0] == PackageManager.PERMISSION_GRANTED + completeInitializeRecorder() return true } diff --git a/example/audio_classification/android/build.gradle b/example/audio_classification/android/build.gradle index 3204979..7b91e28 100644 --- a/example/audio_classification/android/build.gradle +++ b/example/audio_classification/android/build.gradle @@ -24,6 +24,6 @@ subprojects { project.evaluationDependsOn(':app') } -task clean(type: Delete) { +tasks.register("clean", Delete) { delete rootProject.buildDir } diff --git a/example/audio_classification/ios/Flutter/Debug.xcconfig b/example/audio_classification/ios/Flutter/Debug.xcconfig index 592ceee..ec97fc6 100644 --- a/example/audio_classification/ios/Flutter/Debug.xcconfig +++ b/example/audio_classification/ios/Flutter/Debug.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Generated.xcconfig" diff --git a/example/audio_classification/ios/Flutter/Release.xcconfig b/example/audio_classification/ios/Flutter/Release.xcconfig index 592ceee..c4855bf 100644 --- a/example/audio_classification/ios/Flutter/Release.xcconfig +++ b/example/audio_classification/ios/Flutter/Release.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Generated.xcconfig" diff --git a/example/audio_classification/lib/classifier.dart b/example/audio_classification/lib/classifier.dart index 143787d..0121d1e 100644 --- a/example/audio_classification/lib/classifier.dart +++ b/example/audio_classification/lib/classifier.dart @@ -15,7 +15,7 @@ class Classifier { late TensorBuffer _outputBuffer; - TfLiteType _outputType = TfLiteType.uint8; + TensorType _outputType = TensorType.uint8; final String _modelFileName = 'yamnet.tflite'; final String _labelFileName = 'assets/yamnet_class_map.csv'; @@ -84,7 +84,9 @@ List getTopProbability(Map labeledProb) { var pq = PriorityQueue>(compare); pq.addAll(labeledProb.entries); var result = []; - while (pq.isNotEmpty && result.length < 5 && (pq.first.value > 0.1 || result.length < 3)) { + while (pq.isNotEmpty && + result.length < 5 && + (pq.first.value > 0.1 || result.length < 3)) { result.add(Category(pq.first.key, pq.first.value)); pq.removeFirst(); } diff --git a/example/audio_classification/lib/main.dart b/example/audio_classification/lib/main.dart index 299cca0..d4842ce 100644 --- a/example/audio_classification/lib/main.dart +++ b/example/audio_classification/lib/main.dart @@ -83,7 +83,7 @@ class _MyAppState extends State { @override Widget build(BuildContext context) { return MaterialApp( - theme: ThemeData(primaryColor: Colors.orange, accentColor: Colors.orange), + theme: ThemeData(primaryColor: Colors.orange, hintColor: Colors.orange), home: Scaffold( appBar: AppBar( title: const Text( diff --git a/example/audio_classification/pubspec.lock b/example/audio_classification/pubspec.lock index c3dcb28..23fd506 100644 --- a/example/audio_classification/pubspec.lock +++ b/example/audio_classification/pubspec.lock @@ -5,105 +5,144 @@ packages: dependency: transitive description: name: archive - url: "https://pub.dartlang.org" + sha256: "22600aa1e926be775fa5fe7e6894e7fb3df9efda8891c73f70fb3262399a432d" + url: "https://pub.dev" source: hosted - version: "3.1.2" + version: "3.4.10" async: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" source: hosted - version: "2.6.1" + version: "2.11.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" camera: dependency: transitive description: name: camera - url: "https://pub.dartlang.org" + sha256: "9499cbc2e51d8eb0beadc158b288380037618ce4e30c9acbc4fae1ac3ecb5797" + url: "https://pub.dev" source: hosted - version: "0.8.1+7" + version: "0.10.5+9" + camera_android: + dependency: transitive + description: + name: camera_android + sha256: "351429510121d179b9aac5a2e8cb525c3cd6c39f4d709c5f72dfb21726e52371" + url: "https://pub.dev" + source: hosted + version: "0.10.8+16" + camera_avfoundation: + dependency: transitive + description: + name: camera_avfoundation + sha256: "7d0763dfcbf060f56aa254a68c103210280bee9e97bbe4fdef23e257a4f70ab9" + url: "https://pub.dev" + source: hosted + version: "0.9.14" camera_platform_interface: dependency: transitive description: name: camera_platform_interface - url: "https://pub.dartlang.org" + sha256: fceb2c36038b6392317b1d5790c6ba9e6ca9f1da3031181b8bea03882bf9387a + url: "https://pub.dev" source: hosted - version: "2.1.0" - characters: + version: "2.7.3" + camera_web: dependency: transitive description: - name: characters - url: "https://pub.dartlang.org" + name: camera_web + sha256: f18ccfb33b2a7c49a52ad5aa3f07330b7422faaecbdfd9b9fe8e51182f6ad67d + url: "https://pub.dev" source: hosted - version: "1.1.0" - charcode: + version: "0.3.2+4" + characters: dependency: transitive description: - name: charcode - url: "https://pub.dartlang.org" + name: characters + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.0" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + url: "https://pub.dev" source: hosted - version: "1.15.0" + version: "1.18.0" + convert: + dependency: transitive + description: + name: convert + sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" + url: "https://pub.dev" + source: hosted + version: "3.1.1" cross_file: dependency: transitive description: name: cross_file - url: "https://pub.dartlang.org" + sha256: "437b2b8da454fe1e01131f4410274fd607347325e9330f0b469ed5a204991068" + url: "https://pub.dev" source: hosted version: "0.3.1+4" crypto: dependency: transitive description: name: crypto - url: "https://pub.dartlang.org" + sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab + url: "https://pub.dev" source: hosted - version: "3.0.1" + version: "3.0.3" cupertino_icons: dependency: "direct main" description: name: cupertino_icons - url: "https://pub.dartlang.org" + sha256: "486b7bc707424572cdf7bd7e812a0c146de3fd47ecadf070254cc60383f21dd8" + url: "https://pub.dev" source: hosted version: "1.0.3" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.1" ffi: dependency: transitive description: name: ffi - url: "https://pub.dartlang.org" + sha256: "493f37e7df1804778ff3a53bd691d8692ddf69702cf4c1c1096a2e41b4779e21" + url: "https://pub.dev" source: hosted - version: "1.1.2" + version: "2.1.2" file: dependency: transitive description: name: file - url: "https://pub.dartlang.org" + sha256: b69516f2c26a5bcac4eee2e32512e1a5205ab312b3536c1c1227b2b942b5f9ad + url: "https://pub.dev" source: hosted version: "6.1.2" flutter: @@ -111,121 +150,190 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_plugin_android_lifecycle: + dependency: transitive + description: + name: flutter_plugin_android_lifecycle + sha256: b068ffc46f82a55844acfa4fdbb61fad72fa2aef0905548419d97f0f95c456da + url: "https://pub.dev" + source: hosted + version: "2.0.17" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" image: dependency: transitive description: name: image - url: "https://pub.dartlang.org" + sha256: "4c68bfd5ae83e700b5204c1e74451e7bf3cf750e6843c6e158289cf56bda018e" + url: "https://pub.dev" + source: hosted + version: "4.1.7" + js: + dependency: transitive + description: + name: js + sha256: c1b2e9b5ea78c45e1a0788d29606ba27dc5f71f019f32ca5140f61ef071838cf + url: "https://pub.dev" + source: hosted + version: "0.7.1" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" + url: "https://pub.dev" + source: hosted + version: "10.0.0" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 + url: "https://pub.dev" + source: hosted + version: "2.0.1" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 + url: "https://pub.dev" source: hosted - version: "3.0.2" + version: "2.0.1" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb + url: "https://pub.dev" + source: hosted + version: "0.12.16+1" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" + url: "https://pub.dev" source: hosted - version: "0.12.10" + version: "0.8.0" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 + url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.11.0" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" + url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.9.0" path_provider: dependency: transitive description: name: path_provider - url: "https://pub.dartlang.org" + sha256: cfdc261c62a7273be7e051b19d27e503927a40919932f790681042a038f3605d + url: "https://pub.dev" source: hosted version: "2.0.2" path_provider_linux: dependency: transitive description: name: path_provider_linux - url: "https://pub.dartlang.org" + sha256: "938d2b6591587bcb009d2109a6ea464fd8fb2a75dc6423171b0d0afb1d27c708" + url: "https://pub.dev" source: hosted version: "2.0.0" path_provider_macos: dependency: transitive description: name: path_provider_macos - url: "https://pub.dartlang.org" + sha256: eb58b896ea3a504f0b0fa7870646bda6935a6f752b2a54df33f97070dacca8d4 + url: "https://pub.dev" source: hosted version: "2.0.0" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface - url: "https://pub.dartlang.org" + sha256: c2af5a8a6369992d915f8933dfc23172071001359d17896e83db8be57db8a397 + url: "https://pub.dev" source: hosted version: "2.0.1" path_provider_windows: dependency: transitive description: name: path_provider_windows - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.1" - pedantic: - dependency: transitive - description: - name: pedantic - url: "https://pub.dartlang.org" + sha256: "1cb68ba4cd3a795033de62ba1b7b4564dace301f952de6bfb3cd91b202b6ee96" + url: "https://pub.dev" source: hosted - version: "1.11.1" + version: "2.1.7" petitparser: dependency: transitive description: name: petitparser - url: "https://pub.dartlang.org" + sha256: c15605cd28af66339f8eb6fbe0e541bfe2d1b72d5825efc6598f3e0a31b9ad27 + url: "https://pub.dev" source: hosted - version: "4.1.0" + version: "6.0.2" platform: dependency: transitive description: name: platform - url: "https://pub.dartlang.org" + sha256: ebc79f16b5f6b609aad4a5e63447d4795d16f7adee46e93ed03200848c006735 + url: "https://pub.dev" source: hosted version: "3.0.0" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface - url: "https://pub.dartlang.org" + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" + url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.1.8" + pointycastle: + dependency: transitive + description: + name: pointycastle + sha256: "43ac87de6e10afabc85c445745a7b799e04de84cebaa4fd7bf55a5e1e9604d29" + url: "https://pub.dev" + source: hosted + version: "3.7.4" process: dependency: transitive description: name: process - url: "https://pub.dartlang.org" + sha256: dc3c073b5bc0db4e0f3dbc6b69f8e9cf2f336dafb3db996242ebdacf94c295dd + url: "https://pub.dev" source: hosted version: "4.2.1" quiver: dependency: transitive description: name: quiver - url: "https://pub.dartlang.org" + sha256: "5e592c348a6c528fb8deb7cc7d85a7097ce65bf2349121ad004d1fc5d5905eaa" + url: "https://pub.dev" source: hosted version: "3.0.1" random_color: dependency: "direct main" description: name: random_color - url: "https://pub.dartlang.org" + sha256: ec6fffad26e3e1d19e64389e031e9fd324ce1a6cf79bb9a5b050302d6dba37bb + url: "https://pub.dev" source: hosted version: "1.0.6-nullsafety" sky_engine: @@ -237,107 +345,129 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" source: hosted - version: "1.8.1" + version: "1.10.0" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.2" stream_transform: dependency: transitive description: name: stream_transform - url: "https://pub.dartlang.org" + sha256: ed464977cb26a1f41537e177e190c67223dbd9f4f683489b6ab2e5d211ec564e + url: "https://pub.dev" source: hosted version: "2.0.0" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.2.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + url: "https://pub.dev" source: hosted - version: "0.3.0" + version: "0.6.1" tflite_flutter: dependency: transitive description: - path: "../../../tflite_flutter_plugin" - relative: true - source: path - version: "0.9.0" + name: tflite_flutter + sha256: ffb8651fdb116ab0131d6dc47ff73883e0f634ad1ab12bb2852eef1bbeab4a6a + url: "https://pub.dev" + source: hosted + version: "0.10.4" tflite_flutter_helper: dependency: "direct main" description: path: "../.." relative: true source: path - version: "0.2.1" + version: "0.4.0" tuple: dependency: transitive description: name: tuple - url: "https://pub.dartlang.org" + sha256: fe3ae4f0dca3f9aac0888e2e0d117b642ce283a82d7017b54136290c0a3b0dd3 + url: "https://pub.dev" source: hosted version: "2.0.0" typed_data: dependency: transitive description: name: typed_data - url: "https://pub.dartlang.org" + sha256: "53bdf7e979cfbf3e28987552fd72f637e63f3c8724c9e56d9246942dc2fa36ee" + url: "https://pub.dev" source: hosted version: "1.3.0" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.dartlang.org" + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "13.0.0" win32: dependency: transitive description: name: win32 - url: "https://pub.dartlang.org" + sha256: "464f5674532865248444b4c3daca12bd9bf2d7c47f759ce2617986e7229494a8" + url: "https://pub.dev" source: hosted - version: "2.2.5" + version: "5.2.0" xdg_directories: dependency: transitive description: name: xdg_directories - url: "https://pub.dartlang.org" + sha256: "0186b3f2d66be9a12b0295bddcf8b6f8c0b0cc2f85c6287344e2a6366bc28457" + url: "https://pub.dev" source: hosted version: "0.2.0" xml: dependency: transitive description: name: xml - url: "https://pub.dartlang.org" + sha256: b015a8ad1c488f66851d762d3090a21c600e479dc75e68328c52774040cf9226 + url: "https://pub.dev" source: hosted - version: "5.1.2" + version: "6.5.0" sdks: - dart: ">=2.13.0 <3.0.0" - flutter: ">=2.0.0" + dart: ">=3.3.0-279.1.beta <4.0.0" + flutter: ">=3.16.6" diff --git a/example/audio_classification/pubspec.yaml b/example/audio_classification/pubspec.yaml index 50a02e1..a320d9d 100644 --- a/example/audio_classification/pubspec.yaml +++ b/example/audio_classification/pubspec.yaml @@ -3,7 +3,7 @@ description: A new Flutter project. # The following line prevents the package from being accidentally published to # pub.dev using `pub publish`. This is preferred for private packages. -publish_to: 'none' # Remove this line if you wish to publish to pub.dev +publish_to: "none" # Remove this line if you wish to publish to pub.dev # The following defines the version and build number for your application. # A version number is three numbers separated by dots, like 1.2.43 @@ -27,8 +27,7 @@ dependencies: # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 tflite_flutter_helper: - path: - ../../ + path: ../../ random_color: ^1.0.6-nullsafety dev_dependencies: flutter_test: @@ -39,7 +38,6 @@ dev_dependencies: # The following section is specific to Flutter. flutter: - # The following line ensures that the Material Icons font is # included with your application, so that you can use the icons in # the material Icons class. diff --git a/example/bert_question_answer/android/app/build.gradle b/example/bert_question_answer/android/app/build.gradle index ca4ce71..2cd3fcb 100644 --- a/example/bert_question_answer/android/app/build.gradle +++ b/example/bert_question_answer/android/app/build.gradle @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 30 + compileSdkVersion 33 sourceSets { main.java.srcDirs += 'src/main/kotlin' @@ -36,7 +36,7 @@ android { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.example.bert_question_answer" minSdkVersion 21 - targetSdkVersion 30 + targetSdkVersion 33 versionCode flutterVersionCode.toInteger() versionName flutterVersionName } diff --git a/example/bert_question_answer/android/build.gradle b/example/bert_question_answer/android/build.gradle index 9b6ed06..9214c91 100644 --- a/example/bert_question_answer/android/build.gradle +++ b/example/bert_question_answer/android/build.gradle @@ -1,12 +1,12 @@ buildscript { - ext.kotlin_version = '1.3.50' + ext.kotlin_version = '1.6.10' repositories { google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:4.1.0' + classpath 'com.android.tools.build:gradle:7.1.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -14,7 +14,8 @@ buildscript { allprojects { repositories { google() - jcenter() + mavenCentral() + gradlePluginPortal() } } @@ -24,6 +25,6 @@ subprojects { project.evaluationDependsOn(':app') } -task clean(type: Delete) { +tasks.register("clean", Delete) { delete rootProject.buildDir } diff --git a/example/bert_question_answer/android/gradle/wrapper/gradle-wrapper.properties b/example/bert_question_answer/android/gradle/wrapper/gradle-wrapper.properties index bc6a58a..cfe88f6 100644 --- a/example/bert_question_answer/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/bert_question_answer/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip diff --git a/example/bert_question_answer/android/settings.gradle b/example/bert_question_answer/android/settings.gradle index 44e62bc..4e615ce 100644 --- a/example/bert_question_answer/android/settings.gradle +++ b/example/bert_question_answer/android/settings.gradle @@ -1,11 +1,26 @@ -include ':app' +pluginManagement { + def flutterSdkPath = { + def properties = new Properties() + file("local.properties").withInputStream { properties.load(it) } + def flutterSdkPath = properties.getProperty("flutter.sdk") + assert flutterSdkPath != null, "flutter.sdk not set in local.properties" + return flutterSdkPath + } + settings.ext.flutterSdkPath = flutterSdkPath() -def localPropertiesFile = new File(rootProject.projectDir, "local.properties") -def properties = new Properties() + includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle") -assert localPropertiesFile.exists() -localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} -def flutterSdkPath = properties.getProperty("flutter.sdk") -assert flutterSdkPath != null, "flutter.sdk not set in local.properties" -apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" +plugins { + id "dev.flutter.flutter-plugin-loader" version "1.0.0" + id "com.android.application" version "7.1.1" apply false + id "org.jetbrains.kotlin.android" version "1.6.10" apply false +} + +include ":app" \ No newline at end of file diff --git a/example/bert_question_answer/ios/Flutter/Debug.xcconfig b/example/bert_question_answer/ios/Flutter/Debug.xcconfig index 592ceee..ec97fc6 100644 --- a/example/bert_question_answer/ios/Flutter/Debug.xcconfig +++ b/example/bert_question_answer/ios/Flutter/Debug.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Generated.xcconfig" diff --git a/example/bert_question_answer/ios/Flutter/Release.xcconfig b/example/bert_question_answer/ios/Flutter/Release.xcconfig index 592ceee..c4855bf 100644 --- a/example/bert_question_answer/ios/Flutter/Release.xcconfig +++ b/example/bert_question_answer/ios/Flutter/Release.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Generated.xcconfig" diff --git a/example/bert_question_answer/lib/bert_qa.dart b/example/bert_question_answer/lib/bert_qa.dart index c023d38..e24a623 100644 --- a/example/bert_question_answer/lib/bert_qa.dart +++ b/example/bert_question_answer/lib/bert_qa.dart @@ -9,7 +9,7 @@ class BertQA { final _modelPath = "lite-model_mobilebert_1_metadata_1.tflite"; - BertQA () { + BertQA() { createClassifier(); } diff --git a/example/bert_question_answer/pubspec.lock b/example/bert_question_answer/pubspec.lock index f55ef37..7ec81b9 100644 --- a/example/bert_question_answer/pubspec.lock +++ b/example/bert_question_answer/pubspec.lock @@ -5,105 +5,152 @@ packages: dependency: transitive description: name: archive - url: "https://pub.dartlang.org" + sha256: "20071638cbe4e5964a427cfa0e86dce55d060bc7d82d56f3554095d7239a8765" + url: "https://pub.dev" source: hosted - version: "3.1.2" + version: "3.4.2" async: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" source: hosted - version: "2.6.1" + version: "2.11.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" camera: dependency: transitive description: name: camera - url: "https://pub.dartlang.org" + sha256: "9499cbc2e51d8eb0beadc158b288380037618ce4e30c9acbc4fae1ac3ecb5797" + url: "https://pub.dev" + source: hosted + version: "0.10.5+9" + camera_android: + dependency: transitive + description: + name: camera_android + sha256: "351429510121d179b9aac5a2e8cb525c3cd6c39f4d709c5f72dfb21726e52371" + url: "https://pub.dev" + source: hosted + version: "0.10.8+16" + camera_avfoundation: + dependency: transitive + description: + name: camera_avfoundation + sha256: "7d0763dfcbf060f56aa254a68c103210280bee9e97bbe4fdef23e257a4f70ab9" + url: "https://pub.dev" source: hosted - version: "0.8.1+7" + version: "0.9.14" camera_platform_interface: dependency: transitive description: name: camera_platform_interface - url: "https://pub.dartlang.org" + sha256: fceb2c36038b6392317b1d5790c6ba9e6ca9f1da3031181b8bea03882bf9387a + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.7.3" + camera_web: + dependency: transitive + description: + name: camera_web + sha256: f18ccfb33b2a7c49a52ad5aa3f07330b7422faaecbdfd9b9fe8e51182f6ad67d + url: "https://pub.dev" + source: hosted + version: "0.3.2+4" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.3.0" charcode: dependency: transitive description: name: charcode - url: "https://pub.dartlang.org" + sha256: "8e36feea6de5ea69f2199f29cf42a450a855738c498b57c0b980e2d3cca9c362" + url: "https://pub.dev" source: hosted version: "1.2.0" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + url: "https://pub.dev" + source: hosted + version: "1.18.0" + convert: + dependency: transitive + description: + name: convert + sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" + url: "https://pub.dev" source: hosted - version: "1.15.0" + version: "3.1.1" cross_file: dependency: transitive description: name: cross_file - url: "https://pub.dartlang.org" + sha256: "437b2b8da454fe1e01131f4410274fd607347325e9330f0b469ed5a204991068" + url: "https://pub.dev" source: hosted version: "0.3.1+4" crypto: dependency: transitive description: name: crypto - url: "https://pub.dartlang.org" + sha256: cf75650c66c0316274e21d7c43d3dea246273af5955bd94e8184837cd577575c + url: "https://pub.dev" source: hosted version: "3.0.1" cupertino_icons: dependency: "direct main" description: name: cupertino_icons - url: "https://pub.dartlang.org" + sha256: "486b7bc707424572cdf7bd7e812a0c146de3fd47ecadf070254cc60383f21dd8" + url: "https://pub.dev" source: hosted version: "1.0.3" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.1" ffi: dependency: transitive description: name: ffi - url: "https://pub.dartlang.org" + sha256: "493f37e7df1804778ff3a53bd691d8692ddf69702cf4c1c1096a2e41b4779e21" + url: "https://pub.dev" source: hosted - version: "1.1.2" + version: "2.1.2" file: dependency: transitive description: name: file - url: "https://pub.dartlang.org" + sha256: b69516f2c26a5bcac4eee2e32512e1a5205ab312b3536c1c1227b2b942b5f9ad + url: "https://pub.dev" source: hosted version: "6.1.2" flutter: @@ -111,163 +158,246 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_plugin_android_lifecycle: + dependency: transitive + description: + name: flutter_plugin_android_lifecycle + sha256: b068ffc46f82a55844acfa4fdbb61fad72fa2aef0905548419d97f0f95c456da + url: "https://pub.dev" + source: hosted + version: "2.0.17" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" freezed_annotation: dependency: transitive description: name: freezed_annotation - url: "https://pub.dartlang.org" + sha256: "660c3d317449c61cfe85550964e9df78d3e08de4383d929ce6239dfa90124927" + url: "https://pub.dev" source: hosted version: "0.14.2" google_fonts: dependency: "direct main" description: name: google_fonts - url: "https://pub.dartlang.org" + sha256: c31d49dfbcef1a84592128d2d9e8767eebf5a919ac1e6f77d14dc36790ef1639 + url: "https://pub.dev" source: hosted version: "2.1.0" http: dependency: transitive description: name: http - url: "https://pub.dartlang.org" + sha256: b6f1f143a71e1fe1b34670f1acd6f13960ade2557c96b87e127e0cf661969791 + url: "https://pub.dev" source: hosted version: "0.13.3" http_parser: dependency: transitive description: name: http_parser - url: "https://pub.dartlang.org" + sha256: e362d639ba3bc07d5a71faebb98cde68c05bfbcfbbb444b60b6f60bb67719185 + url: "https://pub.dev" source: hosted version: "4.0.0" image: dependency: transitive description: name: image - url: "https://pub.dartlang.org" + sha256: "4c68bfd5ae83e700b5204c1e74451e7bf3cf750e6843c6e158289cf56bda018e" + url: "https://pub.dev" source: hosted - version: "3.0.2" + version: "4.1.7" + js: + dependency: transitive + description: + name: js + sha256: c1b2e9b5ea78c45e1a0788d29606ba27dc5f71f019f32ca5140f61ef071838cf + url: "https://pub.dev" + source: hosted + version: "0.7.1" json_annotation: dependency: transitive description: name: json_annotation - url: "https://pub.dartlang.org" + sha256: fd56fb29e3f02cd9bef80e99e9491d27889fb010f98ff3379b21e7d40d0112b3 + url: "https://pub.dev" source: hosted version: "4.0.1" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" + url: "https://pub.dev" + source: hosted + version: "10.0.0" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 + url: "https://pub.dev" + source: hosted + version: "2.0.1" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 + url: "https://pub.dev" + source: hosted + version: "2.0.1" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb + url: "https://pub.dev" source: hosted - version: "0.12.10" + version: "0.12.16+1" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" + url: "https://pub.dev" + source: hosted + version: "0.8.0" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 + url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.11.0" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" + url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.9.0" path_provider: dependency: "direct main" description: name: path_provider - url: "https://pub.dartlang.org" + sha256: cfdc261c62a7273be7e051b19d27e503927a40919932f790681042a038f3605d + url: "https://pub.dev" source: hosted version: "2.0.2" path_provider_linux: dependency: transitive description: name: path_provider_linux - url: "https://pub.dartlang.org" + sha256: f8d4b3ba360fb5d3517b1dcbb8695d242a8ab4cf6483b46b961c2257da948c93 + url: "https://pub.dev" source: hosted version: "2.0.2" path_provider_macos: dependency: transitive description: name: path_provider_macos - url: "https://pub.dartlang.org" + sha256: "0d1273a80d3db3ffb3d82a1e063b8d1e889fd2879fcd81f8b0f00bfa8246498e" + url: "https://pub.dev" source: hosted version: "2.0.2" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface - url: "https://pub.dartlang.org" + sha256: c2af5a8a6369992d915f8933dfc23172071001359d17896e83db8be57db8a397 + url: "https://pub.dev" source: hosted version: "2.0.1" path_provider_windows: dependency: transitive description: name: path_provider_windows - url: "https://pub.dartlang.org" + sha256: "1cb68ba4cd3a795033de62ba1b7b4564dace301f952de6bfb3cd91b202b6ee96" + url: "https://pub.dev" source: hosted - version: "2.0.3" + version: "2.1.7" pedantic: dependency: transitive description: name: pedantic - url: "https://pub.dartlang.org" + sha256: "67fc27ed9639506c856c840ccce7594d0bdcd91bc8d53d6e52359449a1d50602" + url: "https://pub.dev" source: hosted version: "1.11.1" petitparser: dependency: transitive description: name: petitparser - url: "https://pub.dartlang.org" + sha256: c15605cd28af66339f8eb6fbe0e541bfe2d1b72d5825efc6598f3e0a31b9ad27 + url: "https://pub.dev" source: hosted - version: "4.1.0" + version: "6.0.2" platform: dependency: transitive description: name: platform - url: "https://pub.dartlang.org" + sha256: "4a8c298d9ac37f18a1116f7be2aa86c3eaea5913586c5afbb905429dd79efa84" + url: "https://pub.dev" source: hosted version: "3.0.2" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface - url: "https://pub.dartlang.org" + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" + url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.1.8" + pointycastle: + dependency: transitive + description: + name: pointycastle + sha256: "43ac87de6e10afabc85c445745a7b799e04de84cebaa4fd7bf55a5e1e9604d29" + url: "https://pub.dev" + source: hosted + version: "3.7.4" process: dependency: transitive description: name: process - url: "https://pub.dartlang.org" + sha256: ca157bb5ee3a2dce23ac17bac6d5e54c9d7d1b693f560b606a84aacd2f3c54f8 + url: "https://pub.dev" source: hosted version: "4.2.3" quiver: dependency: transitive description: name: quiver - url: "https://pub.dartlang.org" + sha256: "5e592c348a6c528fb8deb7cc7d85a7097ce65bf2349121ad004d1fc5d5905eaa" + url: "https://pub.dev" source: hosted version: "3.0.1" random_color: dependency: "direct main" description: name: random_color - url: "https://pub.dartlang.org" + sha256: ec6fffad26e3e1d19e64389e031e9fd324ce1a6cf79bb9a5b050302d6dba37bb + url: "https://pub.dev" source: hosted version: "1.0.6-nullsafety" riverpod: dependency: "direct main" description: name: riverpod - url: "https://pub.dartlang.org" + sha256: "13cbe0e17b659f38027986df967b3eaf7f42c519786352167fc3db1be44eae07" + url: "https://pub.dev" source: hosted version: "0.14.0+3" sky_engine: @@ -279,114 +409,137 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" source: hosted - version: "1.8.1" + version: "1.10.0" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.1" state_notifier: dependency: transitive description: name: state_notifier - url: "https://pub.dartlang.org" + sha256: "629c10533982f40660197f5d2d0884b3ab58a1f6a7e72b16a8aefea6c1e9054a" + url: "https://pub.dev" source: hosted version: "0.7.0" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.2" stream_transform: dependency: transitive description: name: stream_transform - url: "https://pub.dartlang.org" + sha256: ed464977cb26a1f41537e177e190c67223dbd9f4f683489b6ab2e5d211ec564e + url: "https://pub.dev" source: hosted version: "2.0.0" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.2.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + url: "https://pub.dev" source: hosted - version: "0.3.0" + version: "0.6.1" tflite_flutter: dependency: transitive description: name: tflite_flutter - url: "https://pub.dartlang.org" + sha256: ffb8651fdb116ab0131d6dc47ff73883e0f634ad1ab12bb2852eef1bbeab4a6a + url: "https://pub.dev" source: hosted - version: "0.9.0" + version: "0.10.4" tflite_flutter_helper: dependency: "direct main" description: path: "../.." relative: true source: path - version: "0.2.2" + version: "0.1.0" tuple: dependency: transitive description: name: tuple - url: "https://pub.dartlang.org" + sha256: fe3ae4f0dca3f9aac0888e2e0d117b642ce283a82d7017b54136290c0a3b0dd3 + url: "https://pub.dev" source: hosted version: "2.0.0" typed_data: dependency: transitive description: name: typed_data - url: "https://pub.dartlang.org" + sha256: "53bdf7e979cfbf3e28987552fd72f637e63f3c8724c9e56d9246942dc2fa36ee" + url: "https://pub.dev" source: hosted version: "1.3.0" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.dartlang.org" + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.4" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 + url: "https://pub.dev" + source: hosted + version: "13.0.0" win32: dependency: transitive description: name: win32 - url: "https://pub.dartlang.org" + sha256: "464f5674532865248444b4c3daca12bd9bf2d7c47f759ce2617986e7229494a8" + url: "https://pub.dev" source: hosted - version: "2.2.5" + version: "5.2.0" xdg_directories: dependency: transitive description: name: xdg_directories - url: "https://pub.dartlang.org" + sha256: "0186b3f2d66be9a12b0295bddcf8b6f8c0b0cc2f85c6287344e2a6366bc28457" + url: "https://pub.dev" source: hosted version: "0.2.0" xml: dependency: transitive description: name: xml - url: "https://pub.dartlang.org" + sha256: b015a8ad1c488f66851d762d3090a21c600e479dc75e68328c52774040cf9226 + url: "https://pub.dev" source: hosted - version: "5.1.2" + version: "6.5.0" sdks: - dart: ">=2.13.0 <3.0.0" - flutter: ">=2.0.0" + dart: ">=3.3.0-279.1.beta <4.0.0" + flutter: ">=3.16.6" diff --git a/example/bert_question_answer/pubspec.yaml b/example/bert_question_answer/pubspec.yaml index 59809b5..65a33ba 100644 --- a/example/bert_question_answer/pubspec.yaml +++ b/example/bert_question_answer/pubspec.yaml @@ -3,7 +3,7 @@ description: Sample app for Bert Question Answer in Flutter # The following line prevents the package from being accidentally published to # pub.dev using `pub publish`. This is preferred for private packages. -publish_to: 'none' # Remove this line if you wish to publish to pub.dev +publish_to: "none" # Remove this line if you wish to publish to pub.dev # The following defines the version and build number for your application. # A version number is three numbers separated by dots, like 1.2.43 @@ -24,8 +24,7 @@ dependencies: flutter: sdk: flutter tflite_flutter_helper: - path: - ../../ + path: ../../ path_provider: riverpod: ^0.14.0+3 cupertino_icons: ^1.0.2 @@ -40,7 +39,6 @@ dev_dependencies: # The following section is specific to Flutter. flutter: - # The following line ensures that the Material Icons font is # included with your application, so that you can use the icons in # the material Icons class. diff --git a/example/image_classification/android/app/build.gradle b/example/image_classification/android/app/build.gradle index fb6aa1f..9494d96 100644 --- a/example/image_classification/android/app/build.gradle +++ b/example/image_classification/android/app/build.gradle @@ -1,3 +1,8 @@ +plugins { + id "com.android.application" + id "dev.flutter.flutter-gradle-plugin" +} + def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) { @@ -6,11 +11,6 @@ if (localPropertiesFile.exists()) { } } -def flutterRoot = localProperties.getProperty('flutter.sdk') -if (flutterRoot == null) { - throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") -} - def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) { flutterVersionCode = '1' @@ -21,11 +21,9 @@ if (flutterVersionName == null) { flutterVersionName = '1.0' } -apply plugin: 'com.android.application' -apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 28 + compileSdkVersion 34 lintOptions { disable 'InvalidPackage' @@ -34,8 +32,8 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.example.imageclassification" - minSdkVersion 21 - targetSdkVersion 28 + minSdkVersion 26 + targetSdkVersion 26 versionCode flutterVersionCode.toInteger() versionName flutterVersionName testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/example/image_classification/android/app/src/main/AndroidManifest.xml b/example/image_classification/android/app/src/main/AndroidManifest.xml index 5fdd614..623e561 100644 --- a/example/image_classification/android/app/src/main/AndroidManifest.xml +++ b/example/image_classification/android/app/src/main/AndroidManifest.xml @@ -6,7 +6,7 @@ additional functionality it is fine to subclass or reimplement FlutterApplication and put your custom class here. --> plugins.load(reader) } + repositories { + google() + mavenCentral() + gradlePluginPortal() + } } -plugins.each { name, path -> - def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() - include ":$name" - project(":$name").projectDir = pluginDirectory +plugins { + id "dev.flutter.flutter-plugin-loader" version "1.0.0" + id "com.android.application" version "7.1.2" apply false } + +include ":app" diff --git a/example/image_classification/ios/Flutter/Debug.xcconfig b/example/image_classification/ios/Flutter/Debug.xcconfig index 592ceee..ec97fc6 100644 --- a/example/image_classification/ios/Flutter/Debug.xcconfig +++ b/example/image_classification/ios/Flutter/Debug.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Generated.xcconfig" diff --git a/example/image_classification/ios/Flutter/Release.xcconfig b/example/image_classification/ios/Flutter/Release.xcconfig index 592ceee..c4855bf 100644 --- a/example/image_classification/ios/Flutter/Release.xcconfig +++ b/example/image_classification/ios/Flutter/Release.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Generated.xcconfig" diff --git a/example/image_classification/lib/classifier.dart b/example/image_classification/lib/classifier.dart index bad50d9..07b644b 100644 --- a/example/image_classification/lib/classifier.dart +++ b/example/image_classification/lib/classifier.dart @@ -18,8 +18,8 @@ abstract class Classifier { late TensorImage _inputImage; late TensorBuffer _outputBuffer; - late TfLiteType _inputType; - late TfLiteType _outputType; + late TensorType _inputType; + late TensorType _outputType; final String _labelsFileName = 'assets/labels.txt'; @@ -40,7 +40,7 @@ abstract class Classifier { if (numThreads != null) { _interpreterOptions.threads = numThreads; } - + logger.i("LOADING THE MODEL!"); loadModel(); loadLabels(); } diff --git a/example/image_classification/lib/main.dart b/example/image_classification/lib/main.dart index 2eb147c..28d2533 100644 --- a/example/image_classification/lib/main.dart +++ b/example/image_classification/lib/main.dart @@ -52,7 +52,7 @@ class _MyHomePageState extends State { } Future getImage() async { - final pickedFile = await picker.getImage(source: ImageSource.gallery); + final pickedFile = await picker.pickImage(source: ImageSource.gallery); setState(() { _image = File(pickedFile!.path); diff --git a/example/image_classification/pubspec.lock b/example/image_classification/pubspec.lock index b229d1e..19bcd5a 100644 --- a/example/image_classification/pubspec.lock +++ b/example/image_classification/pubspec.lock @@ -5,107 +5,178 @@ packages: dependency: transitive description: name: archive - url: "https://pub.dartlang.org" + sha256: "22600aa1e926be775fa5fe7e6894e7fb3df9efda8891c73f70fb3262399a432d" + url: "https://pub.dev" source: hosted - version: "3.1.2" + version: "3.4.10" async: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" source: hosted - version: "2.6.1" + version: "2.11.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" camera: dependency: transitive description: name: camera - url: "https://pub.dartlang.org" + sha256: "9499cbc2e51d8eb0beadc158b288380037618ce4e30c9acbc4fae1ac3ecb5797" + url: "https://pub.dev" + source: hosted + version: "0.10.5+9" + camera_android: + dependency: transitive + description: + name: camera_android + sha256: "351429510121d179b9aac5a2e8cb525c3cd6c39f4d709c5f72dfb21726e52371" + url: "https://pub.dev" + source: hosted + version: "0.10.8+16" + camera_avfoundation: + dependency: transitive + description: + name: camera_avfoundation + sha256: "7d0763dfcbf060f56aa254a68c103210280bee9e97bbe4fdef23e257a4f70ab9" + url: "https://pub.dev" source: hosted - version: "0.8.1+7" + version: "0.9.14" camera_platform_interface: dependency: transitive description: name: camera_platform_interface - url: "https://pub.dartlang.org" + sha256: fceb2c36038b6392317b1d5790c6ba9e6ca9f1da3031181b8bea03882bf9387a + url: "https://pub.dev" source: hosted - version: "2.1.0" - characters: + version: "2.7.3" + camera_web: dependency: transitive description: - name: characters - url: "https://pub.dartlang.org" + name: camera_web + sha256: f18ccfb33b2a7c49a52ad5aa3f07330b7422faaecbdfd9b9fe8e51182f6ad67d + url: "https://pub.dev" source: hosted - version: "1.1.0" - charcode: + version: "0.3.2+4" + characters: dependency: transitive description: - name: charcode - url: "https://pub.dartlang.org" + name: characters + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.0" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: "direct main" description: name: collection - url: "https://pub.dartlang.org" + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + url: "https://pub.dev" + source: hosted + version: "1.18.0" + convert: + dependency: transitive + description: + name: convert + sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" + url: "https://pub.dev" source: hosted - version: "1.15.0" + version: "3.1.1" cross_file: dependency: transitive description: name: cross_file - url: "https://pub.dartlang.org" + sha256: "74a4727e030347edff3b6e5256b7fb0c3de8af8ed278e6c56718760786a1fa40" + url: "https://pub.dev" source: hosted - version: "0.3.1+4" + version: "0.3.4" crypto: dependency: transitive description: name: crypto - url: "https://pub.dartlang.org" + sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab + url: "https://pub.dev" source: hosted - version: "3.0.1" + version: "3.0.3" cupertino_icons: dependency: "direct main" description: name: cupertino_icons - url: "https://pub.dartlang.org" + sha256: d57953e10f9f8327ce64a508a355f0b1ec902193f66288e8cb5070e7c47eeb2d + url: "https://pub.dev" source: hosted - version: "0.1.3" + version: "1.0.6" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.1" ffi: dependency: transitive description: name: ffi - url: "https://pub.dartlang.org" + sha256: "493f37e7df1804778ff3a53bd691d8692ddf69702cf4c1c1096a2e41b4779e21" + url: "https://pub.dev" source: hosted - version: "1.0.0" + version: "2.1.2" file: dependency: transitive description: name: file - url: "https://pub.dartlang.org" + sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c" + url: "https://pub.dev" + source: hosted + version: "7.0.0" + file_selector_linux: + dependency: transitive + description: + name: file_selector_linux + sha256: "045d372bf19b02aeb69cacf8b4009555fb5f6f0b7ad8016e5f46dd1387ddd492" + url: "https://pub.dev" + source: hosted + version: "0.9.2+1" + file_selector_macos: + dependency: transitive + description: + name: file_selector_macos + sha256: b15c3da8bd4908b9918111fa486903f5808e388b8d1c559949f584725a6594d6 + url: "https://pub.dev" source: hosted - version: "6.1.0" + version: "0.9.3+3" + file_selector_platform_interface: + dependency: transitive + description: + name: file_selector_platform_interface + sha256: a3994c26f10378a039faa11de174d7b78eb8f79e4dd0af2a451410c1a5c3f66b + url: "https://pub.dev" + source: hosted + version: "2.6.2" + file_selector_windows: + dependency: transitive + description: + name: file_selector_windows + sha256: d3547240c20cabf205c7c7f01a50ecdbc413755814d6677f3cb366f04abcead0 + url: "https://pub.dev" + source: hosted + version: "0.9.3+1" flutter: dependency: "direct main" description: flutter @@ -120,9 +191,10 @@ packages: dependency: transitive description: name: flutter_plugin_android_lifecycle - url: "https://pub.dartlang.org" + sha256: b068ffc46f82a55844acfa4fdbb61fad72fa2aef0905548419d97f0f95c456da + url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.0.17" flutter_test: dependency: "direct dev" description: flutter @@ -142,44 +214,90 @@ packages: dependency: transitive description: name: http - url: "https://pub.dartlang.org" + sha256: "761a297c042deedc1ffbb156d6e2af13886bb305c2a343a4d972504cd67dd938" + url: "https://pub.dev" source: hosted - version: "0.13.1" + version: "1.2.1" http_parser: dependency: transitive description: name: http_parser - url: "https://pub.dartlang.org" + sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" + url: "https://pub.dev" source: hosted - version: "4.0.0" + version: "4.0.2" image: dependency: transitive description: name: image - url: "https://pub.dartlang.org" + sha256: "4c68bfd5ae83e700b5204c1e74451e7bf3cf750e6843c6e158289cf56bda018e" + url: "https://pub.dev" source: hosted - version: "3.0.2" + version: "4.1.7" image_picker: dependency: "direct main" description: name: image_picker - url: "https://pub.dartlang.org" + sha256: "26222b01a0c9a2c8fe02fc90b8208bd3325da5ed1f4a2acabf75939031ac0bdd" + url: "https://pub.dev" + source: hosted + version: "1.0.7" + image_picker_android: + dependency: transitive + description: + name: image_picker_android + sha256: "39f2bfe497e495450c81abcd44b62f56c2a36a37a175da7d137b4454977b51b1" + url: "https://pub.dev" source: hosted - version: "0.7.4" + version: "0.8.9+3" image_picker_for_web: dependency: transitive description: name: image_picker_for_web - url: "https://pub.dartlang.org" + sha256: e2423c53a68b579a7c37a1eda967b8ae536c3d98518e5db95ca1fe5719a730a3 + url: "https://pub.dev" + source: hosted + version: "3.0.2" + image_picker_ios: + dependency: transitive + description: + name: image_picker_ios + sha256: fadafce49e8569257a0cad56d24438a6fa1f0cbd7ee0af9b631f7492818a4ca3 + url: "https://pub.dev" + source: hosted + version: "0.8.9+1" + image_picker_linux: + dependency: transitive + description: + name: image_picker_linux + sha256: "4ed1d9bb36f7cd60aa6e6cd479779cc56a4cb4e4de8f49d487b1aaad831300fa" + url: "https://pub.dev" source: hosted - version: "2.0.0" + version: "0.2.1+1" + image_picker_macos: + dependency: transitive + description: + name: image_picker_macos + sha256: "3f5ad1e8112a9a6111c46d0b57a7be2286a9a07fc6e1976fdf5be2bd31d4ff62" + url: "https://pub.dev" + source: hosted + version: "0.2.1+1" image_picker_platform_interface: dependency: transitive description: name: image_picker_platform_interface - url: "https://pub.dartlang.org" + sha256: fa4e815e6fcada50e35718727d83ba1c92f1edf95c0b4436554cec301b56233b + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.9.3" + image_picker_windows: + dependency: transitive + description: + name: image_picker_windows + sha256: "6ad07afc4eb1bc25f3a01084d28520496c4a3bb0cb13685435838167c9dcedeb" + url: "https://pub.dev" + source: hosted + version: "0.2.1+1" integration_test: dependency: "direct dev" description: flutter @@ -189,114 +307,178 @@ packages: dependency: transitive description: name: js - url: "https://pub.dartlang.org" + sha256: c1b2e9b5ea78c45e1a0788d29606ba27dc5f71f019f32ca5140f61ef071838cf + url: "https://pub.dev" + source: hosted + version: "0.7.1" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" + url: "https://pub.dev" + source: hosted + version: "10.0.0" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 + url: "https://pub.dev" + source: hosted + version: "2.0.1" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 + url: "https://pub.dev" source: hosted - version: "0.6.3" + version: "2.0.1" logger: dependency: "direct main" description: name: logger - url: "https://pub.dartlang.org" + sha256: "6bbb9d6f7056729537a4309bda2e74e18e5d9f14302489cc1e93f33b3fe32cac" + url: "https://pub.dev" source: hosted - version: "1.0.0" + version: "2.0.2+1" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb + url: "https://pub.dev" source: hosted - version: "0.12.10" + version: "0.12.16+1" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" + url: "https://pub.dev" + source: hosted + version: "0.8.0" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 + url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.11.0" + mime: + dependency: transitive + description: + name: mime + sha256: "2e123074287cc9fd6c09de8336dae606d1ddb88d9ac47358826db698c176a1f2" + url: "https://pub.dev" + source: hosted + version: "1.0.5" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" + url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.9.0" path_provider: dependency: "direct main" description: name: path_provider - url: "https://pub.dartlang.org" + sha256: b27217933eeeba8ff24845c34003b003b2b22151de3c908d0e679e8fe1aa078b + url: "https://pub.dev" source: hosted - version: "2.0.1" - path_provider_linux: + version: "2.1.2" + path_provider_android: dependency: transitive description: - name: path_provider_linux - url: "https://pub.dartlang.org" + name: path_provider_android + sha256: "477184d672607c0a3bf68fbbf601805f92ef79c82b64b4d6eb318cbca4c48668" + url: "https://pub.dev" source: hosted - version: "2.0.0" - path_provider_macos: + version: "2.2.2" + path_provider_foundation: dependency: transitive description: - name: path_provider_macos - url: "https://pub.dartlang.org" + name: path_provider_foundation + sha256: "5a7999be66e000916500be4f15a3633ebceb8302719b47b9cc49ce924125350f" + url: "https://pub.dev" source: hosted - version: "2.0.0" + version: "2.3.2" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279 + url: "https://pub.dev" + source: hosted + version: "2.2.1" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface - url: "https://pub.dartlang.org" + sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334" + url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.1.2" path_provider_windows: dependency: transitive description: name: path_provider_windows - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.0" - pedantic: - dependency: transitive - description: - name: pedantic - url: "https://pub.dartlang.org" + sha256: "8bc9f22eee8690981c22aa7fc602f5c85b497a6fb2ceb35ee5a5e5ed85ad8170" + url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "2.2.1" petitparser: dependency: transitive description: name: petitparser - url: "https://pub.dartlang.org" + sha256: c15605cd28af66339f8eb6fbe0e541bfe2d1b72d5825efc6598f3e0a31b9ad27 + url: "https://pub.dev" source: hosted - version: "4.1.0" + version: "6.0.2" platform: dependency: transitive description: name: platform - url: "https://pub.dartlang.org" + sha256: "12220bb4b65720483f8fa9450b4332347737cf8213dd2840d8b2c823e47243ec" + url: "https://pub.dev" source: hosted - version: "3.0.0" + version: "3.1.4" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface - url: "https://pub.dartlang.org" + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" + url: "https://pub.dev" + source: hosted + version: "2.1.8" + pointycastle: + dependency: transitive + description: + name: pointycastle + sha256: "43ac87de6e10afabc85c445745a7b799e04de84cebaa4fd7bf55a5e1e9604d29" + url: "https://pub.dev" source: hosted - version: "2.0.0" + version: "3.7.4" process: dependency: transitive description: name: process - url: "https://pub.dartlang.org" + sha256: "21e54fd2faf1b5bdd5102afd25012184a6793927648ea81eea80552ac9405b32" + url: "https://pub.dev" source: hosted - version: "4.2.1" + version: "5.0.2" quiver: dependency: transitive description: name: quiver - url: "https://pub.dartlang.org" + sha256: b1c1ac5ce6688d77f65f3375a9abb9319b3cb32486bdc7a1e0fdf004d7ba4e47 + url: "https://pub.dev" source: hosted - version: "3.0.1" + version: "3.2.1" sky_engine: dependency: transitive description: flutter @@ -306,128 +488,153 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" source: hosted - version: "1.8.1" + version: "1.10.0" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.2" stream_transform: dependency: transitive description: name: stream_transform - url: "https://pub.dartlang.org" + sha256: "14a00e794c7c11aa145a170587321aedce29769c08d7f58b1d141da75e3b1c6f" + url: "https://pub.dev" source: hosted - version: "2.0.0" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.2.0" sync_http: dependency: transitive description: name: sync_http - url: "https://pub.dartlang.org" + sha256: "7f0cd72eca000d2e026bcd6f990b81d0ca06022ef4e32fb257b30d3d1014a961" + url: "https://pub.dev" source: hosted - version: "0.3.0" + version: "0.3.1" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + url: "https://pub.dev" source: hosted - version: "0.3.0" + version: "0.6.1" tflite_flutter: dependency: transitive description: name: tflite_flutter - url: "https://pub.dartlang.org" + sha256: ffb8651fdb116ab0131d6dc47ff73883e0f634ad1ab12bb2852eef1bbeab4a6a + url: "https://pub.dev" source: hosted - version: "0.9.0" + version: "0.10.4" tflite_flutter_helper: dependency: "direct main" description: path: "../.." relative: true source: path - version: "0.2.1" + version: "0.4.0" tuple: dependency: transitive description: name: tuple - url: "https://pub.dartlang.org" + sha256: a97ce2013f240b2f3807bcbaf218765b6f301c3eff91092bcfa23a039e7dd151 + url: "https://pub.dev" source: hosted - version: "2.0.0" + version: "2.0.2" typed_data: dependency: transitive description: name: typed_data - url: "https://pub.dartlang.org" + sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c + url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.3.2" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.dartlang.org" + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.4" vm_service: dependency: transitive description: name: vm_service - url: "https://pub.dartlang.org" + sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 + url: "https://pub.dev" + source: hosted + version: "13.0.0" + web: + dependency: transitive + description: + name: web + sha256: "1d9158c616048c38f712a6646e317a3426da10e884447626167240d45209cbad" + url: "https://pub.dev" source: hosted - version: "6.2.0" + version: "0.5.0" webdriver: dependency: transitive description: name: webdriver - url: "https://pub.dartlang.org" + sha256: "003d7da9519e1e5f329422b36c4dcdf18d7d2978d1ba099ea4e45ba490ed845e" + url: "https://pub.dev" source: hosted - version: "3.0.0" + version: "3.0.3" win32: dependency: transitive description: name: win32 - url: "https://pub.dartlang.org" + sha256: "464f5674532865248444b4c3daca12bd9bf2d7c47f759ce2617986e7229494a8" + url: "https://pub.dev" source: hosted - version: "2.0.5" + version: "5.2.0" xdg_directories: dependency: transitive description: name: xdg_directories - url: "https://pub.dartlang.org" + sha256: faea9dee56b520b55a566385b84f2e8de55e7496104adada9962e0bd11bcff1d + url: "https://pub.dev" source: hosted - version: "0.2.0" + version: "1.0.4" xml: dependency: transitive description: name: xml - url: "https://pub.dartlang.org" + sha256: b015a8ad1c488f66851d762d3090a21c600e479dc75e68328c52774040cf9226 + url: "https://pub.dev" source: hosted - version: "5.1.0" + version: "6.5.0" sdks: - dart: ">=2.12.0 <3.0.0" - flutter: ">=2.0.0" + dart: ">=3.3.0 <4.0.0" + flutter: ">=3.16.6" diff --git a/example/image_classification/pubspec.yaml b/example/image_classification/pubspec.yaml index a407d5e..cba4d58 100644 --- a/example/image_classification/pubspec.yaml +++ b/example/image_classification/pubspec.yaml @@ -14,23 +14,22 @@ description: Image Classification Example. version: 1.0.0+1 environment: - sdk: ">=2.12.0 <3.0.0" + sdk: ">=2.12.0 <4.0.0" dependencies: flutter: sdk: flutter - image_picker: ^0.7.4 + image_picker: ^1.0.7 collection: ^1.15.0 - logger: ^1.0.0 + logger: ^2.0.2+1 path_provider: tflite_flutter_helper: - path: - ../../ + path: ../../ # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. - cupertino_icons: ^0.1.2 + cupertino_icons: ^1.0.6 dev_dependencies: flutter_test: @@ -45,7 +44,6 @@ dev_dependencies: # The following section is specific to Flutter. flutter: - # The following line ensures that the Material Icons font is # included with your application, so that you can use the icons in # the material Icons class. diff --git a/example/pubspec.lock b/example/pubspec.lock index f23587f..fce7ef1 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -2,4 +2,4 @@ # See https://dart.dev/tools/pub/glossary#lockfile packages: {} sdks: - dart: ">=2.12.0 <3.0.0" + dart: ">=2.12.0 <4.0.0" diff --git a/example/text_classification_task/android/app/src/main/AndroidManifest.xml b/example/text_classification_task/android/app/src/main/AndroidManifest.xml index d7ffd2e..e2144a2 100644 --- a/example/text_classification_task/android/app/src/main/AndroidManifest.xml +++ b/example/text_classification_task/android/app/src/main/AndroidManifest.xml @@ -6,7 +6,7 @@ additional functionality it is fine to subclass or reimplement FlutterApplication and put your custom class here. --> =2.12.0 <3.0.0" @@ -10,12 +10,11 @@ dependencies: flutter: sdk: flutter tflite_flutter_helper: - path: - ../../ + path: ../../ path_provider: ^2.0.1 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. - cupertino_icons: ^0.1.2 + cupertino_icons: ^1.0.6 dev_dependencies: flutter_test: @@ -25,13 +24,11 @@ dev_dependencies: integration_test: sdk: flutter - # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec # The following section is specific to Flutter. flutter: - # The following line ensures that the Material Icons font is # included with your application, so that you can use the icons in # the material Icons class. diff --git a/examples/image_classifier/assets/greyfox.jpg b/examples/image_classifier/assets/greyfox.jpg new file mode 100644 index 0000000..c93d956 Binary files /dev/null and b/examples/image_classifier/assets/greyfox.jpg differ diff --git a/examples/image_classifier/assets/labels.txt b/examples/image_classifier/assets/labels.txt new file mode 100644 index 0000000..b52daf9 --- /dev/null +++ b/examples/image_classifier/assets/labels.txt @@ -0,0 +1,1001 @@ +background +tench +goldfish +great white shark +tiger shark +hammerhead +electric ray +stingray +cock +hen +ostrich +brambling +goldfinch +house finch +junco +indigo bunting +robin +bulbul +jay +magpie +chickadee +water ouzel +kite +bald eagle +vulture +great grey owl +European fire salamander +common newt +eft +spotted salamander +axolotl +bullfrog +tree frog +tailed frog +loggerhead +leatherback turtle +mud turtle +terrapin +box turtle +banded gecko +common iguana +American chameleon +whiptail +agama +frilled lizard +alligator lizard +Gila monster +green lizard +African chameleon +Komodo dragon +African crocodile +American alligator +triceratops +thunder snake +ringneck snake +hognose snake +green snake +king snake +garter snake +water snake +vine snake +night snake +boa constrictor +rock python +Indian cobra +green mamba +sea snake +horned viper +diamondback +sidewinder +trilobite +harvestman +scorpion +black and gold garden spider +barn spider +garden spider +black widow +tarantula +wolf spider +tick +centipede +black grouse +ptarmigan +ruffed grouse +prairie chicken +peacock +quail +partridge +African grey +macaw +sulphur-crested cockatoo +lorikeet +coucal +bee eater +hornbill +hummingbird +jacamar +toucan +drake +red-breasted merganser +goose +black swan +tusker +echidna +platypus +wallaby +koala +wombat +jellyfish +sea anemone +brain coral +flatworm +nematode +conch +snail +slug +sea slug +chiton +chambered nautilus +Dungeness crab +rock crab +fiddler crab +king crab +American lobster +spiny lobster +crayfish +hermit crab +isopod +white stork +black stork +spoonbill +flamingo +little blue heron +American egret +bittern +crane +limpkin +European gallinule +American coot +bustard +ruddy turnstone +red-backed sandpiper +redshank +dowitcher +oystercatcher +pelican +king penguin +albatross +grey whale +killer whale +dugong +sea lion +Chihuahua +Japanese spaniel +Maltese dog +Pekinese +Shih-Tzu +Blenheim spaniel +papillon +toy terrier +Rhodesian ridgeback +Afghan hound +basset +beagle +bloodhound +bluetick +black-and-tan coonhound +Walker hound +English foxhound +redbone +borzoi +Irish wolfhound +Italian greyhound +whippet +Ibizan hound +Norwegian elkhound +otterhound +Saluki +Scottish deerhound +Weimaraner +Staffordshire bullterrier +American Staffordshire terrier +Bedlington terrier +Border terrier +Kerry blue terrier +Irish terrier +Norfolk terrier +Norwich terrier +Yorkshire terrier +wire-haired fox terrier +Lakeland terrier +Sealyham terrier +Airedale +cairn +Australian terrier +Dandie Dinmont +Boston bull +miniature schnauzer +giant schnauzer +standard schnauzer +Scotch terrier +Tibetan terrier +silky terrier +soft-coated wheaten terrier +West Highland white terrier +Lhasa +flat-coated retriever +curly-coated retriever +golden retriever +Labrador retriever +Chesapeake Bay retriever +German short-haired pointer +vizsla +English setter +Irish setter +Gordon setter +Brittany spaniel +clumber +English springer +Welsh springer spaniel +cocker spaniel +Sussex spaniel +Irish water spaniel +kuvasz +schipperke +groenendael +malinois +briard +kelpie +komondor +Old English sheepdog +Shetland sheepdog +collie +Border collie +Bouvier des Flandres +Rottweiler +German shepherd +Doberman +miniature pinscher +Greater Swiss Mountain dog +Bernese mountain dog +Appenzeller +EntleBucher +boxer +bull mastiff +Tibetan mastiff +French bulldog +Great Dane +Saint Bernard +Eskimo dog +malamute +Siberian husky +dalmatian +affenpinscher +basenji +pug +Leonberg +Newfoundland +Great Pyrenees +Samoyed +Pomeranian +chow +keeshond +Brabancon griffon +Pembroke +Cardigan +toy poodle +miniature poodle +standard poodle +Mexican hairless +timber wolf +white wolf +red wolf +coyote +dingo +dhole +African hunting dog +hyena +red fox +kit fox +Arctic fox +grey fox +tabby +tiger cat +Persian cat +Siamese cat +Egyptian cat +cougar +lynx +leopard +snow leopard +jaguar +lion +tiger +cheetah +brown bear +American black bear +ice bear +sloth bear +mongoose +meerkat +tiger beetle +ladybug +ground beetle +long-horned beetle +leaf beetle +dung beetle +rhinoceros beetle +weevil +fly +bee +ant +grasshopper +cricket +walking stick +cockroach +mantis +cicada +leafhopper +lacewing +dragonfly +damselfly +admiral +ringlet +monarch +cabbage butterfly +sulphur butterfly +lycaenid +starfish +sea urchin +sea cucumber +wood rabbit +hare +Angora +hamster +porcupine +fox squirrel +marmot +beaver +guinea pig +sorrel +zebra +hog +wild boar +warthog +hippopotamus +ox +water buffalo +bison +ram +bighorn +ibex +hartebeest +impala +gazelle +Arabian camel +llama +weasel +mink +polecat +black-footed ferret +otter +skunk +badger +armadillo +three-toed sloth +orangutan +gorilla +chimpanzee +gibbon +siamang +guenon +patas +baboon +macaque +langur +colobus +proboscis monkey +marmoset +capuchin +howler monkey +titi +spider monkey +squirrel monkey +Madagascar cat +indri +Indian elephant +African elephant +lesser panda +giant panda +barracouta +eel +coho +rock beauty +anemone fish +sturgeon +gar +lionfish +puffer +abacus +abaya +academic gown +accordion +acoustic guitar +aircraft carrier +airliner +airship +altar +ambulance +amphibian +analog clock +apiary +apron +ashcan +assault rifle +backpack +bakery +balance beam +balloon +ballpoint +Band Aid +banjo +bannister +barbell +barber chair +barbershop +barn +barometer +barrel +barrow +baseball +basketball +bassinet +bassoon +bathing cap +bath towel +bathtub +beach wagon +beacon +beaker +bearskin +beer bottle +beer glass +bell cote +bib +bicycle-built-for-two +bikini +binder +binoculars +birdhouse +boathouse +bobsled +bolo tie +bonnet +bookcase +bookshop +bottlecap +bow +bow tie +brass +brassiere +breakwater +breastplate +broom +bucket +buckle +bulletproof vest +bullet train +butcher shop +cab +caldron +candle +cannon +canoe +can opener +cardigan +car mirror +carousel +carpenter's kit +carton +car wheel +cash machine +cassette +cassette player +castle +catamaran +CD player +cello +cellular telephone +chain +chainlink fence +chain mail +chain saw +chest +chiffonier +chime +china cabinet +Christmas stocking +church +cinema +cleaver +cliff dwelling +cloak +clog +cocktail shaker +coffee mug +coffeepot +coil +combination lock +computer keyboard +confectionery +container ship +convertible +corkscrew +cornet +cowboy boot +cowboy hat +cradle +crane +crash helmet +crate +crib +Crock Pot +croquet ball +crutch +cuirass +dam +desk +desktop computer +dial telephone +diaper +digital clock +digital watch +dining table +dishrag +dishwasher +disk brake +dock +dogsled +dome +doormat +drilling platform +drum +drumstick +dumbbell +Dutch oven +electric fan +electric guitar +electric locomotive +entertainment center +envelope +espresso maker +face powder +feather boa +file +fireboat +fire engine +fire screen +flagpole +flute +folding chair +football helmet +forklift +fountain +fountain pen +four-poster +freight car +French horn +frying pan +fur coat +garbage truck +gasmask +gas pump +goblet +go-kart +golf ball +golfcart +gondola +gong +gown +grand piano +greenhouse +grille +grocery store +guillotine +hair slide +hair spray +half track +hammer +hamper +hand blower +hand-held computer +handkerchief +hard disc +harmonica +harp +harvester +hatchet +holster +home theater +honeycomb +hook +hoopskirt +horizontal bar +horse cart +hourglass +iPod +iron +jack-o'-lantern +jean +jeep +jersey +jigsaw puzzle +jinrikisha +joystick +kimono +knee pad +knot +lab coat +ladle +lampshade +laptop +lawn mower +lens cap +letter opener +library +lifeboat +lighter +limousine +liner +lipstick +Loafer +lotion +loudspeaker +loupe +lumbermill +magnetic compass +mailbag +mailbox +maillot +maillot +manhole cover +maraca +marimba +mask +matchstick +maypole +maze +measuring cup +medicine chest +megalith +microphone +microwave +military uniform +milk can +minibus +miniskirt +minivan +missile +mitten +mixing bowl +mobile home +Model T +modem +monastery +monitor +moped +mortar +mortarboard +mosque +mosquito net +motor scooter +mountain bike +mountain tent +mouse +mousetrap +moving van +muzzle +nail +neck brace +necklace +nipple +notebook +obelisk +oboe +ocarina +odometer +oil filter +organ +oscilloscope +overskirt +oxcart +oxygen mask +packet +paddle +paddlewheel +padlock +paintbrush +pajama +palace +panpipe +paper towel +parachute +parallel bars +park bench +parking meter +passenger car +patio +pay-phone +pedestal +pencil box +pencil sharpener +perfume +Petri dish +photocopier +pick +pickelhaube +picket fence +pickup +pier +piggy bank +pill bottle +pillow +ping-pong ball +pinwheel +pirate +pitcher +plane +planetarium +plastic bag +plate rack +plow +plunger +Polaroid camera +pole +police van +poncho +pool table +pop bottle +pot +potter's wheel +power drill +prayer rug +printer +prison +projectile +projector +puck +punching bag +purse +quill +quilt +racer +racket +radiator +radio +radio telescope +rain barrel +recreational vehicle +reel +reflex camera +refrigerator +remote control +restaurant +revolver +rifle +rocking chair +rotisserie +rubber eraser +rugby ball +rule +running shoe +safe +safety pin +saltshaker +sandal +sarong +sax +scabbard +scale +school bus +schooner +scoreboard +screen +screw +screwdriver +seat belt +sewing machine +shield +shoe shop +shoji +shopping basket +shopping cart +shovel +shower cap +shower curtain +ski +ski mask +sleeping bag +slide rule +sliding door +slot +snorkel +snowmobile +snowplow +soap dispenser +soccer ball +sock +solar dish +sombrero +soup bowl +space bar +space heater +space shuttle +spatula +speedboat +spider web +spindle +sports car +spotlight +stage +steam locomotive +steel arch bridge +steel drum +stethoscope +stole +stone wall +stopwatch +stove +strainer +streetcar +stretcher +studio couch +stupa +submarine +suit +sundial +sunglass +sunglasses +sunscreen +suspension bridge +swab +sweatshirt +swimming trunks +swing +switch +syringe +table lamp +tank +tape player +teapot +teddy +television +tennis ball +thatch +theater curtain +thimble +thresher +throne +tile roof +toaster +tobacco shop +toilet seat +torch +totem pole +tow truck +toyshop +tractor +trailer truck +tray +trench coat +tricycle +trimaran +tripod +triumphal arch +trolleybus +trombone +tub +turnstile +typewriter keyboard +umbrella +unicycle +upright +vacuum +vase +vault +velvet +vending machine +vestment +viaduct +violin +volleyball +waffle iron +wall clock +wallet +wardrobe +warplane +washbasin +washer +water bottle +water jug +water tower +whiskey jug +whistle +wig +window screen +window shade +Windsor tie +wine bottle +wing +wok +wooden spoon +wool +worm fence +wreck +yawl +yurt +web site +comic book +crossword puzzle +street sign +traffic light +book jacket +menu +plate +guacamole +consomme +hot pot +trifle +ice cream +ice lolly +French loaf +bagel +pretzel +cheeseburger +hotdog +mashed potato +head cabbage +broccoli +cauliflower +zucchini +spaghetti squash +acorn squash +butternut squash +cucumber +artichoke +bell pepper +cardoon +mushroom +Granny Smith +strawberry +orange +lemon +fig +pineapple +banana +jackfruit +custard apple +pomegranate +hay +carbonara +chocolate sauce +dough +meat loaf +pizza +potpie +burrito +red wine +espresso +cup +eggnog +alp +bubble +cliff +coral reef +geyser +lakeside +promontory +sandbar +seashore +valley +volcano +ballplayer +groom +scuba diver +rapeseed +daisy +yellow lady's slipper +corn +acorn +hip +buckeye +coral fungus +agaric +gyromitra +stinkhorn +earthstar +hen-of-the-woods +bolete +ear +toilet tissue \ No newline at end of file diff --git a/examples/image_classifier/assets/lion.jpg b/examples/image_classifier/assets/lion.jpg new file mode 100644 index 0000000..e219564 Binary files /dev/null and b/examples/image_classifier/assets/lion.jpg differ diff --git a/examples/image_classifier/assets/mobilenet_v1_1.0_224.tflite b/examples/image_classifier/assets/mobilenet_v1_1.0_224.tflite new file mode 100644 index 0000000..a3054e1 Binary files /dev/null and b/examples/image_classifier/assets/mobilenet_v1_1.0_224.tflite differ diff --git a/examples/image_classifier/assets/mobilenet_v1_1.0_224_quant.tflite b/examples/image_classifier/assets/mobilenet_v1_1.0_224_quant.tflite new file mode 100644 index 0000000..437640b Binary files /dev/null and b/examples/image_classifier/assets/mobilenet_v1_1.0_224_quant.tflite differ diff --git a/examples/image_classifier/lib/classifier.dart b/examples/image_classifier/lib/classifier.dart new file mode 100644 index 0000000..cd28916 --- /dev/null +++ b/examples/image_classifier/lib/classifier.dart @@ -0,0 +1,130 @@ +import 'dart:math'; + +import 'package:image/image.dart'; +import 'package:collection/collection.dart'; +import 'package:logger/logger.dart'; +import 'package:tflite_flutter/tflite_flutter.dart'; +import 'package:tflite_flutter_helper/tflite_flutter_helper.dart'; + +abstract class Classifier { + late Interpreter interpreter; + late InterpreterOptions _interpreterOptions; + + var logger = Logger(); + + late List _inputShape; + late List _outputShape; + + late TensorImage _inputImage; + late TensorBuffer _outputBuffer; + + late TensorType _inputType; + late TensorType _outputType; + + final String _labelsFileName = 'assets/labels.txt'; + + final int _labelsLength = 1001; + + late var _probabilityProcessor; + + late List labels; + + String get modelName; + + NormalizeOp get preProcessNormalizeOp; + NormalizeOp get postProcessNormalizeOp; + + Classifier({int? numThreads}) { + _interpreterOptions = InterpreterOptions(); + + if (numThreads != null) { + _interpreterOptions.threads = numThreads; + } + + loadModel(); + loadLabels(); + } + + Future loadModel() async { + try { + interpreter = + await Interpreter.fromAsset(modelName, options: _interpreterOptions); + print('Interpreter Created Successfully'); + + _inputShape = interpreter.getInputTensor(0).shape; + _outputShape = interpreter.getOutputTensor(0).shape; + _inputType = interpreter.getInputTensor(0).type; + _outputType = interpreter.getOutputTensor(0).type; + + _outputBuffer = TensorBuffer.createFixedSize(_outputShape, _outputType); + _probabilityProcessor = + TensorProcessorBuilder().add(postProcessNormalizeOp).build(); + } catch (e) { + print('Unable to create interpreter, Caught Exception: ${e.toString()}'); + } + } + + Future loadLabels() async { + labels = await FileUtil.loadLabels(_labelsFileName); + if (labels.length == _labelsLength) { + print('Labels loaded successfully'); + } else { + print('Unable to load labels'); + } + } + + TensorImage _preProcess() { + int cropSize = min(_inputImage.height, _inputImage.width); + return ImageProcessorBuilder() + .add(ResizeWithCropOrPadOp(cropSize, cropSize)) + .add(ResizeOp( + _inputShape[1], _inputShape[2], ResizeMethod.NEAREST_NEIGHBOUR)) + .add(preProcessNormalizeOp) + .build() + .process(_inputImage); + } + + Category predict(Image image) { + final pres = DateTime.now().millisecondsSinceEpoch; + _inputImage = TensorImage(_inputType); + _inputImage.loadImage(image); + _inputImage = _preProcess(); + final pre = DateTime.now().millisecondsSinceEpoch - pres; + + print('Time to load image: $pre ms'); + + final runs = DateTime.now().millisecondsSinceEpoch; + interpreter.run(_inputImage.buffer, _outputBuffer.getBuffer()); + final run = DateTime.now().millisecondsSinceEpoch - runs; + + print('Time to run inference: $run ms'); + + Map labeledProb = TensorLabel.fromList( + labels, _probabilityProcessor.process(_outputBuffer)) + .getMapWithFloatValue(); + final pred = getTopProbability(labeledProb); + + return Category(pred.key, pred.value); + } + + void close() { + interpreter.close(); + } +} + +MapEntry getTopProbability(Map labeledProb) { + var pq = PriorityQueue>(compare); + pq.addAll(labeledProb.entries); + + return pq.first; +} + +int compare(MapEntry e1, MapEntry e2) { + if (e1.value > e2.value) { + return -1; + } else if (e1.value == e2.value) { + return 0; + } else { + return 1; + } +} diff --git a/examples/image_classifier/lib/classifier_float.dart b/examples/image_classifier/lib/classifier_float.dart new file mode 100644 index 0000000..78d6793 --- /dev/null +++ b/examples/image_classifier/lib/classifier_float.dart @@ -0,0 +1,15 @@ +import 'package:imageclassification/classifier.dart'; +import 'package:tflite_flutter_helper/tflite_flutter_helper.dart'; + +class ClassifierFloat extends Classifier { + ClassifierFloat({int? numThreads}) : super(numThreads: numThreads); + + @override + String get modelName => 'mobilenet_v1_1.0_224.tflite'; + + @override + NormalizeOp get preProcessNormalizeOp => NormalizeOp(127.5, 127.5); + + @override + NormalizeOp get postProcessNormalizeOp => NormalizeOp(0, 1); +} diff --git a/examples/image_classifier/lib/classifier_quant.dart b/examples/image_classifier/lib/classifier_quant.dart new file mode 100644 index 0000000..38e8f03 --- /dev/null +++ b/examples/image_classifier/lib/classifier_quant.dart @@ -0,0 +1,15 @@ +import 'package:imageclassification/classifier.dart'; +import 'package:tflite_flutter_helper/tflite_flutter_helper.dart'; + +class ClassifierQuant extends Classifier { + ClassifierQuant({int numThreads = 1}) : super(numThreads: numThreads); + + @override + String get modelName => 'mobilenet_v1_1.0_224_quant.tflite'; + + @override + NormalizeOp get preProcessNormalizeOp => NormalizeOp(0, 1); + + @override + NormalizeOp get postProcessNormalizeOp => NormalizeOp(0, 255); +} diff --git a/examples/image_classifier/lib/main.dart b/examples/image_classifier/lib/main.dart new file mode 100644 index 0000000..28d2533 --- /dev/null +++ b/examples/image_classifier/lib/main.dart @@ -0,0 +1,120 @@ +import 'dart:io'; +import 'package:image/image.dart' as img; +import 'package:flutter/material.dart'; +import 'package:image_picker/image_picker.dart'; +import 'package:imageclassification/classifier.dart'; +import 'package:imageclassification/classifier_quant.dart'; +import 'package:logger/logger.dart'; +import 'package:tflite_flutter_helper/tflite_flutter_helper.dart'; + +void main() => runApp(MyApp()); + +class MyApp extends StatelessWidget { + @override + Widget build(BuildContext context) { + return MaterialApp( + title: 'Image Classification', + theme: ThemeData( + primarySwatch: Colors.orange, + ), + home: MyHomePage(title: 'Flutter Demo Home Page'), + ); + } +} + +class MyHomePage extends StatefulWidget { + MyHomePage({Key? key, this.title}) : super(key: key); + + final String? title; + + @override + _MyHomePageState createState() => _MyHomePageState(); +} + +class _MyHomePageState extends State { + late Classifier _classifier; + + var logger = Logger(); + + File? _image; + final picker = ImagePicker(); + + Image? _imageWidget; + + img.Image? fox; + + Category? category; + + @override + void initState() { + super.initState(); + _classifier = ClassifierQuant(); + } + + Future getImage() async { + final pickedFile = await picker.pickImage(source: ImageSource.gallery); + + setState(() { + _image = File(pickedFile!.path); + _imageWidget = Image.file(_image!); + + _predict(); + }); + } + + void _predict() async { + img.Image imageInput = img.decodeImage(_image!.readAsBytesSync())!; + var pred = _classifier.predict(imageInput); + + setState(() { + this.category = pred; + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text('TfLite Flutter Helper', + style: TextStyle(color: Colors.white)), + ), + body: Column( + children: [ + Center( + child: _image == null + ? Text('No image selected.') + : Container( + constraints: BoxConstraints( + maxHeight: MediaQuery.of(context).size.height / 2), + decoration: BoxDecoration( + border: Border.all(), + ), + child: _imageWidget, + ), + ), + SizedBox( + height: 36, + ), + Text( + category != null ? category!.label : '', + style: TextStyle(fontSize: 20, fontWeight: FontWeight.w600), + ), + SizedBox( + height: 8, + ), + Text( + category != null + ? 'Confidence: ${category!.score.toStringAsFixed(3)}' + : '', + style: TextStyle(fontSize: 16), + ), + ], + ), + floatingActionButton: FloatingActionButton( + onPressed: getImage, + tooltip: 'Pick Image', + child: Icon(Icons.add_a_photo), + ), + ); + } +} diff --git a/examples/image_classifier/test/widget_test.dart b/examples/image_classifier/test/widget_test.dart new file mode 100644 index 0000000..570e0e4 --- /dev/null +++ b/examples/image_classifier/test/widget_test.dart @@ -0,0 +1,8 @@ +// This is a basic Flutter widget test. +// +// To perform an interaction with a widget in your test, use the WidgetTester +// utility that Flutter provides. For example, you can send tap and scroll +// gestures. You can also use WidgetTester to find child widgets in the widget +// tree, read text, and verify that the values of widget properties are correct. + +void main() {} diff --git a/examples/image_classifier/test_driver/integration_test.dart b/examples/image_classifier/test_driver/integration_test.dart new file mode 100644 index 0000000..10acaa6 --- /dev/null +++ b/examples/image_classifier/test_driver/integration_test.dart @@ -0,0 +1,5 @@ +import 'dart:async'; + +import 'package:integration_test/integration_test_driver.dart'; + +Future main() async => integrationDriver(); diff --git a/ios/tflite_flutter_helper.podspec b/ios/tflite_flutter_helper.podspec index 745b295..5b4d88c 100644 --- a/ios/tflite_flutter_helper.podspec +++ b/ios/tflite_flutter_helper.podspec @@ -4,12 +4,12 @@ # Pod::Spec.new do |s| s.name = 'tflite_flutter_helper' - s.version = '0.0.1' + s.version = '0.1.0' s.summary = 'A new Flutter project.' s.description = <<-DESC A new Flutter project. DESC - s.homepage = 'http://example.com' + s.homepage = 'http://chaoticdevelopment.com' s.license = { :file => '../LICENSE' } s.author = { 'Your Company' => 'email@example.com' } s.source = { :path => '.' } diff --git a/lib/src/audio/tensor_audio.dart b/lib/src/audio/tensor_audio.dart index aa35c9d..3c2d381 100644 --- a/lib/src/audio/tensor_audio.dart +++ b/lib/src/audio/tensor_audio.dart @@ -10,7 +10,7 @@ class TensorAudio { late final FloatRingBuffer buffer; late final TensorAudioFormat format; - TensorAudio._(this.format, int sampleCount){ + TensorAudio._(this.format, int sampleCount) { this.buffer = FloatRingBuffer._(sampleCount * format.channelCount); } @@ -22,13 +22,12 @@ class TensorAudio { loadDoubleListOffset(src, 0, src.length); } - void loadDoubleListOffset(List src, int offsetInFloat, - int sizeInFloat) { + void loadDoubleListOffset( + List src, int offsetInFloat, int sizeInFloat) { checkArgument( sizeInFloat % format.channelCount == 0, message: - "Size ($sizeInFloat) needs to be a multiplier of the number of channels (${format - .channelCount})", + "Size ($sizeInFloat) needs to be a multiplier of the number of channels (${format.channelCount})", ); buffer.loadOffset(src, offsetInFloat, sizeInFloat); } @@ -56,10 +55,9 @@ class TensorAudio { } void loadListOffset(List src, int offsetInShort, int sizeInShort) { - checkArgument( - offsetInShort + sizeInShort <= src.length, - message: "Index out of range. offset ($offsetInShort) + size ($sizeInShort) should <= newData.length (${src - .length})"); + checkArgument(offsetInShort + sizeInShort <= src.length, + message: + "Index out of range. offset ($offsetInShort) + size ($sizeInShort) should <= newData.length (${src.length})"); List floatData = List.filled(sizeInShort, 0.0); for (int i = offsetInShort; i < sizeInShort; i++) { // Convert the data to PCM Float encoding i.e. values between -1 and 1 @@ -68,19 +66,14 @@ class TensorAudio { loadDoubleList(floatData); } - /// Returns a float {@link TensorBuffer} holding all the available audio samples in {@link /// android.media.AudioFormat#ENCODING_PCM_FLOAT} i.e. values are in the range of [-1, 1]. TensorBuffer get tensorBuffer { ByteBuffer byteBuffer = buffer.buffer; TensorBuffer tensorBuffer = - // TODO: Confirm Shape - TensorBuffer.createFixedSize( - [1, byteBuffer - .asFloat32List() - .length - ], - TfLiteType.float32); + // TODO: Confirm Shape + TensorBuffer.createFixedSize( + [1, byteBuffer.asFloat32List().length], TensorType.float32); tensorBuffer.loadBuffer(byteBuffer); return tensorBuffer; } @@ -105,8 +98,8 @@ class TensorAudioFormat { static TensorAudioFormat create(int channelCount, int sampleRate) { checkArgument(channelCount > 0, message: "Number of channels should be greater than 0"); - checkArgument( - sampleRate > 0, message: "Sample rate should be greater than 0"); + checkArgument(sampleRate > 0, + message: "Sample rate should be greater than 0"); return TensorAudioFormat._(channelCount, sampleRate); } @@ -136,8 +129,7 @@ class FloatRingBuffer { checkArgument( offset + size <= newData.length, message: - "Index out of range. offset ($offset) + size ($size) should <= newData.length (${newData - .length})", + "Index out of range. offset ($offset) + size ($size) should <= newData.length (${newData.length})", ); // If buffer can't hold all the data, only keep the most recent data of size buffer.length if (size > _buffer.length) { @@ -164,9 +156,7 @@ class FloatRingBuffer { ByteBuffer get buffer { // TODO: Make sure there is no endianness issue - return Float32List - .fromList(_buffer) - .buffer; + return Float32List.fromList(_buffer).buffer; } int get capacity => _buffer.length; diff --git a/lib/src/common/ops/cast_op.dart b/lib/src/common/ops/cast_op.dart index 87ae2a6..bd6f361 100644 --- a/lib/src/common/ops/cast_op.dart +++ b/lib/src/common/ops/cast_op.dart @@ -5,7 +5,7 @@ import 'package:tflite_flutter_helper/src/tensorbuffer/tensorbuffer.dart'; /// Casts a [TensorBuffer] to a specified data type. class CastOp implements TensorOperator { - late TfLiteType _destinationType; + late TensorType _destinationType; /// Constructs a CastOp. /// @@ -15,12 +15,12 @@ class CastOp implements TensorOperator { /// When this Op is executed, if the original [TensorBuffer] is already in /// [destinationType], the original buffer will be directly returned. /// - /// Throws [ArgumentError] if [destinationType] is neither [TfLiteType.float32] - /// nor [TfLiteType.uint8]. - CastOp(TfLiteType destinationType) { + /// Throws [ArgumentError] if [destinationType] is neither [TfLiteType.kTfLiteFloat32] + /// nor [TfLiteType.kTfLiteUInt8]. + CastOp(TensorType destinationType) { SupportPreconditions.checkArgument( - destinationType == TfLiteType.uint8 || - destinationType == TfLiteType.float32, + destinationType == TensorType.uint8 || + destinationType == TensorType.float32, errorMessage: "Destination Type " + destinationType.toString() + " is not supported"); diff --git a/lib/src/common/ops/normailze_op.dart b/lib/src/common/ops/normailze_op.dart index 649d3a2..4487e58 100644 --- a/lib/src/common/ops/normailze_op.dart +++ b/lib/src/common/ops/normailze_op.dart @@ -29,8 +29,8 @@ class NormalizeOp implements TensorOperator { /// Note: If [mean] is set to 0 and [stddev] is set to 1, no computation will /// happen, and original input will be directly returned in execution. /// - /// Note: The returned [TensorBuffer] is always a [TfLiteType.float32] tensor at - /// present, except that the input is a [TfLiteType.uint8] tensor, [mean] is set to 0 and + /// Note: The returned [TensorBuffer] is always a [TfLiteType.kTfLiteFloat32] tensor at + /// present, except that the input is a [TfLiteType.kTfLiteUInt8] tensor, [mean] is set to 0 and /// [stddev] is set to 1. /// /// @@ -65,8 +65,8 @@ class NormalizeOp implements TensorOperator { /// Note: If all values in [mean] are set to 0 and all [stddev] are set to 1, no /// computation will happen, and original input will be directly returned in execution. /// - /// Note: The returned [TensorBuffer] is always a [TfLiteType.float32] tensor at - /// present, except that the input is a [TfLiteType.uint8] tensor, all [mean] are set to + /// Note: The returned [TensorBuffer] is always a [TfLiteType.kTfLiteFloat32] tensor at + /// present, except that the input is a [TfLiteType.kTfLiteUInt8] tensor, all [mean] are set to /// 0 and all [stddev] are set to 1. /// /// List [mean] are the mean values to be subtracted first for each channel. @@ -125,9 +125,9 @@ class NormalizeOp implements TensorOperator { } TensorBuffer output; if (input.isDynamic) { - output = TensorBuffer.createDynamic(TfLiteType.float32); + output = TensorBuffer.createDynamic(TensorType.float32); } else { - output = TensorBuffer.createFixedSize(shape, TfLiteType.float32); + output = TensorBuffer.createFixedSize(shape, TensorType.float32); } output.loadList(values, shape: shape); return output; diff --git a/lib/src/image/base_image_container.dart b/lib/src/image/base_image_container.dart index 56a0255..1226d26 100644 --- a/lib/src/image/base_image_container.dart +++ b/lib/src/image/base_image_container.dart @@ -5,7 +5,6 @@ import 'package:tflite_flutter_helper/src/image/color_space_type.dart'; import 'package:tflite_flutter_helper/src/tensorbuffer/tensorbuffer.dart'; abstract class BaseImageContainer { - /// Performs deep copy of the {@link ImageContainer}. */ BaseImageContainer clone(); @@ -20,7 +19,7 @@ abstract class BaseImageContainer { /// Gets the {@link TensorBuffer} representation with the specific {@code dataType} of the /// underlying image format. - TensorBuffer getTensorBuffer(TfLiteType dataType); + TensorBuffer getTensorBuffer(TensorType dataType); /// Gets the {@link Image} representation of the underlying image format. */ CameraImage get mediaImage; diff --git a/lib/src/image/bounding_box_utils.dart b/lib/src/image/bounding_box_utils.dart index ffe7a4a..ebe1397 100644 --- a/lib/src/image/bounding_box_utils.dart +++ b/lib/src/image/bounding_box_utils.dart @@ -50,7 +50,7 @@ class BoundingBoxUtils { /// [D] is the number of dimensions of the [tensor]. /// /// Throws [ArgumentError] if [tensor] has data type other than - /// [TfLiteType.float32]. + /// [TfLiteType.kTfLiteFloat32]. static List convert({ required TensorBuffer tensor, List valueIndex = const [0, 1, 2, 3], @@ -82,7 +82,7 @@ class BoundingBoxUtils { "Bounding box index list length ${valueIndex.length} is not 4. Got index list $valueIndex", ); SupportPreconditions.checkArgument( - tensor.getDataType() == TfLiteType.float32, + tensor.getDataType() == TfLiteType.kTfLiteFloat32, errorMessage: "Bounding Boxes only create from FLOAT32 buffers. Got: ${tensor.getDataType()}"); diff --git a/lib/src/image/camera_image_container.dart b/lib/src/image/camera_image_container.dart index b05a2fb..d818d73 100644 --- a/lib/src/image/camera_image_container.dart +++ b/lib/src/image/camera_image_container.dart @@ -30,7 +30,7 @@ class CameraImageContainer extends BaseImageContainer { } @override - TensorBuffer getTensorBuffer(TfLiteType dataType) { + TensorBuffer getTensorBuffer(TensorType dataType) { throw UnsupportedError( 'Converting CameraImage to TensorBuffer is not supported.'); } diff --git a/lib/src/image/image_container.dart b/lib/src/image/image_container.dart index f35d375..5136aca 100644 --- a/lib/src/image/image_container.dart +++ b/lib/src/image/image_container.dart @@ -1,5 +1,5 @@ import 'package:camera/camera.dart'; -import 'package:image/image.dart'; +import 'package:image/image.dart' as img; import 'package:tflite_flutter/tflite_flutter.dart'; import 'package:tflite_flutter_helper/src/image/base_image_container.dart'; import 'package:tflite_flutter_helper/src/image/image_conversions.dart'; @@ -7,13 +7,13 @@ import 'package:tflite_flutter_helper/src/tensorbuffer/tensorbuffer.dart'; import 'package:tflite_flutter_helper/src/image/color_space_type.dart'; class ImageContainer extends BaseImageContainer { - late final Image _image; + late final img.Image _image; - ImageContainer._(Image image) { + ImageContainer._(img.Image image) { this._image = image; } - static ImageContainer create(Image image) { + static ImageContainer create(img.Image image) { return ImageContainer._(image); } @@ -24,15 +24,7 @@ class ImageContainer extends BaseImageContainer { @override ColorSpaceType get colorSpaceType { - int len = _image.data.length; - bool isGrayscale = true; - for (int i = (len / 4).floor(); i < _image.data.length; i++) { - if (_image.data[i] != 0) { - isGrayscale = false; - break; - } - } - if (isGrayscale) { + if (image.numChannels == 1) { return ColorSpaceType.GRAYSCALE; } else { return ColorSpaceType.RGB; @@ -40,7 +32,7 @@ class ImageContainer extends BaseImageContainer { } @override - TensorBuffer getTensorBuffer(TfLiteType dataType) { + TensorBuffer getTensorBuffer(TensorType dataType) { TensorBuffer buffer = TensorBuffer.createDynamic(dataType); ImageConversions.convertImageToTensorBuffer(image, buffer); return buffer; @@ -50,7 +42,7 @@ class ImageContainer extends BaseImageContainer { int get height => _image.height; @override - Image get image => _image; + img.Image get image => _image; @override CameraImage get mediaImage => throw UnsupportedError( diff --git a/lib/src/image/image_conversions.dart b/lib/src/image/image_conversions.dart index 0d911b7..d4030cf 100644 --- a/lib/src/image/image_conversions.dart +++ b/lib/src/image/image_conversions.dart @@ -1,4 +1,4 @@ -import 'package:image/image.dart'; +import 'package:image/image.dart' as img; import 'package:tflite_flutter/tflite_flutter.dart'; import 'package:tflite_flutter_helper/src/image/color_space_type.dart'; import 'package:tflite_flutter_helper/src/tensorbuffer/tensorbuffer.dart'; @@ -7,14 +7,14 @@ import 'package:tflite_flutter_helper/src/tensorbuffer/tensorbuffer.dart'; /// /// This class is an internal helper. class ImageConversions { - static Image convertRgbTensorBufferToImage(TensorBuffer buffer) { + static img.Image convertRgbTensorBufferToImage(TensorBuffer buffer) { List shape = buffer.getShape(); ColorSpaceType rgb = ColorSpaceType.RGB; rgb.assertShape(shape); int h = rgb.getHeight(shape); int w = rgb.getWidth(shape); - Image image = Image(w, h); + img.Image image = img.Image(width: w, height: h); List rgbValues = buffer.getIntList(); assert(rgbValues.length == w * h * 3); @@ -23,7 +23,7 @@ class ImageConversions { int r = rgbValues[j++]; int g = rgbValues[j++]; int b = rgbValues[j++]; - image.setPixelRgba(wi, hi, r, g, b); + image.setPixelRgba(wi, hi, r, g, b, 1); wi++; if (wi % w == 0) { wi = 0; @@ -34,45 +34,49 @@ class ImageConversions { return image; } - static Image convertGrayscaleTensorBufferToImage(TensorBuffer buffer) { + static img.Image convertGrayscaleTensorBufferToImage(TensorBuffer buffer) { // Convert buffer into Uint8 as needed. - TensorBuffer uint8Buffer = buffer.getDataType() == TfLiteType.uint8 + TensorBuffer uint8Buffer = buffer.getDataType() == TensorType.uint8 ? buffer - : TensorBuffer.createFrom(buffer, TfLiteType.uint8); + : TensorBuffer.createFrom(buffer, TensorType.uint8); final shape = uint8Buffer.getShape(); final grayscale = ColorSpaceType.GRAYSCALE; grayscale.assertShape(shape); - final image = Image.fromBytes(grayscale.getWidth(shape), - grayscale.getHeight(shape), uint8Buffer.getBuffer().asUint8List(), - format: Format.luminance); + final image = img.Image.fromBytes( + width: grayscale.getWidth(shape), + height: grayscale.getHeight(shape), + bytes: uint8Buffer.getBuffer(), + format: img.Format.uint8); return image; } - static void convertImageToTensorBuffer(Image image, TensorBuffer buffer) { + static void convertImageToTensorBuffer(img.Image image, TensorBuffer buffer) { int w = image.width; int h = image.height; - List intValues = image.data; + List pixels = image.data! + .map((pixel) => img.PixelUint8.from(pixel as img.PixelUint8)) + .toList(); int flatSize = w * h * 3; List shape = [h, w, 3]; switch (buffer.getDataType()) { - case TfLiteType.uint8: + case TensorType.uint8: List byteArr = List.filled(flatSize, 0); - for (int i = 0, j = 0; i < intValues.length; i++) { - byteArr[j++] = ((intValues[i]) & 0xFF); - byteArr[j++] = ((intValues[i] >> 8) & 0xFF); - byteArr[j++] = ((intValues[i] >> 16) & 0xFF); + for (int i = 0, j = 0; i < (w * h); i++) { + byteArr[j++] = pixels[i].r.toInt(); + byteArr[j++] = pixels[i].g.toInt(); + byteArr[j++] = pixels[i].b.toInt(); } buffer.loadList(byteArr, shape: shape); break; - case TfLiteType.float32: + case TensorType.float32: List floatArr = List.filled(flatSize, 0.0); - for (int i = 0, j = 0; i < intValues.length; i++) { - floatArr[j++] = ((intValues[i]) & 0xFF).toDouble(); - floatArr[j++] = ((intValues[i] >> 8) & 0xFF).toDouble(); - floatArr[j++] = ((intValues[i] >> 16) & 0xFF).toDouble(); + for (int i = 0, j = 0; i < (w * h); i++) { + floatArr[j++] = pixels[i].r.toDouble(); + floatArr[j++] = pixels[i].g.toDouble(); + floatArr[j++] = pixels[i].b.toDouble(); } buffer.loadList(floatArr, shape: shape); break; diff --git a/lib/src/image/ops/resize_with_crop_or_pad_op.dart b/lib/src/image/ops/resize_with_crop_or_pad_op.dart index 783920a..b8abfa4 100644 --- a/lib/src/image/ops/resize_with_crop_or_pad_op.dart +++ b/lib/src/image/ops/resize_with_crop_or_pad_op.dart @@ -25,7 +25,7 @@ class ResizeWithCropOrPadOp implements ImageOperator { /// You can pass whith [_cropLeft] and [_cropTop] top-left position of a crop to overide the default centered one. ResizeWithCropOrPadOp(this._targetHeight, this._targetWidth, [this._cropLeft, this._cropTop]) - : _output = Image(_targetWidth, _targetHeight); + : _output = Image(width: _targetWidth, height: _targetHeight); /// Applies the defined resizing with cropping or/and padding on [image] and returns the /// result. diff --git a/lib/src/image/ops/rot90_op.dart b/lib/src/image/ops/rot90_op.dart index cb51f17..be9389d 100644 --- a/lib/src/image/ops/rot90_op.dart +++ b/lib/src/image/ops/rot90_op.dart @@ -18,7 +18,7 @@ class Rot90Op extends ImageOperator { /// with the output. @override TensorImage apply(TensorImage image) { - Image rotated = copyRotate(image.image, 90 * _numRotation); + Image rotated = copyRotate(image.image, angle: 90 * _numRotation); image.loadImage(rotated); return image; } diff --git a/lib/src/image/tensor_buffer_container.dart b/lib/src/image/tensor_buffer_container.dart index 93be2c0..48c69e7 100644 --- a/lib/src/image/tensor_buffer_container.dart +++ b/lib/src/image/tensor_buffer_container.dart @@ -20,11 +20,14 @@ class TensorBufferContainer implements BaseImageContainer { /// /// @throws IllegalArgumentException if the shape of the {@link TensorBuffer} does not match the /// specified color space type, or if the color space type is not supported - static TensorBufferContainer create(TensorBuffer buffer, ColorSpaceType colorSpaceType) { + static TensorBufferContainer create( + TensorBuffer buffer, ColorSpaceType colorSpaceType) { checkArgument( - colorSpaceType == ColorSpaceType.RGB || colorSpaceType == ColorSpaceType.GRAYSCALE, - message: "Only ColorSpaceType.RGB and ColorSpaceType.GRAYSCALE are supported. Use" - + " `create(TensorBuffer, ImageProperties)` for other color space types."); + colorSpaceType == ColorSpaceType.RGB || + colorSpaceType == ColorSpaceType.GRAYSCALE, + message: + "Only ColorSpaceType.RGB and ColorSpaceType.GRAYSCALE are supported. Use" + + " `create(TensorBuffer, ImageProperties)` for other color space types."); return TensorBufferContainer._( buffer, @@ -33,12 +36,12 @@ class TensorBufferContainer implements BaseImageContainer { colorSpaceType.getWidth(buffer.getShape())); } - TensorBufferContainer._( - TensorBuffer buffer, ColorSpaceType colorSpaceType, int height, int width) { - checkArgument( - colorSpaceType != ColorSpaceType.YUV_420_888, - message: "The actual encoding format of YUV420 is required. Choose a ColorSpaceType from: NV12," - + " NV21, YV12, YV21. Use YUV_420_888 only when loading an android.media.Image."); + TensorBufferContainer._(TensorBuffer buffer, ColorSpaceType colorSpaceType, + int height, int width) { + checkArgument(colorSpaceType != ColorSpaceType.YUV_420_888, + message: + "The actual encoding format of YUV420 is required. Choose a ColorSpaceType from: NV12," + + " NV21, YV12, YV21. Use YUV_420_888 only when loading an android.media.Image."); colorSpaceType.assertNumElements(buffer.getFlatSize(), height, width); this._buffer = buffer; @@ -58,7 +61,7 @@ class TensorBufferContainer implements BaseImageContainer { @override Image get image { - if (_buffer.getDataType() != TfLiteType.uint8) { + if (_buffer.getDataType() != TfLiteType.kTfLiteUInt8) { // Print warning instead of throwing an exception. When using float models, users may want to // convert the resulting float image into Bitmap. That's fine to do so, as long as they are // aware of the potential accuracy lost when casting to uint8. @@ -72,12 +75,14 @@ class TensorBufferContainer implements BaseImageContainer { } @override - TensorBuffer getTensorBuffer(TfLiteType dataType) { + TensorBuffer getTensorBuffer(TensorType dataType) { // If the data type of buffer is desired, return it directly. Not making a defensive copy for // performance considerations. During image processing, users may need to set and get the // TensorBuffer many times. // Otherwise, create another one with the expected data type. - return _buffer.getDataType() == dataType ? _buffer : TensorBuffer.createFrom(_buffer, dataType); + return _buffer.getDataType() == dataType + ? _buffer + : TensorBuffer.createFrom(_buffer, dataType); } @override @@ -104,5 +109,4 @@ class TensorBufferContainer implements BaseImageContainer { ColorSpaceType get colorSpaceType { return _colorSpaceType; } - } diff --git a/lib/src/image/tensor_image.dart b/lib/src/image/tensor_image.dart index eb02102..64f08d2 100644 --- a/lib/src/image/tensor_image.dart +++ b/lib/src/image/tensor_image.dart @@ -29,12 +29,12 @@ import 'package:tflite_flutter_helper/src/tensorbuffer/tensorbuffer.dart'; /// See [ImageProcessor] which is often used for transforming a [TensorImage]. class TensorImage { BaseImageContainer? _container; - final TfLiteType _tfLiteType; + final TensorType _tfLiteType; /// Initialize a [TensorImage] object. /// /// Note: For Image with float value pixels use [TensorImage(TfLiteType.float)] - TensorImage([TfLiteType dataType = TfLiteType.uint8]) + TensorImage([TensorType dataType = TensorType.uint8]) : _tfLiteType = dataType; /// Initialize [TensorImage] from [Image] @@ -134,19 +134,19 @@ class TensorImage { /// Gets the current data type. /// /// Currently only UINT8 and FLOAT32 are possible. - TfLiteType get dataType { + TensorType get dataType { return _tfLiteType; } /// Gets the current data type. /// /// Currently only UINT8 and FLOAT32 are possible. - TfLiteType getDataType() => dataType; + TensorType getDataType() => dataType; /// Gets the current data type. /// /// Currently only UINT8 and FLOAT32 are possible. - TfLiteType get tfLiteType { + TensorType get tfLiteType { return _tfLiteType; } @@ -171,7 +171,7 @@ class TensorImage { /// It's essentially a short cut for [getTensorBuffer.getBuffer()]. /// /// Throws [StateError] if the TensorImage never loads data. - ByteBuffer get buffer { + ByteBuffer get buffer { return tensorBuffer.buffer; } diff --git a/lib/src/label/tensor_label.dart b/lib/src/label/tensor_label.dart index dc27901..751db17 100644 --- a/lib/src/label/tensor_label.dart +++ b/lib/src/label/tensor_label.dart @@ -93,7 +93,7 @@ class TensorLabel { "get a map requires the labels are set on the first non-1 axis."); List labels = _axisLabels[labeledAxis]!; - TfLiteType dataType = _tensorBuffer.getDataType(); + TensorType dataType = _tensorBuffer.getDataType(); int typeSize = _tensorBuffer.getTypeSize(); int flatSize = _tensorBuffer.getFlatSize(); diff --git a/lib/src/task/bindings/text/nl_classifier/bert_nl_classifier.dart b/lib/src/task/bindings/text/nl_classifier/bert_nl_classifier.dart index 71fa57a..bf2d125 100644 --- a/lib/src/task/bindings/text/nl_classifier/bert_nl_classifier.dart +++ b/lib/src/task/bindings/text/nl_classifier/bert_nl_classifier.dart @@ -9,43 +9,45 @@ import 'package:tflite_flutter_helper/src/task/bindings/dlib.dart'; // Creates BertBertNLClassifier from model path and options, returns nullptr if the // file doesn't exist or is not a well formatted TFLite model path. -Pointer Function(Pointer modelPath, - Pointer options) -BertNLClassifierFromFileAndOptions = tflitelib - .lookup>( - 'BertNLClassifierFromFileAndOptions') - .asFunction(); +Pointer Function( + Pointer modelPath, Pointer options) + BertNLClassifierFromFileAndOptions = tflitelib + .lookup>( + 'BertNLClassifierFromFileAndOptions') + .asFunction(); -typedef _BertNLClassifierFromFileAndOptions_native_t = Pointer Function( - Pointer modelPath, - Pointer options); +typedef _BertNLClassifierFromFileAndOptions_native_t + = Pointer Function(Pointer modelPath, + Pointer options); // Creates BertNLClassifier from model path and default options, returns nullptr // if the file doesn't exist or is not a well formatted TFLite model path. Pointer Function(Pointer modelPath) -BertNLClassifierFromFile = tflitelib - .lookup>( - 'BertNLClassifierFromFile') - .asFunction(); + BertNLClassifierFromFile = tflitelib + .lookup>( + 'BertNLClassifierFromFile') + .asFunction(); -typedef _BertNLClassifierFromFile_native_t = Pointer Function( - Pointer modelPath); +typedef _BertNLClassifierFromFile_native_t = Pointer + Function(Pointer modelPath); // Invokes the encapsulated TFLite model and classifies the input text. -Pointer Function(Pointer classifier, - Pointer text) -BertNLClassifierClassify = tflitelib - .lookup>( - 'BertNLClassifierClassify') - .asFunction(); +Pointer Function( + Pointer classifier, Pointer text) + BertNLClassifierClassify = tflitelib + .lookup>( + 'BertNLClassifierClassify') + .asFunction(); -typedef _BertNLClassifierClassify_native_t = Pointer Function(Pointer classifier, - Pointer text); +typedef _BertNLClassifierClassify_native_t = Pointer Function( + Pointer classifier, Pointer text); // Deletes BertNLClassifer instance -void Function(Pointer) BertNLClassifierDelete = tflitelib - .lookup>( - 'BertNLClassifierDelete') - .asFunction(); - -typedef _BertNLClassifierDelete_native_t = Void Function(Pointer); \ No newline at end of file +void Function(Pointer) BertNLClassifierDelete = + tflitelib + .lookup>( + 'BertNLClassifierDelete') + .asFunction(); + +typedef _BertNLClassifierDelete_native_t = Void Function( + Pointer); diff --git a/lib/src/task/bindings/text/nl_classifier/nl_classifer.dart b/lib/src/task/bindings/text/nl_classifier/nl_classifer.dart index 5c3f47c..a58648e 100644 --- a/lib/src/task/bindings/text/nl_classifier/nl_classifer.dart +++ b/lib/src/task/bindings/text/nl_classifier/nl_classifer.dart @@ -9,32 +9,32 @@ import 'package:tflite_flutter_helper/src/task/bindings/dlib.dart'; // Creates NLClassifier from model path and options, returns nullptr if the file // doesn't exist or is not a well formatted TFLite model path. -Pointer Function(Pointer modelPath, - Pointer options) -NLClassifierFromFileAndOptions = tflitelib - .lookup>( - 'NLClassifierFromFileAndOptions') - .asFunction(); +Pointer Function( + Pointer modelPath, Pointer options) + NLClassifierFromFileAndOptions = tflitelib + .lookup>( + 'NLClassifierFromFileAndOptions') + .asFunction(); -typedef _NLClassifierFromFileAndOptions_native_t = Pointer Function( - Pointer modelPath, - Pointer options); +typedef _NLClassifierFromFileAndOptions_native_t + = Pointer Function( + Pointer modelPath, Pointer options); // Invokes the encapsulated TFLite model and classifies the input text. -Pointer Function(Pointer classifier, - Pointer text) -NLClassifierClassify = tflitelib - .lookup>( - 'NLClassifierClassify') - .asFunction(); +Pointer Function( + Pointer classifier, Pointer text) + NLClassifierClassify = tflitelib + .lookup>( + 'NLClassifierClassify') + .asFunction(); -typedef _NLClassifierClassify_native_t = Pointer Function(Pointer classifier, - Pointer text); +typedef _NLClassifierClassify_native_t = Pointer Function( + Pointer classifier, Pointer text); // Deletes NLClassifer instance void Function(Pointer) NLClassifierDelete = tflitelib - .lookup>( - 'NLClassifierDelete') + .lookup>('NLClassifierDelete') .asFunction(); -typedef _NLClassifierDelete_native_t = Void Function(Pointer); \ No newline at end of file +typedef _NLClassifierDelete_native_t = Void Function( + Pointer); diff --git a/lib/src/task/bindings/text/nl_classifier/types.dart b/lib/src/task/bindings/text/nl_classifier/types.dart index 94902df..5ce2fa4 100644 --- a/lib/src/task/bindings/text/nl_classifier/types.dart +++ b/lib/src/task/bindings/text/nl_classifier/types.dart @@ -2,9 +2,9 @@ import 'dart:ffi'; import 'package:ffi/ffi.dart'; -class TfLiteNLClassifier extends Opaque {} +final class TfLiteNLClassifier extends Opaque {} -class TfLiteNLClassifierOptions extends Struct { +final class TfLiteNLClassifierOptions extends Struct { @Int32() external int inputTensorIndex; @@ -40,23 +40,23 @@ class TfLiteNLClassifierOptions extends Struct { } } -class TfLiteCategories extends Struct { +final class TfLiteCategories extends Struct { @Int32() external int size; external Pointer categories; } -class TfLiteCategory extends Struct { +final class TfLiteCategory extends Struct { external Pointer text; @Double() external double score; } -class TfLiteBertNLClassifier extends Opaque {} +final class TfLiteBertNLClassifier extends Opaque {} -class TfLiteBertNLClassifierOptions extends Struct { +final class TfLiteBertNLClassifierOptions extends Struct { @Int32() external int maxSeqLen; diff --git a/lib/src/task/bindings/text/qa/bert_qa.dart b/lib/src/task/bindings/text/qa/bert_qa.dart index e0ac8ab..c0f87a0 100644 --- a/lib/src/task/bindings/text/qa/bert_qa.dart +++ b/lib/src/task/bindings/text/qa/bert_qa.dart @@ -10,38 +10,47 @@ import 'package:tflite_flutter_helper/src/task/bindings/dlib.dart'; // Creates BertQuestionAnswerer from model path, returns nullptr if the file // doesn't exist or is not a well formatted TFLite model path. Pointer Function(Pointer modelPath) -BertQuestionAnswererFromFile = tflitelib - .lookup>( - 'BertQuestionAnswererFromFile') - .asFunction(); + BertQuestionAnswererFromFile = tflitelib + .lookup>( + 'BertQuestionAnswererFromFile') + .asFunction(); -typedef _BertQuestionAnswererFromFile_native_t = Pointer Function( - Pointer modelPath); +typedef _BertQuestionAnswererFromFile_native_t + = Pointer Function(Pointer modelPath); // Invokes the encapsulated TFLite model and answers a question based on // context. -Pointer Function(Pointer questionAnswerer, - Pointer context, Pointer question) -BertQuestionAnswererAnswer = tflitelib - .lookup>( - 'BertQuestionAnswererAnswer') - .asFunction(); - -typedef _BertQuestionAnswererAnswer_native_t = Pointer Function(Pointer questionAnswerer, - Pointer context, Pointer question); +Pointer Function( + Pointer questionAnswerer, + Pointer context, + Pointer question) BertQuestionAnswererAnswer = + tflitelib + .lookup>( + 'BertQuestionAnswererAnswer') + .asFunction(); + +typedef _BertQuestionAnswererAnswer_native_t + = Pointer Function( + Pointer questionAnswerer, + Pointer context, + Pointer question); // Deletes BertQuestionAnswerer instance -void Function(Pointer) BertQuestionAnswererDelete = tflitelib - .lookup>( - 'BertQuestionAnswererDelete') - .asFunction(); +void Function(Pointer) BertQuestionAnswererDelete = + tflitelib + .lookup>( + 'BertQuestionAnswererDelete') + .asFunction(); -typedef _BertQuestionAnswererDelete_native_t = Void Function(Pointer); +typedef _BertQuestionAnswererDelete_native_t = Void Function( + Pointer); // Deletes BertQuestionAnswererQaAnswers instance -void Function(Pointer) BertQuestionAnswererQaAnswersDelete = tflitelib - .lookup>( - 'BertQuestionAnswererQaAnswersDelete') - .asFunction(); - -typedef _BertQuestionAnswererQaAnswersDelete_native_t = Void Function(Pointer); +void Function(Pointer) BertQuestionAnswererQaAnswersDelete = + tflitelib + .lookup>( + 'BertQuestionAnswererQaAnswersDelete') + .asFunction(); + +typedef _BertQuestionAnswererQaAnswersDelete_native_t = Void Function( + Pointer); diff --git a/lib/src/task/bindings/text/qa/types.dart b/lib/src/task/bindings/text/qa/types.dart index 0f7255d..dcfb676 100644 --- a/lib/src/task/bindings/text/qa/types.dart +++ b/lib/src/task/bindings/text/qa/types.dart @@ -2,9 +2,9 @@ import 'dart:ffi'; import 'package:ffi/ffi.dart'; -class TfLiteBertQuestionAnswerer extends Opaque {} +final class TfLiteBertQuestionAnswerer extends Opaque {} -class TfLiteQaAnswer extends Struct { +final class TfLiteQaAnswer extends Struct { @Int32() external int start; @Int32() @@ -15,7 +15,7 @@ class TfLiteQaAnswer extends Struct { external Pointer text; } -class TfLiteQaAnswers extends Struct { +final class TfLiteQaAnswers extends Struct { @Int32() external int size; diff --git a/lib/src/task/text/nl_classifier/bert_nl_classifier_options.dart b/lib/src/task/text/nl_classifier/bert_nl_classifier_options.dart index 3b90bc0..c64eff2 100644 --- a/lib/src/task/text/nl_classifier/bert_nl_classifier_options.dart +++ b/lib/src/task/text/nl_classifier/bert_nl_classifier_options.dart @@ -16,7 +16,8 @@ class BertNLClassifierOptions { /// Creates a new options instance. factory BertNLClassifierOptions() { - final optionsPtr = TfLiteBertNLClassifierOptions.allocate(DEFAULT_MAX_SEQ_LEN); + final optionsPtr = + TfLiteBertNLClassifierOptions.allocate(DEFAULT_MAX_SEQ_LEN); return BertNLClassifierOptions._(optionsPtr); } diff --git a/lib/src/tensorbuffer/tensorbuffer.dart b/lib/src/tensorbuffer/tensorbuffer.dart index 7435c18..925734d 100644 --- a/lib/src/tensorbuffer/tensorbuffer.dart +++ b/lib/src/tensorbuffer/tensorbuffer.dart @@ -30,30 +30,30 @@ abstract class TensorBuffer { /// ```dart /// Creating a float TensorBuffer with shape [2, 3]: /// List shape = [2, 3]; - /// TensorBuffer tensorBuffer = TensorBuffer.createFixedSize(shape, TfLiteType.float32); + /// TensorBuffer tensorBuffer = TensorBuffer.createFixedSize(shape, TfLiteType.kTfLiteFloat32); /// ``` /// /// ```dart /// Creating an uint8 TensorBuffer of a scalar: /// List shape = [2, 3]; - /// TensorBuffer tensorBuffer = TensorBuffer.createFixedSize(shape, TfLiteType.uint8); + /// TensorBuffer tensorBuffer = TensorBuffer.createFixedSize(shape, TfLiteType.kTfLiteUInt8); /// ``` /// /// ```dart /// Creating an empty uint8 TensorBuffer: /// List shape = [0]; - /// TensorBuffer tensorBuffer = TensorBuffer.createFixedSize(shape, TfLiteType.uint8); + /// TensorBuffer tensorBuffer = TensorBuffer.createFixedSize(shape, TfLiteType.kTfLiteUInt8); /// ``` /// /// The size of a fixed-size TensorBuffer cannot be changed once it is created. /// /// Throws [ArgumentError.notNull] if [shape] is null and /// [ArgumentError] is [shape] has non-positive elements. - static TensorBuffer createFixedSize(List shape, TfLiteType dataType) { + static TensorBuffer createFixedSize(List shape, TensorType dataType) { switch (dataType) { - case TfLiteType.float32: + case TensorType.float32: return TensorBufferFloat(shape); - case TfLiteType.uint8: + case TensorType.uint8: return TensorBufferUint8(shape); default: throw ArgumentError( @@ -68,11 +68,11 @@ abstract class TensorBuffer { /// /// Dynamic TensorBuffers will reallocate memory when loading arrays or data buffers of /// different buffer sizes. - static TensorBuffer createDynamic(TfLiteType dataType) { + static TensorBuffer createDynamic(TensorType dataType) { switch (dataType) { - case TfLiteType.float32: + case TensorType.float32: return TensorBufferFloat.dynamic(); - case TfLiteType.uint8: + case TensorType.uint8: return TensorBufferUint8.dynamic(); default: throw ArgumentError( @@ -83,7 +83,7 @@ abstract class TensorBuffer { /// Creates a [TensorBuffer] deep-copying data from another, with specified [TfLiteType]. /// /// Throws [ArgumentError.notNull] if [buffer] is null. - static TensorBuffer createFrom(TensorBuffer buffer, TfLiteType dataType) { + static TensorBuffer createFrom(TensorBuffer buffer, TensorType dataType) { SupportPreconditions.checkNotNull(buffer, message: "Cannot create a buffer from null"); TensorBuffer result; @@ -95,8 +95,8 @@ abstract class TensorBuffer { // The only scenario we need float array is FLOAT32->FLOAT32, or we can always use INT as // intermediate container. // The assumption is not true when we support other data types. - if (buffer.getDataType() == TfLiteType.float32 && - dataType == TfLiteType.float32) { + if (buffer.getDataType() == TfLiteType.kTfLiteFloat32 && + dataType == TfLiteType.kTfLiteFloat32) { List data = buffer.getDoubleList(); result.loadList(data, shape: buffer.shape); } else { @@ -119,7 +119,7 @@ abstract class TensorBuffer { List getShape() => shape; /// Returns the data type of this buffer. - TfLiteType getDataType(); + TensorType getDataType(); /// Returns a List of the values stored in this buffer. If the buffer is of different types /// than double, the values will be converted into double. For example, values in diff --git a/lib/src/tensorbuffer/tensorbufferfloat.dart b/lib/src/tensorbuffer/tensorbufferfloat.dart index 3f2c961..09a5923 100644 --- a/lib/src/tensorbuffer/tensorbufferfloat.dart +++ b/lib/src/tensorbuffer/tensorbufferfloat.dart @@ -5,7 +5,7 @@ import 'tensorbuffer.dart'; /// Represents data buffer with float(double) values. class TensorBufferFloat extends TensorBuffer { - static const TfLiteType DATA_TYPE = TfLiteType.float32; + static const TensorType DATA_TYPE = TensorType.float32; /// Creates a [TensorBufferFloat] with specified [shape]. /// @@ -15,7 +15,7 @@ class TensorBufferFloat extends TensorBuffer { TensorBufferFloat.dynamic() : super.dynamic(); @override - TfLiteType getDataType() { + TensorType getDataType() { return DATA_TYPE; } diff --git a/lib/src/tensorbuffer/tensorbufferuint8.dart b/lib/src/tensorbuffer/tensorbufferuint8.dart index 48fa345..df026f3 100644 --- a/lib/src/tensorbuffer/tensorbufferuint8.dart +++ b/lib/src/tensorbuffer/tensorbufferuint8.dart @@ -14,8 +14,8 @@ class TensorBufferUint8 extends TensorBuffer { TensorBufferUint8.dynamic() : super.dynamic(); @override - TfLiteType getDataType() { - return TfLiteType.uint8; + TensorType getDataType() { + return TensorType.uint8; } @override diff --git a/linux/include/tflite_flutter_helper/tflite_flutter_helper_plugin.h b/linux/include/tflite_flutter_processing/tflite_flutter_processing_plugin.h similarity index 100% rename from linux/include/tflite_flutter_helper/tflite_flutter_helper_plugin.h rename to linux/include/tflite_flutter_processing/tflite_flutter_processing_plugin.h diff --git a/pubspec.lock b/pubspec.lock index def05b8..b665298 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,215 +5,313 @@ packages: dependency: transitive description: name: archive - url: "https://pub.dartlang.org" + sha256: "22600aa1e926be775fa5fe7e6894e7fb3df9efda8891c73f70fb3262399a432d" + url: "https://pub.dev" source: hosted - version: "3.1.2" + version: "3.4.10" async: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" source: hosted - version: "2.6.1" + version: "2.11.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" camera: dependency: "direct main" description: name: camera - url: "https://pub.dartlang.org" + sha256: "2170a943dcb67be2af2c6bcda8775e74b41d4c02d6a4eb10bdc832ee185c4eea" + url: "https://pub.dev" + source: hosted + version: "0.11.0+1" + camera_android_camerax: + dependency: transitive + description: + name: camera_android_camerax + sha256: "7c03940cb8c92eb5b184952674a07cc4a73c6ba2b3568aad70255ad4cb913660" + url: "https://pub.dev" + source: hosted + version: "0.6.7+1" + camera_avfoundation: + dependency: transitive + description: + name: camera_avfoundation + sha256: "95c2f40b4d06cdb0fd2ad893c762d1f2c931a5e370793ec34c939eb4fcbf96bb" + url: "https://pub.dev" source: hosted - version: "0.8.1+7" + version: "0.9.17" camera_platform_interface: dependency: transitive description: name: camera_platform_interface - url: "https://pub.dartlang.org" + sha256: fceb2c36038b6392317b1d5790c6ba9e6ca9f1da3031181b8bea03882bf9387a + url: "https://pub.dev" source: hosted - version: "2.1.0" - characters: + version: "2.7.3" + camera_web: dependency: transitive description: - name: characters - url: "https://pub.dartlang.org" + name: camera_web + sha256: b9235ec0a2ce949daec546f1f3d86f05c3921ed31c7d9ab6b7c03214d152fc2d + url: "https://pub.dev" source: hosted - version: "1.1.0" - charcode: + version: "0.3.4" + characters: dependency: transitive description: - name: charcode - url: "https://pub.dartlang.org" + name: characters + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.0" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + url: "https://pub.dev" + source: hosted + version: "1.18.0" + convert: + dependency: transitive + description: + name: convert + sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" + url: "https://pub.dev" source: hosted - version: "1.15.0" + version: "3.1.1" cross_file: dependency: transitive description: name: cross_file - url: "https://pub.dartlang.org" + sha256: "74a4727e030347edff3b6e5256b7fb0c3de8af8ed278e6c56718760786a1fa40" + url: "https://pub.dev" source: hosted - version: "0.3.1+4" + version: "0.3.4" crypto: dependency: transitive description: name: crypto - url: "https://pub.dartlang.org" + sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab + url: "https://pub.dev" source: hosted - version: "3.0.1" + version: "3.0.3" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.1" ffi: dependency: "direct main" description: name: ffi - url: "https://pub.dartlang.org" + sha256: "493f37e7df1804778ff3a53bd691d8692ddf69702cf4c1c1096a2e41b4779e21" + url: "https://pub.dev" source: hosted - version: "1.1.2" - file: - dependency: transitive - description: - name: file - url: "https://pub.dartlang.org" - source: hosted - version: "6.1.2" + version: "2.1.2" flutter: dependency: "direct main" description: flutter source: sdk version: "0.0.0" + flutter_plugin_android_lifecycle: + dependency: transitive + description: + name: flutter_plugin_android_lifecycle + sha256: b068ffc46f82a55844acfa4fdbb61fad72fa2aef0905548419d97f0f95c456da + url: "https://pub.dev" + source: hosted + version: "2.0.17" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" image: dependency: "direct main" description: name: image - url: "https://pub.dartlang.org" + sha256: "2237616a36c0d69aef7549ab439b833fb7f9fb9fc861af2cc9ac3eedddd69ca8" + url: "https://pub.dev" source: hosted - version: "3.0.2" + version: "4.2.0" + js: + dependency: transitive + description: + name: js + sha256: c1b2e9b5ea78c45e1a0788d29606ba27dc5f71f019f32ca5140f61ef071838cf + url: "https://pub.dev" + source: hosted + version: "0.7.1" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" + url: "https://pub.dev" + source: hosted + version: "10.0.4" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" + url: "https://pub.dev" + source: hosted + version: "3.0.3" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" + url: "https://pub.dev" + source: hosted + version: "3.0.1" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb + url: "https://pub.dev" + source: hosted + version: "0.12.16+1" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" + url: "https://pub.dev" source: hosted - version: "0.12.10" + version: "0.8.0" meta: dependency: "direct main" description: name: meta - url: "https://pub.dartlang.org" + sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" + url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.12.0" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" + url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.9.0" path_provider: dependency: "direct main" description: name: path_provider - url: "https://pub.dartlang.org" + sha256: c9e7d3a4cd1410877472158bee69963a4579f78b68c65a2b7d40d1a7a88bb161 + url: "https://pub.dev" source: hosted - version: "2.0.2" - path_provider_linux: + version: "2.1.3" + path_provider_android: dependency: transitive description: - name: path_provider_linux - url: "https://pub.dartlang.org" + name: path_provider_android + sha256: "477184d672607c0a3bf68fbbf601805f92ef79c82b64b4d6eb318cbca4c48668" + url: "https://pub.dev" source: hosted - version: "2.0.2" - path_provider_macos: + version: "2.2.2" + path_provider_foundation: dependency: transitive description: - name: path_provider_macos - url: "https://pub.dartlang.org" + name: path_provider_foundation + sha256: "5a7999be66e000916500be4f15a3633ebceb8302719b47b9cc49ce924125350f" + url: "https://pub.dev" source: hosted - version: "2.0.2" + version: "2.3.2" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279 + url: "https://pub.dev" + source: hosted + version: "2.2.1" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface - url: "https://pub.dartlang.org" + sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334" + url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.1.2" path_provider_windows: dependency: transitive description: name: path_provider_windows - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.3" - pedantic: - dependency: transitive - description: - name: pedantic - url: "https://pub.dartlang.org" + sha256: "8bc9f22eee8690981c22aa7fc602f5c85b497a6fb2ceb35ee5a5e5ed85ad8170" + url: "https://pub.dev" source: hosted - version: "1.11.1" + version: "2.2.1" petitparser: dependency: transitive description: name: petitparser - url: "https://pub.dartlang.org" + sha256: c15605cd28af66339f8eb6fbe0e541bfe2d1b72d5825efc6598f3e0a31b9ad27 + url: "https://pub.dev" source: hosted - version: "4.1.0" + version: "6.0.2" platform: dependency: transitive description: name: platform - url: "https://pub.dartlang.org" + sha256: "12220bb4b65720483f8fa9450b4332347737cf8213dd2840d8b2c823e47243ec" + url: "https://pub.dev" source: hosted - version: "3.0.2" + version: "3.1.4" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface - url: "https://pub.dartlang.org" + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" + url: "https://pub.dev" source: hosted - version: "2.0.1" - process: + version: "2.1.8" + pointycastle: dependency: transitive description: - name: process - url: "https://pub.dartlang.org" + name: pointycastle + sha256: "43ac87de6e10afabc85c445745a7b799e04de84cebaa4fd7bf55a5e1e9604d29" + url: "https://pub.dev" source: hosted - version: "4.2.3" + version: "3.7.4" quiver: dependency: "direct main" description: name: quiver - url: "https://pub.dartlang.org" + sha256: b1c1ac5ce6688d77f65f3375a9abb9319b3cb32486bdc7a1e0fdf004d7ba4e47 + url: "https://pub.dev" source: hosted - version: "3.0.1" + version: "3.2.1" sky_engine: dependency: transitive description: flutter @@ -223,100 +321,130 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" source: hosted - version: "1.8.1" + version: "1.10.0" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.2" stream_transform: dependency: transitive description: name: stream_transform - url: "https://pub.dartlang.org" + sha256: "14a00e794c7c11aa145a170587321aedce29769c08d7f58b1d141da75e3b1c6f" + url: "https://pub.dev" source: hosted - version: "2.0.0" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.2.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" + url: "https://pub.dev" source: hosted - version: "0.3.0" + version: "0.7.0" tflite_flutter: dependency: "direct main" description: name: tflite_flutter - url: "https://pub.dartlang.org" + sha256: ffb8651fdb116ab0131d6dc47ff73883e0f634ad1ab12bb2852eef1bbeab4a6a + url: "https://pub.dev" source: hosted - version: "0.9.0" + version: "0.10.4" tuple: dependency: "direct main" description: name: tuple - url: "https://pub.dartlang.org" + sha256: a97ce2013f240b2f3807bcbaf218765b6f301c3eff91092bcfa23a039e7dd151 + url: "https://pub.dev" source: hosted - version: "2.0.0" + version: "2.0.2" typed_data: dependency: transitive description: name: typed_data - url: "https://pub.dartlang.org" + sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c + url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.3.2" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.dartlang.org" + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.4" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" + url: "https://pub.dev" + source: hosted + version: "14.2.1" + web: + dependency: transitive + description: + name: web + sha256: "1d9158c616048c38f712a6646e317a3426da10e884447626167240d45209cbad" + url: "https://pub.dev" + source: hosted + version: "0.5.0" win32: dependency: transitive description: name: win32 - url: "https://pub.dartlang.org" + sha256: "464f5674532865248444b4c3daca12bd9bf2d7c47f759ce2617986e7229494a8" + url: "https://pub.dev" source: hosted - version: "2.2.5" + version: "5.2.0" xdg_directories: dependency: transitive description: name: xdg_directories - url: "https://pub.dartlang.org" + sha256: faea9dee56b520b55a566385b84f2e8de55e7496104adada9962e0bd11bcff1d + url: "https://pub.dev" source: hosted - version: "0.2.0" + version: "1.0.4" xml: dependency: transitive description: name: xml - url: "https://pub.dartlang.org" + sha256: b015a8ad1c488f66851d762d3090a21c600e479dc75e68328c52774040cf9226 + url: "https://pub.dev" source: hosted - version: "5.1.2" + version: "6.5.0" sdks: - dart: ">=2.13.0 <3.0.0" - flutter: ">=2.0.0" + dart: ">=3.4.0 <4.0.0" + flutter: ">=3.22.0" diff --git a/pubspec.yaml b/pubspec.yaml index 5877a7d..f547aad 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,36 +1,32 @@ name: tflite_flutter_helper description: Easy, fast processing and manipulation input and output of TensorFlow Lite Models. -version: 0.3.0 -homepage: https://www.github.com/am15h/tflite_flutter_helper +version: 0.4.0 +homepage: https://www.github.com/xmartlabs/tflite_flutter_helper environment: - sdk: ">=2.12.0 <3.0.0" - flutter: ">=1.10.0" + sdk: ">=3.0.0 <4.0.0" + flutter: ">=3.22.0" dependencies: flutter: sdk: flutter - meta: ^1.1.8 - quiver: ^3.0.1 - path_provider: ^2.0.1 - tflite_flutter: ^0.9.0 - tuple: ^2.0.0 - camera: ^0.8.1+3 - ffi: ^1.0.0 - image: ^3.0.2 + meta: ^1.12.0 + quiver: ^3.2.1 + path_provider: ^2.1.3 + tflite_flutter: ^0.10.4 + tuple: ^2.0.2 + camera: ^0.11.0+1 + ffi: ^2.1.2 + image: ^4.2.0 dev_dependencies: flutter_test: sdk: flutter -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec - -# The following section is specific to Flutter. flutter: plugin: platforms: android: - package: com.tfliteflutter.tflite_flutter_helper + package: com.xmartlabs.tflite_flutter_helper pluginClass: TfliteFlutterHelperPlugin ios: pluginClass: TfliteFlutterHelperPlugin @@ -40,33 +36,3 @@ flutter: pluginClass: TfliteFlutterHelperPlugin windows: pluginClass: TfliteFlutterHelperPlugin - # To add assets to your package, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - # - # For details regarding assets in packages, see - # https://flutter.dev/assets-and-images/#from-packages - # - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware. - - # To add custom fonts to your package, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts in packages, see - # https://flutter.dev/custom-fonts/#from-packages diff --git a/test/tfliteflutterhelper_test.dart b/test/tfliteflutterhelper_test.dart index badd810..4470e15 100644 --- a/test/tfliteflutterhelper_test.dart +++ b/test/tfliteflutterhelper_test.dart @@ -36,7 +36,7 @@ void main() { test('static', () { late TensorBuffer tensorBuffer = - TensorBuffer.createFixedSize([1, 3, 2], TfLiteType.uint8); + TensorBuffer.createFixedSize([1, 3, 2], TensorType.uint8); ByteBuffer buffer = Uint8List.fromList([1, 2, 3, 4, 5, 6]).buffer; tensorBuffer.loadBuffer(buffer); expect(tensorBuffer.getIntList(), [1, 2, 3, 4, 5, 6]); @@ -82,7 +82,7 @@ void main() { test('static', () { late TensorBuffer tensorBuffer = - TensorBuffer.createFixedSize([1, 2, 2], TfLiteType.float32); + TensorBuffer.createFixedSize([1, 2, 2], TensorType.float32); var bdata = ByteData(16); for (int i = 0, j = 1; i < 16; i += 4, j++) @@ -96,7 +96,7 @@ void main() { test('load list int', () { late TensorBuffer tensorBuffer = - TensorBuffer.createFixedSize([1, 2, 2], TfLiteType.float32); + TensorBuffer.createFixedSize([1, 2, 2], TensorType.float32); tensorBuffer.loadList([1, 2, 3, 4], shape: [1, 2, 2]); expect(tensorBuffer.getDoubleList(), [1, 2, 3, 4]); @@ -105,7 +105,7 @@ void main() { test('load list float', () { late TensorBuffer tensorBuffer = - TensorBuffer.createFixedSize([1, 2, 2], TfLiteType.float32); + TensorBuffer.createFixedSize([1, 2, 2], TensorType.float32); tensorBuffer.loadList([1.0, 2.0, 3.0, 4.0], shape: [1, 2, 2]); expect(tensorBuffer.getDoubleList(), [1.0, 2.0, 3.0, 4.0]); @@ -124,7 +124,7 @@ void main() { group('ops', () { test('normalize', () { late TensorBuffer tensorBuffer = - TensorBuffer.createFixedSize([3], TfLiteType.float32); + TensorBuffer.createFixedSize([3], TensorType.float32); tensorBuffer.loadList([0, 255, 127.5], shape: [3]); final processor = @@ -160,8 +160,8 @@ void main() { test('load pixels', () { late TensorImage tensorImage = TensorImage(); - tensorImage.loadRgbPixels( - image.getBytes(format: Format.rgb), [inputHeight, inputWidth, 3]); + tensorImage.loadRgbPixels(image.getBytes(order: ChannelOrder.rgb), + [inputHeight, inputWidth, 3]); expect(tensorImage.image.height, inputHeight); expect(tensorImage.image.width, inputWidth); @@ -181,9 +181,9 @@ void main() { tensorbuffer = tensorImage.tensorBuffer; expect(tensorbuffer, isNotNull); expect(tensorbuffer.getFlatSize(), - image.getBytes(format: Format.rgb).length); + image.getBytes(order: ChannelOrder.rgb).length); expect(tensorbuffer.getIntList().length, - image.getBytes(format: Format.rgb).length); + image.getBytes(order: ChannelOrder.rgb).length); }); test('fromTensorBuffer', () {