shaqian / flutter_tflite Goto Github PK
View Code? Open in Web Editor NEWFlutter plugin for TensorFlow Lite
Home Page: https://pub.dartlang.org/packages/tflite
License: MIT License
Flutter plugin for TensorFlow Lite
Home Page: https://pub.dartlang.org/packages/tflite
License: MIT License
dragon_labels_33.txt
Resnet20_0_to_20.tflite.zip
data20_mini.zip
I have made a couple of tf model to recognise numbers.
After converting to tflite, saving and loading back into python, I benchmark them in python and get classification accuracies of >99%.
If I load that same tflite model into a flutter app and benchmark it there on the same data I get accuracies of around 10 - 60 % on the same images.
I have noticed that deeper networks seem more affected by this than shallow networks.
Shallower networks that benchmark at around 96% in python, get around 75 ish percent in flutter and the Deeper Resnet based model (which I will try to attach somehow) which benchmarks at >99% only gets around 60ish % on the phone, for a 21 class classification (0-20).
The model has three one-hot outputs with len=11 (0-9 +nan), with correspond to 100's 10's and 1's.
My python benchmarking code is as follows:
import numpy as np
import tensorflow as tf
from glob import glob
from random import shuffle
from PIL import Image
def reverse_one_hot(one_hot):
one_hot = one_hot.reshape(3,11)
categories = [' ','0','1','2','3','4','5','6','7','8','9']
ix0 = one_hot[0].tolist().index(1)
ix1 = one_hot[1].tolist().index(1)
ix2 = one_hot[2].tolist().index(1)
res = categories[ix0]+categories[ix1]+categories[ix2]
return res
tf_lite_model_name = 'tflite_models/Resnet20_0_to_20.tflite'
file_list = glob('/data20/*/*.png')
shuffle(file_list)
interpreter = tf.compat.v2.lite.Interpreter(model_path=tf_lite_model_name)
interpreter.allocate_tensors()
# Get input and output tensors.
input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()
# Test model on random input data.
input_shape = input_details[0]['shape']
print(f'input tensor shape: {input_shape}')
files = file_list
shuffle(files)
incorrect_classes = []
all_classes = []
n_correct = 0
n_incorrect = 0
for ix, file in enumerate(files):
img = Image.open(file)
img = img.resize((48, 48))
np_img = np.array(img, dtype=np.float32).reshape(*input_shape)
img_mean = np.mean(np_img)
img_std = np.std(np_img)
np_img = np_img/255
interpreter.set_tensor(input_details[0]['index'], np_img)
interpreter.invoke()
output_data = interpreter.get_tensor(output_details[0]['index'])
output_data = (output_data>0.5).astype(int)
try:
res = reverse_one_hot(output_data)
except:
continue
lable = file.split('/')[-2].rjust(3)
if res==' ':
res = 'nan'
if res == lable:
n_correct = n_correct+1
else:
n_incorrect = n_incorrect+1
acc = n_correct/(n_correct+n_incorrect)
print(f'\r ix:{ix} acc: {acc}',end='')
The flutter benchmarking is a bit more involved, but at it's core looks as follows:
for (String imgPath in dataMap.keys) {
String trueLabel = dataMap[imgPath];
var recognitions = await Tflite.runModelOnImage(
path: imgPath, // required
imageMean: imgMean, // defaults to 117.0
imageStd: imgStd, // defaults to 1.0
numResults: 3, // defaults to 5
threshold: 0.2, // defaults to 0.1
asynch: true // defaults to true
);
if (recognitions.length != 3){
print('model returned weird length');
return;
}
if (recognitions.length > 0) {
int p0 = int.parse(recognitions[0]['label']);
int p1 = int.parse(recognitions[1]['label']);
int p2 = int.parse(recognitions[2]['label']);
int intRes = p0+p1+p2;
String result = intRes.toString();
// String result = recognitions[0]['label'];
if (result == trueLabel) {
countTrue++;
oneIfTrue = 1;
} else {
countFalse++;
oneIfTrue = 0;
}
bloc.addInt(oneIfTrue);
}
print('accuracy = ${countTrue / (countTrue + countFalse)}');
// break;
}
I have tried various combinations of imageMean
and imageStd
. I'm a bit out of my depth here, any help would be greatly appreciated.
E
This plugin is awesome! Any plans to update it to support YoloV3-Tiny networks?
Thanks!
`Launching lib/main.dart on Kent Hinson’s iPhone in debug mode...
Automatically signing iOS for device deployment using specified development team in Xcode project: L2F5C82287
Xcode build done. 1.8s
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **
Xcode's output:
↳
=== BUILD TARGET image_picker OF PROJECT Pods WITH CONFIGURATION Debug ===
/Users/kent/Desktop/mlTest/flutter_tflite/ios/Classes/TflitePlugin.mm:19:10: fatal error: 'tensorflow/lite/kernels/register.h' file not found
#include "tensorflow/lite/kernels/register.h"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Could not build the precompiled application for the device.
Error launching application on Kent Hinson’s iPhone.
`
Hello, I want to implement MNIST, I've based the implementation on this repo and the examples posted here, but I have issues getting the predictions, I think the problem is about the input format but I've tried with some configuration and I'm unable to get good results, can you help me with this?
Could you write a little bit more about the installation?
Seems like I missed some requirements for using this package.
I'm now trying to use tflite models in flutter apps. The model which I've used is the ssd mobilenet model in your "flutter_realtime_detection" application. Almost all the code that I've done is based on yours. Even then the IllegalArgumentException occurs. I don't know from where the error originates. Please help me out.
camera.txt
Hi guys.
I'm making an app using the flutter.
I'd like to experiment with a variety of deep learning algorithms using the flutter tf-lite, do you know how?
(for example, image segmentation, landmark detection, etc..)
If there is any method or related material, please let me know.
Thanks, Regard.
Is it possible at least for Linux? :)
Hi
I'm trying to use this package, but I cant get the app to build
^
12 warnings generated.
=== BUILD TARGET Runner OF PROJECT Runner WITH CONFIGURATION Debug ===
ld: targeted OS version does not support use of thread local variables in
__ZN14EigenForTFLite26NonBlockingThreadPoolTemplINS_20StlThreadEnvironmentEE8ScheduleENSt3__18functionIFvvEEE for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Could not build the application for the simulator.
Error launching application on iPhone XR.
Any idea what I'm doing wrong? Let me know if there's any other info I can share to help you debug.
Here's how my pubspec.yaml
file looks like -
name: awesomeapp
description: some desc
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# Read more about versioning at semver.org.
version: 1.0.0+1
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cloud_firestore: "^0.8.2+1"
flutter_slidable: "^0.4.9"
camera: "0.2.4"
path_provider: ^0.4.1
video_player: ^0.5.2
firebase_core: "^0.2.5+1"
firebase_storage: ^1.0.4
http: ^0.12.0
timeago: ^2.0.9
image_picker: ^0.4.10
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
dev_dependencies:
flutter_test:
sdk: flutter
tflite:
path: ../flutter_tflite/
# 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.
uses-material-design: true
assets:
- assets/labels.txt
- assets/mobilenet_v1_1.0_224.tflite
- images/
How to use this plugin to load and use 2 models within the same app?
I am trying to do Image Classification for every frame. I have this code:
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:camera/camera.dart';
import 'package:tflite/tflite.dart';
List<CameraDescription> cameras;
Future<void> main() async {
cameras = await availableCameras();
runApp(CameraApp());
}
class CameraApp extends StatefulWidget {
@override
_CameraAppState createState() => _CameraAppState();
}
class _CameraAppState extends State<CameraApp> {
CameraController controller;
bool isDetecting = false;
bool tfLoaded = false;
@override
void initState() {
super.initState();
loadTensorFlow();
loadCamera();
}
void loadCamera(){
if (cameras == null || cameras.length < 1) {
print('No camera is found');
} else {
controller = CameraController(cameras[0], ResolutionPreset.high);
controller.initialize().then((_) {
if (!mounted) return;
setState(() {});
controller.startImageStream((CameraImage img) {
if (isDetecting) return;
if (!tfLoaded) return;
isDetecting = true;
try {
int startTime = new DateTime.now().millisecondsSinceEpoch;
print("Camera format ${img.format.group}");
Tflite.runModelOnFrame(
bytesList: img.planes.map((plane) {return plane.bytes;}).toList(),
imageHeight: img.height,
imageWidth: img.width,
imageMean: 127.5, // defaults to 127.5
imageStd: 127.5, // defaults to 127.5
rotation: 90, // defaults to 90, Android only
numResults: 2, // defaults to 5
threshold: 0.1, // defaults to 0.1
asynch: true // defaults to true
).then((recognitions) {
print("Recognitions: $recognitions");
print("Detection took ${new DateTime.now().millisecondsSinceEpoch - startTime}");
isDetecting = false;
});
} catch (e) {
print(e);
isDetecting = false;
}
});
});
}
}
@override
void dispose() {
controller?.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
if (!controller.value.isInitialized) {
return Container();
}
return AspectRatio(
aspectRatio:
controller.value.aspectRatio,
child: CameraPreview(controller));
}
// Load model and labels
void loadTensorFlow() async{
String res = await Tflite.loadModel(
model: "assets/tf/mobilenet_v1_1.0_224_quant.tflite",
labels: "assets/tf/labels_mobilenet_quant_v1_224.txt",
numThreads: 1,
);
setState(() {
if(res != null) {
tfLoaded = true;
}
});
}
}
And I am having the following error:
E/AndroidRuntime( 9556): FATAL EXCEPTION: AsyncTask #2
E/AndroidRuntime( 9556): Process: com.myapp.myapp, PID: 9556
E/AndroidRuntime( 9556): java.lang.RuntimeException: An error occurred while executing doInBackground()
E/AndroidRuntime( 9556): at android.os.AsyncTask$3.done(AsyncTask.java:353)
E/AndroidRuntime( 9556): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
E/AndroidRuntime( 9556): at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
E/AndroidRuntime( 9556): at java.util.concurrent.FutureTask.run(FutureTask.java:271)
E/AndroidRuntime( 9556): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
E/AndroidRuntime( 9556): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
E/AndroidRuntime( 9556): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
E/AndroidRuntime( 9556): at java.lang.Thread.run(Thread.java:764)
E/AndroidRuntime( 9556): Caused by: java.lang.IllegalArgumentException: Cannot convert between a TensorFlowLite tensor with type UINT8 and a Java object of type [[F (which is compatible with the TensorFlowLite type FLOAT32).
E/AndroidRuntime( 9556): at org.tensorflow.lite.Tensor.throwExceptionIfTypeIsIncompatible(Tensor.java:233)
E/AndroidRuntime( 9556): at org.tensorflow.lite.Tensor.copyTo(Tensor.java:116)
E/AndroidRuntime( 9556): at org.tensorflow.lite.NativeInterpreterWrapper.run(NativeInterpreterWrapper.java:157)
E/AndroidRuntime( 9556): at org.tensorflow.lite.Interpreter.runForMultipleInputsOutputs(Interpreter.java:250)
E/AndroidRuntime( 9556): at org.tensorflow.lite.Interpreter.run(Interpreter.java:228)
E/AndroidRuntime( 9556): at sq.flutter.tflite.TflitePlugin$RunModelOnFrame.runTflite(TflitePlugin.java:478)
E/AndroidRuntime( 9556): at sq.flutter.tflite.TflitePlugin$TfliteTask.doInBackground(TflitePlugin.java:389)
E/AndroidRuntime( 9556): at sq.flutter.tflite.TflitePlugin$TfliteTask.doInBackground(TflitePlugin.java:363)
E/AndroidRuntime( 9556): at android.os.AsyncTask$2.call(AsyncTask.java:333)
E/AndroidRuntime( 9556): at java.util.concurrent.FutureTask.run(FutureTask.java:266)
E/AndroidRuntime( 9556): ... 4 more
I am doing what it is said in the README.md --> Image Classification --> Run on image stream (video frame). I have tried with camera version ^0.4.3+2 and 0.4.0 (I suppose you mean that one when saying 4.0.0 in the README.md). I have also checked that my android phone is in YUV_420 and it is.
App does not load up. It gets installed but does not open. On the terminal it hangs on the step after installing the apk. I've seen that other people are able to run it so I'm guessing it's something specific to me. Has anyone faced a similar problem?
Steps to reproduce:
flutter packages get
flutter run
Device:
OS
Tried and did not work:
adb uninstall ${package_name}
, and doing flutter run
againHello. This package is realy cool.
I want to use my own tflite model for pose estimation. Can I get output with my own format? I want to get heatmap from my model outputs for pose estimation, where count of keypoints only is 14.
Hello,
The following is the section of my code which causes a crash for my app on iOS 12.1.2 using an iPhone 6.
Future analyze(String imagePath) async {
String model = await Tflite.loadModel(
model: Assets.myModel,
labels: Assets.myModelLabels,
numThreads: 1 // defaults to 1
);
var analysis = await Tflite.runModelOnImage(
path: imagePath,
// required
imageMean: 0.0,
// defaults to 117.0
imageStd: 255.0,
// defaults to 1.0
numResults: 1,
// defaults to 5
threshold: 0.2,
// defaults to 0.1
asynch: true // defaults to true
);
return analysis;
}
loadModel causes no issues. However, when I call runModelOnImage for any picture I take, the app crashes. I went through with a debugger in Android Studio and it does not crash on any of the code I have written, but no feedback is provided when it crashes and everything just stops.
When I repeat this using Xcode to build instead of Android Studio, a breakpoint is automatically created and execution stops on line 65 of ios_image_load.mm. I am confident that I did not do anything to cause this as I did not write the code in that file. The following text is what was displayed by Xcode when I could not progress any further in the application before causing the crash of the app (happening in "LoadImageFromFile(const char* file_name, int* out_width, int* out_height, int* out_channels" of the ios_image_load.mm file):
2019-08-16 15:46:56.285280-0500 Runner[24458:5125639] flutter: Observatory listening on http://127.0.0.1:57634/8aOsiY60hlQ=/
2019-08-16 15:47:20.297500-0500 Runner[24458:5125630] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2019-08-16 15:47:20.298693-0500 Runner[24458:5125630] [MC] Reading from public effective user settings.
2019-08-16 15:47:23.866548-0500 Runner[24458:5125538] Could not load IOSurface for time string. Rendering locally instead.
Loaded model 1resolved reporter2019-08-16 15:47:27.824862-0500 Runner[24458:5125538] [Unknown process name] CGContextDrawImage: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
warning: could not execute support code to read Objective-C class data in the process. This may reduce the quality of type information available.
(lldb)
There are no problems that I have noticed with Android, only iOS.
Here is a screenshot of what I saw in Xcode before the app would crash.
Whenever I try to use tflite with gpu support ('org.tensorflow:tensorflow-lite:0.0.1-gpu-experimental') I get "GpuDelegate: java.lang.ClassNotFoundException" in runtime, though it compiles fine. flutter clean
doesn't help.
E/flutter (25136): [ERROR:flutter/shell/platform/android/platform_view_android_jni.cc(40)] java.lang.NoClassDefFoundError: Failed resolution of: Lorg/tensorflow/lite/experimental/GpuDelegate;
E/flutter (25136): at sq.flutter.tflite.TflitePlugin.loadModel(TflitePlugin.java:139)
E/flutter (25136): at sq.flutter.tflite.TflitePlugin.onMethodCall(TflitePlugin.java:68)
E/flutter (25136): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:201)
E/flutter (25136): at io.flutter.view.FlutterNativeView$PlatformMessageHandlerImpl.handleMessageFromDart(FlutterNativeView.java:188)
E/flutter (25136): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:202)
E/flutter (25136): at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter (25136): at android.os.MessageQueue.next(MessageQueue.java:323)
E/flutter (25136): at android.os.Looper.loop(Looper.java:142)
E/flutter (25136): at android.app.ActivityThread.main(ActivityThread.java:6238)
E/flutter (25136): at java.lang.reflect.Method.invoke(Native Method)
E/flutter (25136): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
E/flutter (25136): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
Hi thank you for your work! I've just tried to use this plugin by copying the exact example code with the same model and labels, however I get this error after taking a picture and setting it as the image variable.
Dart Error: Unhandled exception: PlatformException(Failed to run model, null, null)
any idea how I could fix this? Thank you!
Hi, I’m using a graph.lite trained with 2 results and a labels.txt, I have managed to get the example working, however it works wonderfully while I’m using it and I can analyze and take as many pictures as I want, yet when I leave to another screen in the app and come back I get an error like the one below stating that somehow the Java object which had correctly worked and gave me a result on top of the taken image, has now changed from [1,2] to [1,4], what’s more interesting is that this discrepancy keeps growing as I leave and come back, as the next time it’s [1,6], the next [1,8], next [1,10] you get the picture, and it constantly keeps giving me this error and doesn’t go on to analyze the image therefore I get no results anymore. I have to close the app and start it again for tensorflow to work, then again if I leave to another screen and come back it starts the same cycle. Is this a bug or should I change something else? I have used either 224 or 299 for image size when preparing tflite, imageMean was 128 not 127.5 but I’ve tried changing that too without any results. I have tried modifying the variables numResults, imageMean, imageStd, image sizes in main and tflite.dart however I still get an error on second run. The only thing I didn’t try changing was threshold. Can you please help. This is the error I get below. Best regards
E/flutter (23306): [ERROR:flutter/shell/common/shell.cc(184)] Dart Error: Unhandled exception:
E/flutter (23306): PlatformException(error, Unsupported value: java.lang.IllegalArgumentException: Cannot copy between a TensorFlowLite tensor with shape [1, 2] and a Java object with shape [1, 4]., null)
E/flutter (23306): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:551:7)
E/flutter (23306): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:292:18)
E/flutter (23306):
E/flutter (23306): #2 Tflite.runModelOnImage (package:tflite/tflite.dart:33:27)
E/flutter (23306):
E/flutter (23306): #3 _MyAppState.recognizeImage (package:someApp_tabbed_activity/tflite/tflitemain.dart:74:37)
E/flutter (23306):
E/flutter (23306): #4 _MyAppState.getImage (package:someApp_tabbed_activity/tflite/tflitemain.dart:25:5)
E/flutter (23306):
E/flutter (23306): #5 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:507:14)
E/flutter (23306): #6 _InkResponseState.build. (package:flutter/src/material/ink_well.dart:562:30)
E/flutter (23306): #7 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
E/flutter (23306): #8 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:242:9)
E/flutter (23306): #9 TapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:204:7)
E/flutter (23306): #10 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
E/flutter (23306): #11 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:184:20)
E/flutter (23306): #12 _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:158:22)
E/flutter (23306): #13 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:138:7)
E/flutter (23306): #14 _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:101:7)
E/flutter (23306): #15 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:85:7)
E/flutter (23306): #16 _invoke1 (dart:ui/hooks.dart:168:13)
E/flutter (23306): #17 _dispatchPointerDataPacket (dart:ui/hooks.dart:122:5)
Hello!
I tried to get your example app to work. When I click on the button Tiny YOLOv2, I always get the error message:
flutter: Failed to mmap model /var/containers/Bundle/Application/F91D7024-D937-4D94-BDC2-5CC6C8A273E8/Runner.app/Frameworks/App.framework/flutter_assets/assets/yolov2_tiny.tflite
It's the same for the other two models.
I have created the assets folder and also included the assets in my pubspec.yaml:
assets:
- assets/mobilenet_v1_1.0_224.tflite
- assets/mobilenet_v1_1.0_224.txt
- assets/ssd_mobilenet.tflite
- assets/ssd_mobilenet.txt
- assets/yolov2_tiny.tflite
- assets/yolov2_tiny.txt
Could you give me an idea on what it is not working correctly?
Hello! I like this plugin but it seems to be limited to Image Classification while TFLite also supports Object Detection models. Do you have any plans for incorporating object detection into this plugin?
`* Error running Gradle:
ProcessException: Process "/Users/kent/Desktop/mlTest/flutter_tflite/example/android/gradlew" exited abnormally:
Starting a Gradle Daemon (subsequent builds will be faster)
Download https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.1.2/gradle-3.1.2.pom
Download https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle-core/3.1.2/gradle-core-3.1.2.pom
Download https://dl.google.com/dl/android/maven2/com/android/tools/lint/lint-gradle-api/26.1.2/lint-gradle-api-26.1.2.pom
Download https://dl.google.com/dl/android/maven2/com/android/tools/build/builder/3.1.2/builder-3.1.2.pom
Download https://dl.google.com/dl/android/maven2/com/android/databinding/compilerCommon/3.1.2/compilerCommon-3.1.2.pom
Download https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle-api/3.1.2/gradle-api-3.1.2.pom
Download https://jcenter.bintray.com/com/android/tools/annotations/24.5.0/annotations-24.5.0.pom
FAILURE: Build failed with an exception.
Could not resolve all files for configuration ':classpath'.
Could not resolve org.ow2.asm:asm-analysis:5.1.
Required by:
project : > com.android.tools.build:gradle:3.1.2 > com.android.tools.build:gradle-core:3.1.2
> Could not resolve org.ow2.asm:asm-analysis:5.1.
> Could not get resource 'https://dl.google.com/dl/android/maven2/org/ow2/asm/asm-analysis/5.1/asm-analysis-5.1.pom'.
> Could not HEAD 'https://dl.google.com/dl/android/maven2/org/ow2/asm/asm-analysis/5.1/asm-analysis-5.1.pom'.
> Read timed out
Could not resolve com.android.tools.build:aapt2-proto:0.1.0.
Required by:
project : > com.android.tools.build:gradle:3.1.2 > com.android.tools.build:bundletool:0.1.0-alpha01
> Skipped due to earlier error
Could not resolve com.android.tools.build:builder-model:3.1.2.
Required by:
project : > com.android.tools.build:gradle:3.1.2 > com.android.tools.build:gradle-core:3.1.2 > com.android.tools.build:builder:3.1.2
project : > com.android.tools.build:gradle:3.1.2 > com.android.tools.build:gradle-core:3.1.2 > com.android.tools.lint:lint-gradle-api:26.1.2
project : > com.android.tools.build:gradle:3.1.2 > com.android.tools.build:gradle-core:3.1.2 > com.android.tools.build:gradle-api:3.1.2
> Skipped due to earlier error
Could not resolve com.android.tools.build:builder-test-api:3.1.2.
Required by:
project : > com.android.tools.build:gradle:3.1.2 > com.android.tools.build:gradle-core:3.1.2 > com.android.tools.build:builder:3.1.2
project : > com.android.tools.build:gradle:3.1.2 > com.android.tools.build:gradle-core:3.1.2 > com.android.tools.build:gradle-api:3.1.2
> Skipped due to earlier error
Could not resolve com.android.tools:sdklib:26.1.2.
Required by:
project : > com.android.tools.build:gradle:3.1.2 > com.android.tools.build:gradle-core:3.1.2 > com.android.tools.build:builder:3.1.2
project : > com.android.tools.build:gradle:3.1.2 > com.android.tools.build:gradle-core:3.1.2 > com.android.tools.lint:lint-gradle-api:26.1.2
> Skipped due to earlier error
Could not resolve com.android.tools:sdk-common:26.1.2.
Required by:
project : > com.android.tools.build:gradle:3.1.2 > com.android.tools.build:gradle-core:3.1.2 > com.android.tools.build:builder:3.1.2
> Skipped due to earlier error
Could not resolve com.android.tools:common:26.1.2.
Required by:
project : > com.android.tools.build:gradle:3.1.2 > com.android.tools.build:gradle-core:3.1.2 > com.android.tools.build:builder:3.1.2
> Skipped due to earlier error
Could not resolve com.android.tools.build:manifest-merger:26.1.2.
Required by:
project : > com.android.tools.build:gradle:3.1.2 > com.android.tools.build:gradle-core:3.1.2 > com.android.tools.build:builder:3.1.2
> Skipped due to earlier error
Could not resolve com.android.tools.ddms:ddmlib:26.1.2.
Required by:
project : > com.android.tools.build:gradle:3.1.2 > com.android.tools.build:gradle-core:3.1.2 > com.android.tools.build:builder:3.1.2
> Skipped due to earlier error
Could not resolve com.android.tools.analytics-library:protos:26.1.2.
Required by:
project : > com.android.tools.build:gradle:3.1.2 > com.android.tools.build:gradle-core:3.1.2 > com.android.tools.build:builder:3.1.2
> Skipped due to earlier error
Could not resolve com.android.tools.analytics-library:shared:26.1.2.
Required by:
project : > com.android.tools.build:gradle:3.1.2 > com.android.tools.build:gradle-core:3.1.2 > com.android.tools.build:builder:3.1.2
> Skipped due to earlier error
Could not resolve com.android.tools.analytics-library:tracker:26.1.2.
Required by:
project : > com.android.tools.build:gradle:3.1.2 > com.android.tools.build:gradle-core:3.1.2 > com.android.tools.build:builder:3.1.2
> Skipped due to earlier error
Could not resolve com.android.tools.build:apksig:3.1.2.
Required by:
project : > com.android.tools.build:gradle:3.1.2 > com.android.tools.build:gradle-core:3.1.2 > com.android.tools.build:builder:3.1.2
> Skipped due to earlier error
Could not resolve com.android.databinding:baseLibrary:3.1.2.
Required by:
project : > com.android.tools.build:gradle:3.1.2 > com.android.tools.build:gradle-core:3.1.2 > com.android.databinding:compilerCommon:3.1.2
> Skipped due to earlier error
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 38s
Command: /Users/kent/Desktop/mlTest/flutter_tflite/example/android/gradlew app:properties
Please review your Gradle project setup in the android/ folder.
Exited (sigterm)`
E/MethodChannel#tflite( 8556): Failed to handle method call
E/MethodChannel#tflite( 8556): java.lang.IllegalArgumentException: Unsupported value: java.lang.RuntimeException: Interpreter busy
E/MethodChannel#tflite( 8556): at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:294)
E/MethodChannel#tflite( 8556): at io.flutter.plugin.common.StandardMethodCodec.encodeErrorEnvelope(StandardMethodCodec.java:70)
E/MethodChannel#tflite( 8556): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.error(MethodChannel.java:230)
E/MethodChannel#tflite( 8556): at sq.flutter.tflite.TflitePlugin.onMethodCall(TflitePlugin.java:175)
E/MethodChannel#tflite( 8556): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:222)
E/MethodChannel#tflite( 8556): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:96)
E/MethodChannel#tflite( 8556): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:643)
E/MethodChannel#tflite( 8556): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#tflite( 8556): at android.os.MessageQueue.next(MessageQueue.java:323)
E/MethodChannel#tflite( 8556): at android.os.Looper.loop(Looper.java:142)
E/MethodChannel#tflite( 8556): at android.app.ActivityThread.main(ActivityThread.java:6389)
E/MethodChannel#tflite( 8556): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#tflite( 8556): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
E/MethodChannel#tflite( 8556): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:791)
E/flutter ( 8556): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: PlatformException(error, Unsupported value: java.lang.RuntimeException: Interpreter busy, null)
Good work, we need this for Flutter. I'm referencing the example here where the file under the lib folder is main.dart not tflite.dart. I'm having issue importing tflite package though. IntelliJ tells me: Target of URI doesn't exist: 'package:tflite/tflite.dart'. for the line
import 'package:tflite/tflite.dart';
I believe I've added tflite package properly to the pubscec.yaml file using instructions here but it still won't work...
dev_dependencies:
flutter_test:
sdk: flutter
image_picker: ^0.4.10
tflite: ^0.0.2
any ideas why I can't import
Hello! I was very excited to find your plugin. I've forked the repo and tried replacing the graph and labels with my own, but it keeps crashing on iOS. Android seems to be working fine.
Here is my repo:
https://github.com/jordanmcadoo/flutter_tflite
And this is the output upon crash:
Launching lib/main.dart on iPhone XR in debug mode...
Starting Xcode build...
Xcode build done. 5.0s
Syncing files to device iPhone XR...
flutter: success
*** First throw call stack:
(
0 CoreFoundation 0x00000001052ab29b __exceptionPreprocess + 331
1 libobjc.A.dylib 0x0000000104847735 objc_exception_throw + 48
2 CoreFoundation 0x00000001052ab0f5 +[NSException raise:format:] + 197
3 Foundation 0x00000001042d6546 +[NSString stringWithUTF8String:] + 78
4 Runner 0x00000001027db603 _Z15runModelOnImageP12NSDictionary + 4035
5 Runner 0x00000001027d9976 -[TflitePlugin handleMethodCall:result:] + 662
6 Flutter 0x0000000102a73b3b __45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke + 115
7 Flutter 0x0000000102a8f248 _ZNK5shell21PlatformMessageRouter21HandlePlatformMessageEN3fml6RefPtrIN5blink15Pl<…>
Lost connection to device.
Hey, this package is so awesome. Can it load my own model to predict audio data? the input shape is (1, 97, 200, 1), but after read package usage, It seems to only be used for image?
Hi,
I need to use pose estimation model from tensorflow in flutter. Can you explain how I can do it?
Thank you!
Inference took 1183
I/flutter (32429): []
I/flutter (32429): []
this is what i get after executing
final val = await Tflite.runModelOnImage(
path: "/storage/emulated/0/Download/download.jpeg", // required
imageMean: 0.0, // defaults to 117.0
imageStd: 255.0, // defaults to 1.0
numResults: 2, // defaults to 5
threshold: 0.2, // defaults to 0.1
asynch: true);
print(val.toString());
Hello, I am facing this issue when trying to run the code:
var imageBytes = (await rootBundle.load(image.path)).buffer;
img.Image oriImage = img.decodeJpg(imageBytes.asUint8List());
img.Image resizedImage = img.copyResize(oriImage, height: 112, width: 112);
var recognitions = await Tflite.runModelOnBinary(
binary: imageToByteListFloat32(resizedImage, 112, 127.5, 127.5),
numResults: 6,
threshold: 0.05,
);
}
Uint8List imageToByteListFloat32(
img.Image image, int inputSize, double mean, double std) {
var convertedBytes = Float32List(1 * inputSize * inputSize * 3);
var buffer = Float32List.view(convertedBytes.buffer);
int pixelIndex = 0;
for (var i = 0; i < inputSize; i++) {
for (var j = 0; j < inputSize; j++) {
var pixel = image.getPixel(j, i);
buffer[pixelIndex++] = (img.getRed(pixel) - mean) / std;
buffer[pixelIndex++] = (img.getGreen(pixel) - mean) / std;
buffer[pixelIndex++] = (img.getBlue(pixel) - mean) / std;
}
}
return convertedBytes.buffer.asUint8List();
}
I am using model, generated using AutoML in firebase.
Error is as follows:
Caused by: java.lang.IllegalArgumentException: Cannot convert between a TensorFlowLite tensor with type UINT8 and a Java object of type [[F (which is compatible with the TensorFlowLite type FLOAT32).
Hi I used your example from the repo for your pose detections, however the output scores are sometimes really low (using the same params as you 0.7 threshold and same code)
Everything works great on Android.
On IOS, error came out after pod install
:
The 'Pods-Runner' target has transitive dependencies that include static binaries: (test_app/ios/Pods/TensorFlowLite/Frameworks/tensorflow_lite.framework)
In Podfile:
target 'Runner' do use_frameworks! <-- to use swift plugin
Performing hot restart...
Running "flutter packages get" in example...
Syncing files to device Redmi 7...
Restarted application in 15,854ms.
I/Choreographer( 6138): Skipped 61 frames! The application may be doing too much work on its main thread.
W/Looper ( 6138): Slow Frame: doFrame is 1018ms late
I/Timeline( 6138): Timeline: Activity_launch_request time:307300050
E/MethodChannel#tflite( 6138): Failed to handle method call
E/MethodChannel#tflite( 6138): java.lang.IllegalArgumentException: Unsupported value: java.lang.RuntimeException: Interpreter busy
E/MethodChannel#tflite( 6138): at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:289)
E/MethodChannel#tflite( 6138): at io.flutter.plugin.common.StandardMethodCodec.encodeErrorEnvelope(StandardMethodCodec.java:70)
E/MethodChannel#tflite( 6138): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.error(MethodChannel.java:209)
E/MethodChannel#tflite( 6138): at sq.flutter.tflite.TflitePlugin.onMethodCall(TflitePlugin.java:82)
E/MethodChannel#tflite( 6138): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:201)
E/MethodChannel#tflite( 6138): at io.flutter.view.FlutterNativeView$PlatformMessageHandlerImpl.handleMessageFromDart(FlutterNativeView.java:188)
E/MethodChannel#tflite( 6138): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:202)
E/MethodChannel#tflite( 6138): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#tflite( 6138): at android.os.MessageQueue.next(MessageQueue.java:326)
E/MethodChannel#tflite( 6138): at android.os.Looper.loop(Looper.java:165)
E/MethodChannel#tflite( 6138): at android.app.ActivityThread.main(ActivityThread.java:6810)
E/MethodChannel#tflite( 6138): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#tflite( 6138): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
E/MethodChannel#tflite( 6138): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
E/flutter ( 6138): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: PlatformException(error, Unsupported value: java.lang.RuntimeException: Interpreter busy, null)
E/flutter ( 6138): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:564:7)
E/flutter ( 6138): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:302:33)
E/flutter ( 6138):
E/flutter ( 6138): #2 Tflite.runModelOnImage (package:tflite/tflite.dart:28:27)
E/flutter ( 6138):
E/flutter ( 6138): #3 _MyAppState.recognizeImage (package:tflite_example/main.dart:152:37)
E/flutter ( 6138):
E/flutter ( 6138): #4 _MyAppState.predictImage (package:tflite_example/main.dart:63:15)
E/flutter ( 6138):
E/flutter ( 6138): #5 _MyAppState.predictImagePicker (package:tflite_example/main.dart:46:5)
E/flutter ( 6138):
E/flutter ( 6138): #6 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:513:14)
E/flutter ( 6138): #7 _InkResponseState.build. (package:flutter/src/material/ink_well.dart:568:30)
E/flutter ( 6138): #8 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:120:24)
E/flutter ( 6138): #9 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:242:9)
E/flutter ( 6138): #10 TapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:204:7)
E/flutter ( 6138): #11 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
E/flutter ( 6138): #12 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:218:20)
E/flutter ( 6138): #13 _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:192:22)
E/flutter ( 6138): #14 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:149:7)
E/flutter ( 6138): #15 _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:101:7)
E/flutter ( 6138): #16 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:85:7)
E/flutter ( 6138): #17 _rootRunUnary (dart:async/zone.dart:1136:13)
E/flutter ( 6138): #18 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
E/flutter ( 6138): #19 _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
E/flutter ( 6138): #20 _invoke1 (dart:ui/hooks.dart:223:10)
E/flutter ( 6138): #21 _dispatchPointerDataPacket (dart:ui/hooks.dart:144:5)
E/flutter ( 6138):
W/System ( 6138): A resource failed to call close.
I/chatty ( 6138): uid=10202(sq.flutter.tfliteexample) FinalizerDaemon identical 1 line
W/System ( 6138): A resource failed to call close.
W/Looper ( 6138): Slow Frame: doFrame is 311ms late
Hi, the copyResize method in Dart packages has been changed by the Flutter team and no longer takes in 3 arguments, but one. How do you solve this? This is the new class, if you make a new project in Flutter, you will see an error on the line in the subject, and you can inspect the same class, here it is
import 'dart:typed_data';
import '../color.dart';
import '../image.dart';
import '../image_exception.dart';
import '../util/interpolation.dart';
import 'bake_orientation.dart';
/// Returns a resized copy of the [src] image.
/// If [height] isn't specified, then it will be determined by the aspect
/// ratio of [src] and [width].
/// If [width] isn't specified, then it will be determined by the aspect ratio
/// of [src] and [height].
Image copyResize(Image src, {int width, int height,
Interpolation interpolation = Interpolation.nearest}) {
if (width == null && height == null) {
throw ImageException('Invalid size');
}
src = bakeOrientation(src);
if (height == null || height <= 0) {
height = (width * (src.height / src.width)).toInt();
}
if (width == null || width <= 0) {
width = (height * (src.width / src.height)).toInt();
}
if (width == src.width && height == src.height) {
return src.clone();
}
Image dst = Image(width, height, channels: src.channels, exif: src.exif,
iccp: src.iccProfile);
double dy = src.height / height;
double dx = src.width / width;
if (interpolation == Interpolation.average) {
Uint8List sData = src.getBytes();
int sw4 = src.width * 4;
for (int y = 0; y < height; ++y) {
int y1 = (y * dy).toInt();
int y2 = ((y + 1) * dy).toInt();
if (y2 == y1) {
y2++;
}
for (int x = 0; x < width; ++x) {
int x1 = (x * dx).toInt();
int x2 = ((x + 1) * dx).toInt();
if (x2 == x1) {
x2++;
}
int r = 0;
int g = 0;
int b = 0;
int a = 0;
int np = 0;
for (int sy = y1; sy < y2; ++sy) {
int si = sy * sw4 + x1 * 4;
for (int sx = x1; sx < x2; ++sx, ++np) {
r += sData[si++];
g += sData[si++];
b += sData[si++];
a += sData[si++];
}
}
dst.setPixel(x, y, getColor(r ~/ np, g ~/ np, b ~/ np, a ~/ np));
}
}
} else if (interpolation == Interpolation.nearest) {
final scaleX = Int32List(width);
for (int x = 0; x < width; ++x) {
scaleX[x] = (x * dx).toInt();
}
for (int y = 0; y < height; ++y) {
int y2 = (y * dy).toInt();
for (int x = 0; x < width; ++x) {
dst.setPixel(x, y, src.getPixel(scaleX[x], y2));
}
}
} else {
// Copy the pixels from this image to the new image.
for (int y = 0; y < height; ++y) {
double y2 = (y * dy);
for (int x = 0; x < width; ++x) {
double x2 = (x * dx);
dst.setPixel(x, y, src.getPixelInterpolate(x2, y2, interpolation));
}
}
}
return dst;
}
For now, I have just done this
img.Image resizedImage = img.copyResize(oriImage);
and it works, but I don't know if this will change the results a lot, is there a better solution?
Trying to build for both ios 12 device and emulator
While building module 'tflite' imported from GeneratedPluginRegistrant.m:11:
In file included from <module-includes>:1:
In file included from tflite-umbrella.h:13:
ios_image_load.h:1:10: fatal error: 'vector' file not found
#include <vector>
^~~~~~~~
1 error generated.
GeneratedPluginRegistrant.m:11:9: fatal error: could not build module 'tflite'
#import <tflite/TflitePlugin.h>
Hello,
I wonder how to save image with Bounding boxes... BB is a widget (positioned), so I can't convert it to image class and also merge positioned class and image class.
Let me know how to do it ...
Thanks
I was wondering if there is a way of inputing an array into the neural net instead a file path?
I'm trying to use my retrained ssd mobilenet model, but I'm gonna need greater number of detections than 10.
I am getting this error
Compiler message:
lib/main.dart:167:44: Error: Too many positional arguments: 1 allowed, but 3 found.
Try removing the extra positional arguments.
img.Image resizedImage = img.copyResize(oriImage, 224, 224);
^
file:///Users/ajinkyabobade/development/flutter/.pub-cache/hosted/pub.dartlang.org/image-2.1.2/lib/src/transform/copy_resize.dart:14:7: Context: Found this candidate, but the arguments don't match.
Image copyResize(Image src, {int width, int height,
^^^^^^^^^^
Compiler failed on /Users/ajinkyabobade/Documents/flutter_tflite/example/lib/main.dart
How to resolve it ?
I trained a Mobilenet model using transfer learning with Keras. I then converted the keras h5 model to tflite using toco and replaced the mobilnet model and the labels with my labels. I have 11 classes in my model. But, while running, I am getting the above error. Here is the full trace.
E/AndroidRuntime(21599): FATAL EXCEPTION: AsyncTask #2 E/AndroidRuntime(21599): Process: com.example.examplerealtime, PID: 21599 E/AndroidRuntime(21599): java.lang.RuntimeException: An error occurred while executing doInBackground() E/AndroidRuntime(21599): at android.os.AsyncTask$3.done(AsyncTask.java:354) E/AndroidRuntime(21599): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383) E/AndroidRuntime(21599): at java.util.concurrent.FutureTask.setException(FutureTask.java:252) E/AndroidRuntime(21599): at java.util.concurrent.FutureTask.run(FutureTask.java:271) E/AndroidRuntime(21599): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245) E/AndroidRuntime(21599): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) E/AndroidRuntime(21599): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) E/AndroidRuntime(21599): at java.lang.Thread.run(Thread.java:764) E/AndroidRuntime(21599): Caused by: java.lang.IllegalArgumentException: Cannot copy between a TensorFlowLite tensor with shape [1, 11] and a Java object with shape [1, 11, 4]. E/AndroidRuntime(21599): at org.tensorflow.lite.Tensor.throwIfShapeIsIncompatible(Tensor.java:282) E/AndroidRuntime(21599): at org.tensorflow.lite.Tensor.throwIfDataIsIncompatible(Tensor.java:249) E/AndroidRuntime(21599): at org.tensorflow.lite.Tensor.copyTo(Tensor.java:141) E/AndroidRuntime(21599): at org.tensorflow.lite.NativeInterpreterWrapper.run(NativeInterpreterWrapper.java:161) E/AndroidRuntime(21599): at org.tensorflow.lite.Interpreter.runForMultipleInputsOutputs(Interpreter.java:275) E/AndroidRuntime(21599): at sq.flutter.tflite.TflitePlugin$RunSSDMobileNet.runTflite(TflitePlugin.java:622) E/AndroidRuntime(21599): at sq.flutter.tflite.TflitePlugin$TfliteTask.doInBackground(TflitePlugin.java:419) E/AndroidRuntime(21599): at sq.flutter.tflite.TflitePlugin$TfliteTask.doInBackground(TflitePlugin.java:393) E/AndroidRuntime(21599): at android.os.AsyncTask$2.call(AsyncTask.java:333) E/AndroidRuntime(21599): at java.util.concurrent.FutureTask.run(FutureTask.java:266)
Hello,
I want to be able to take a portrait picture but when I change the aspect ratio or orientation the detection goes crazy.
Is there a way to achieve this?
Thank you!
Hi,
How do you find the mean and deviation for the input?
Thanks
I've created a brand new Flutter project
Imported tflite dependecy to pubspec.yaml acrroding to README Installation and run "flutter run" after package get to build my flutter app to my iOS Simulator
obviously there were error like "'vector' file not found"
I did what README told to do:
open ios/Runner.xcworkspace in Xcode, click Runner > Tagets > Runner > Build Settings, search Compile Sources As, change the value to Objective-C++;
But there are some other errors:
`Failed to build iOS app
Error output from Xcode build:
↳
2019-08-13 13:15:28.862 xcodebuild[37596:699677] DTDeviceKit: deviceType from
00008027-001329AA1498002E was NULL
2019-08-13 13:15:28.907 xcodebuild[37596:699678] DTDeviceKit: deviceType from
00008027-001329AA1498002E was NULL
** BUILD FAILED **
Xcode's output:
↳
warning: The use of Swift 3 @objc inference in Swift 4 mode is deprecated. Please
address deprecated @objc inference warnings, test your code with “Use of deprecated
Swift 3 @objc inference” logging enabled, and then disable inference by changing the
"Swift 3 @objc Inference" build setting to "Default" for the "Runner" target. (in target
'Runner')
ld: targeted OS version does not support use of thread local variables in
__ZN14EigenForTFLite15ThreadPoolTemplINS_20StlThreadEnvironmentEE16ScheduleWithHintENSt3
__18functionIFvvEEEii for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
note: Using new build systemnote: Planning buildnote: Constructing build description`
I googled it and found a result as
After doing that, here was one last error:
Error output from Xcode build:
↳
2019-08-13 13:27:29.227 xcodebuild[39427:733244] DTDeviceKit: deviceType from
00008027-001329AA1498002E was NULL
2019-08-13 13:27:29.299 xcodebuild[39427:733281] DTDeviceKit: deviceType from
00008027-001329AA1498002E was NULL
** BUILD FAILED **
Xcode's output: ↳ ld: targeted OS version does not support use of thread local variables in __ZN14EigenForTFLite15ThreadPoolTemplINS_20StlThreadEnvironmentEE16ScheduleWithHintENSt3 __18functionIFvvEEEii for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) note: Using new build systemnote: Planning buildnote: Constructing build description
I can't solve this problem even I tried what I can googled
After that, I tried to run the example in this github Repository directly
But still got errors
I appreciate with your work but it really needs to be update soon
When I substitute a quantized model into code that works for image classification with the non-quantized model (I simply substituted 'mobilenet_v2_1.0_224_quant.tflite' for 'Mobilenet_V2_1.0_224'), I get:
Caused by: java.lang.IllegalArgumentException: Cannot convert between a TensorFlowLite tensor with type UINT8 and a Java object of type [[F (which is compatible with the TensorFlowLite type FLOAT32).
Is it possible to use quantized models? If so, how (would be good to have something in the documentation)? If not, would also be good if the documentation said so - or if it is just not possible at the moment, but hopefully in the future, I guess consider this a feature request.
Can't I just use the model load?
Looks like a reference to the breaking API change with flutter 1.7 !!
cd /Users/apple/workspace/go/src/github.com/shaqian/flutter_tflite/example && flutter run -d all
No devices found
make: *** [mob-run] Error 1
x-MacBook-Pro:shaqian apple$ make mob-run
cd /Users/apple/workspace/go/src/github.com/shaqian/flutter_tflite/example && flutter run -d all
Launching lib/main.dart on Nexus 5X in debug mode...
Initializing gradle... 3.3s
Resolving dependencies... 4.8s
Compiler message:
lib/app.dart:73:22: Error: The argument type 'Null Function(ImageInfo, bool)' can't be assigned to the parameter type 'ImageStreamListener'.
- 'ImageInfo' is from 'package:flutter/src/painting/image_stream.dart' ('file:///Users/apple/fvm/master/packages/flutter/lib/src/painting/image_stream.dart').
- 'ImageStreamListener' is from 'package:flutter/src/painting/image_stream.dart' ('file:///Users/apple/fvm/master/packages/flutter/lib/src/painting/image_stream.dart').
Try changing the type of the parameter, or casting the argument to 'ImageStreamListener'.
.addListener((ImageInfo info, bool _) {
^
Compiler failed on /Users/apple/workspace/go/src/github.com/shaqian/flutter_tflite/example/lib/main.dart
FAILURE: Build failed with an exception.
* Where:
Script '/Users/apple/fvm/master/packages/flutter_tools/gradle/flutter.gradle' line: 652
* What went wrong:
Execution failed for task ':app:compileflutterBuildDebugArm64'.
> Process 'command '/Users/apple/fvm/master/bin/flutter'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 15s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 16.1s
Gradle task assembleDebug failed with exit code 1
make: *** [mob-run] Error 1
x-MacBook-Pro:shaqian apple$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel dev, v1.8.0, on Mac OS X 10.14.5 18F132, locale en-DE)
[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
✗ Android license status unknown.
Try re-installing or updating your Android SDK Manager.
See https://developer.android.com/studio/#downloads or visit
https://flutter.dev/setup/#android-setup for detailed instructions.
[✓] Xcode - develop for iOS and macOS (Xcode 10.2.1)
[✓] iOS tools - develop for iOS devices
[!] Android Studio (version 3.4)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] VS Code (version 1.36.1)
[✓] Connected device (1 available)
byte[] binary = (byte[])args.get("binary");
String model = args.get("model").toString();
double threshold = (double)args.get("threshold");
float THRESHOLD = (float)threshold;
List ANCHORS = (ArrayList)args.get("anchors");
int BLOCK_SIZE = (int)args.get("blockSize");
int NUM_BOXES_PER_BLOCK = (int)args.get("numBoxesPerBlock");
int NUM_RESULTS_PER_CLASS = (int)args.get("numResultsPerClass");
ByteBuffer imgData = ByteBuffer.wrap(binary);
if (model.equals("SSDMobileNet")) {
return parseSSDMobileNet(imgData, NUM_RESULTS_PER_CLASS, THRESHOLD);
} else {
return parseYOLO(imgData, BLOCK_SIZE, NUM_BOXES_PER_BLOCK, ANCHORS, THRESHOLD, NUM_RESULTS_PER_CLASS);
}
}
sorry, no link, old browser
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.