TensorFlow Lite Flutter Plugin

Overview



Platform Pub Package Docs

Overview

TensorFlow Lite Flutter plugin provides a flexible and fast solution for accessing TensorFlow Lite interpreter and performing inference. The API is similar to the TFLite Java and Swift APIs. It directly binds to TFLite C API making it efficient (low-latency). Offers acceleration support using NNAPI, GPU delegates on Android, Metal and CoreML delegates on iOS, and XNNPack delegate on Desktop platforms.

Key Features

  • Multi-platform Support for Android, iOS, Windows, Mac, Linux.
  • Flexibility to use any TFLite Model.
  • Acceleration using multi-threading and delegate support.
  • Similar structure as TensorFlow Lite Java API.
  • Inference speeds close to native Android Apps built using the Java API.
  • You can choose to use any TensorFlow version by building binaries locally.
  • Run inference in different isolates to prevent jank in UI thread.

(Important) Initial setup : Add dynamic libraries to your app

Android

  1. Place the script install.sh (Linux/Mac) or install.bat (Windows) at the root of your project.

  2. Execute sh install.sh (Linux) / install.bat (Windows) at the root of your project to automatically download and place binaries at appropriate folders.

    Note: The binaries installed will not include support for GpuDelegateV2 and NnApiDelegate however InterpreterOptions().useNnApiForAndroid can still be used.

  3. Use sh install.sh -d (Linux) or install.bat -d (Windows) instead if you wish to use these GpuDelegateV2 and NnApiDelegate.

These scripts install pre-built binaries based on latest stable tensorflow release. For info about using other tensorflow versions follow instructions in wiki.

iOS

  1. Download TensorFlowLiteC.framework. For building a custom version of tensorflow, follow instructions in wiki.
  2. Place the TensorFlowLiteC.framework in the pub-cache folder of this package.

Pub-Cache folder location: (ref)

  • ~/.pub-cache/hosted/pub.dartlang.org/tflite_flutter-<plugin-version>/ios/ (Linux/ Mac)
  • %LOCALAPPDATA%\Pub\Cache\hosted\pub.dartlang.org\tflite_flutter-<plugin-version>\ios\ (Windows)

Desktop

Follow instructions in this guide to build and use desktop binaries.

TFLite Flutter Helper Library

A dedicated library with simple architecture for processing and manipulating input and output of TFLite Models. API design and documentation is identical to the TensorFlow Lite Android Support Library. Strongly recommended to be used with tflite_flutter_plugin. Learn more.

Examples

Title Code Demo Blog
Text Classification App Code Blog/Tutorial
Image Classification App Code -
Object Detection App Code Blog/Tutorial
Reinforcement Learning App Code Blog/Tutorial

Import

import 'package:tflite_flutter/tflite_flutter.dart';

Usage instructions

Creating the Interpreter

  • From asset

    Place your_model.tflite in assets directory. Make sure to include assets in pubspec.yaml.

    final interpreter = await tfl.Interpreter.fromAsset('your_model.tflite');

Refer to the documentation for info on creating interpreter from buffer or file.

Performing inference

See TFLite Flutter Helper Library for easy processing of input and output.

  • For single input and output

    Use void run(Object input, Object output).

    // For ex: if input tensor shape [1,5] and type is float32
    var input = [[1.23, 6.54, 7.81. 3.21, 2.22]];
    
    // if output tensor shape [1,2] and type is float32
    var output = List.filled(1*2, 0).reshape([1,2]);
    
    // inference
    interpreter.run(input, output);
    
    // print the output
    print(output);
  • For multiple inputs and outputs

    Use void runForMultipleInputs(List<Object> inputs, Map<int, Object> outputs).

    var input0 = [1.23];  
    var input1 = [2.43];  
    
    // input: List<Object>
    var inputs = [input0, input1, input0, input1];  
    
    var output0 = List<double>.filled(1, 0);  
    var output1 = List<double>.filled(1, 0);
    
    // output: Map<int, Object>
    var outputs = {0: output0, 1: output1};
    
    // inference  
    interpreter.runForMultipleInputs(inputs, outputs);
    
    // print outputs
    print(outputs)

Closing the interpreter

interpreter.close();

Improve performance using delegate support

Note: This feature is under testing and could be unstable with some builds and on some devices.
  • NNAPI delegate for Android

    var interpreterOptions = InterpreterOptions()..useNnApiForAndroid = true;
    final interpreter = await Interpreter.fromAsset('your_model.tflite',
        options: interpreterOptions);
    

    or

    var interpreterOptions = InterpreterOptions()..addDelegate(NnApiDelegate());
    final interpreter = await Interpreter.fromAsset('your_model.tflite',
        options: interpreterOptions);
    
  • GPU delegate for Android and iOS

    • Android GpuDelegateV2

      final gpuDelegateV2 = GpuDelegateV2(
              options: GpuDelegateOptionsV2(
              false,
              TfLiteGpuInferenceUsage.fastSingleAnswer,
              TfLiteGpuInferencePriority.minLatency,
              TfLiteGpuInferencePriority.auto,
              TfLiteGpuInferencePriority.auto,
          ));
      
      var interpreterOptions = InterpreterOptions()..addDelegate(gpuDelegateV2);
      final interpreter = await Interpreter.fromAsset('your_model.tflite',
          options: interpreterOptions);
    • iOS Metal Delegate (GpuDelegate)

      final gpuDelegate = GpuDelegate(
            options: GpuDelegateOptions(true, TFLGpuDelegateWaitType.active),
          );
      var interpreterOptions = InterpreterOptions()..addDelegate(gpuDelegate);
      final interpreter = await Interpreter.fromAsset('your_model.tflite',
          options: interpreterOptions);

Refer Tests to see more example code for each method.

Credits

  • Tian LIN, Jared Duke, Andrew Selle, YoungSeok Yoon, Shuangfeng Li from the TensorFlow Lite Team for their invaluable guidance.
  • Authors of dart-lang/tflite_native.
Comments
  • Cant run app on IOS

    Cant run app on IOS

    When i build the project i got this message:

     ld: warning: Could not find or use auto-linked library 'swiftSwiftOnoneSupport'
                   ld: warning: Could not find or use auto-linked library 'swiftCoreFoundation'
                   ld: warning: Could not find or use auto-linked library 'swiftCompatibility50'
                   ld: warning: Could not find or use auto-linked library 'swiftObjectiveC'
                   ld: warning: Could not find or use auto-linked library 'swiftUIKit'
                   ld: warning: Could not find or use auto-linked library 'swiftDarwin'
                   ld: warning: Could not find or use auto-linked library 'swiftQuartzCore'
                   ld: warning: Could not find or use auto-linked library 'swiftCore'
                   ld: warning: Could not find or use auto-linked library 'swiftCoreGraphics'
                   ld: warning: Could not find or use auto-linked library 'swiftFoundation'
                   ld: warning: Could not find or use auto-linked library 'swiftCoreImage'
                   ld: warning: Could not find or use auto-linked library 'swiftCompatibilityDynamicReplacements'
                   ld: warning: Could not find or use auto-linked library 'swiftMetal'
                   ld: warning: Could not find or use auto-linked library 'swiftDispatch'
                   ld: warning: Could not find or use auto-linked library 'swiftCoreMedia'
                   ld: warning: Could not find or use auto-linked library 'swiftCoreAudio'
                   Undefined symbols for architecture arm64:
                     "value witness table for Builtin.UnknownObject", referenced from:
                         full type metadata for tflite_flutter.SwiftTfliteFlutter in libtflite_flutter.a(SwiftTfliteFlutter.o)
                     "__swift_FORCE_LOAD_$_swiftCompatibilityDynamicReplacements", referenced from:
                         __swift_FORCE_LOAD_$_swiftCompatibilityDynamicReplacements_$_tflite_flutter in libtflite_flutter.a(SwiftTfliteFlutter.o)
                        (maybe you meant: __swift_FORCE_LOAD_$_swiftCompatibilityDynamicReplacements_$_tflite_flutter)
                     "_swift_allocObject", referenced from:
                         @objc tflite_flutter.SwiftTfliteFlutter.handle(_: __C.FlutterMethodCall, result: (Any?) -> ()) -> () in libtflite_flutter.a(SwiftTfliteFlutter.o)
                     "static (extension in Foundation):Swift.String._unconditionallyBridgeFromObjectiveC(__C.NSString?) -> Swift.String", referenced from:
                         tflite_flutter.SwiftTfliteFlutter.handle(_: __C.FlutterMethodCall, result: (Any?) -> ()) -> () in libtflite_flutter.a(SwiftTfliteFlutter.o)
                     "_swift_unknownObjectRelease", referenced from:
                         static tflite_flutter.SwiftTfliteFlutter.register(with: __C.FlutterPluginRegistrar) -> () in libtflite_flutter.a(SwiftTfliteFlutter.o)
                         @nonobjc __C.FlutterMethodChannel.__allocating_init(name: Swift.String, binaryMessenger: __C.FlutterBinaryMessenger) -> __C.FlutterMethodChannel in libtflite_flutter.a(SwiftTfliteFlutter.o)
                         @objc static tflite_flutter.SwiftTfliteFlutter.register(with: __C.FlutterPluginRegistrar) -> () in libtflite_flutter.a(SwiftTfliteFlutter.o)
                         reabstraction thunk helper from @escaping @callee_unowned @convention(block) (@unowned Swift.AnyObject?) -> () to @escaping @callee_guaranteed (@in_guaranteed Any?) -> () in libtflite_flutter.a(SwiftTfliteFlutter.o)
                     "_swift_release", referenced from:
                         tflite_flutter.SwiftTfliteFlutter.handle(_: __C.FlutterMethodCall, result: (Any?) -> ()) -> () in libtflite_flutter.a(SwiftTfliteFlutter.o)
                         ___swift_destroy_boxed_opaque_existential_0 in libtflite_flutter.a(SwiftTfliteFlutter.o)
                         @objc tflite_flutter.SwiftTfliteFlutter.handle(_: __C.FlutterMethodCall, result: (Any?) -> ()) -> () in libtflite_flutter.a(SwiftTfliteFlutter.o)
                     "_swift_deallocObject", referenced from:
                         l_objectdestroy in libtflite_flutter.a(SwiftTfliteFlutter.o)
                     "_swift_retain", referenced from:
                         tflite_flutter.SwiftTfliteFlutter.handle(_: __C.FlutterMethodCall, result: (Any?) -> ()) -> () in libtflite_flutter.a(SwiftTfliteFlutter.o)
                     "_swift_unknownObjectRetain", referenced from:
                         @objc static tflite_flutter.SwiftTfliteFlutter.register(with: __C.FlutterPluginRegistrar) -> () in libtflite_flutter.a(SwiftTfliteFlutter.o)
                     "Swift._bridgeAnythingToObjectiveC<A>(A) -> Swift.AnyObject", referenced from:
                         reabstraction thunk helper from @escaping @callee_unowned @convention(block) (@unowned Swift.AnyObject?) -> () to @escaping @callee_guaranteed (@in_guaranteed Any?) -> () in libtflite_flutter.a(SwiftTfliteFlutter.o)
                     "(extension in Foundation):Swift.String._bridgeToObjectiveC() -> __C.NSString", referenced from:
                         @nonobjc __C.FlutterMethodChannel.__allocating_init(name: Swift.String, binaryMessenger: __C.FlutterBinaryMessenger) -> __C.FlutterMethodChannel in libtflite_flutter.a(SwiftTfliteFlutter.o)
                     "_swift_getObjCClassFromMetadata", referenced from:
                         @nonobjc __C.FlutterMethodChannel.__allocating_init(name: Swift.String, binaryMessenger: __C.FlutterBinaryMessenger) -> __C.FlutterMethodChannel in libtflite_flutter.a(SwiftTfliteFlutter.o)
                     "static Swift.String.+ infix(Swift.String, Swift.String) -> Swift.String", referenced from:
                         tflite_flutter.SwiftTfliteFlutter.handle(_: __C.FlutterMethodCall, result: (Any?) -> ()) -> () in libtflite_flutter.a(SwiftTfliteFlutter.o)
                     "type metadata for Swift.String", referenced from:
                         tflite_flutter.SwiftTfliteFlutter.handle(_: __C.FlutterMethodCall, result: (Any?) -> ()) -> () in libtflite_flutter.a(SwiftTfliteFlutter.o)
                     "__swift_FORCE_LOAD_$_swiftCompatibility50", referenced from:
                         __swift_FORCE_LOAD_$_swiftCompatibility50_$_tflite_flutter in libtflite_flutter.a(SwiftTfliteFlutter.o)
                        (maybe you meant: __swift_FORCE_LOAD_$_swiftCompatibility50_$_tflite_flutter)
                     "_swift_bridgeObjectRelease", referenced from:
                         @nonobjc __C.FlutterMethodChannel.__allocating_init(name: Swift.String, binaryMessenger: __C.FlutterBinaryMessenger) -> __C.FlutterMethodChannel in libtflite_flutter.a(SwiftTfliteFlutter.o)
                         tflite_flutter.SwiftTfliteFlutter.handle(_: __C.FlutterMethodCall, result: (Any?) -> ()) -> () in libtflite_flutter.a(SwiftTfliteFlutter.o)
                     "_swift_getObjCClassMetadata", referenced from:
                         type metadata accessor for __C.FlutterMethodChannel in libtflite_flutter.a(SwiftTfliteFlutter.o)
                         @objc static tflite_flutter.SwiftTfliteFlutter.register(with: __C.FlutterPluginRegistrar) -> () in libtflite_flutter.a(SwiftTfliteFlutter.o)
                     "_swift_getInitializedObjCClass", referenced from:
                         type metadata accessor for __C.FlutterMethodChannel in libtflite_flutter.a(SwiftTfliteFlutter.o)
                         type metadata accessor for tflite_flutter.SwiftTfliteFlutter in libtflite_flutter.a(SwiftTfliteFlutter.o)
                         tflite_flutter.SwiftTfliteFlutter.handle(_: __C.FlutterMethodCall, result: (Any?) -> ()) -> () in libtflite_flutter.a(SwiftTfliteFlutter.o)
                     "Swift.String.init(_builtinStringLiteral: Builtin.RawPointer, utf8CodeUnitCount: Builtin.Word, isASCII: Builtin.Int1) -> Swift.String", referenced from:
                         static tflite_flutter.SwiftTfliteFlutter.register(with: __C.FlutterPluginRegistrar) -> () in libtflite_flutter.a(SwiftTfliteFlutter.o)
                         tflite_flutter.SwiftTfliteFlutter.handle(_: __C.FlutterMethodCall, result: (Any?) -> ()) -> () in libtflite_flutter.a(SwiftTfliteFlutter.o)
                   ld: symbol(s) not found for architecture arm64
    
    bug help wanted iOS 
    opened by IliaKhuzhakhmetovRoonyx 21
  • Custom YOLO Model

    Custom YOLO Model

    I'm using the example code for the object detection app. Is there anything else in the Classifier file code that needs to be changed for different models besides MODEL_FILE_NAME, LABEL_FILE_NAME, and INPUT_SIZE?

    Edit: The model is YOLOv4Tiny and works fine running it in python. I am using TexMexMax's code below as a reference. In the ReadMe section he says to change the image_conversion.dart file in the tflite_flutter_helper package (0.3.0 for me) and after doing that my build breaks. Changing back to an unaltered tflite_flutter_helper 0.2.0 I can run the model, but the results are incorrect.

    https://github.com/TexMexMax/object_detection_flutter

    opened by jmtrutna 19
  • Bad state: failed precondition

    Bad state: failed precondition

    Hello, I'm working on app that uses my custom created object detection .tflite model. I followed code described in this tutorial: https://github.com/am15h/object_detection_flutter but I'm getting Bad state: failed precondition error in this line: checkState(tfLiteTensorCopyFromBuffer(_tensor, ptr.cast(), bytes.length) == TfLiteStatus.ok); at tensor.dart. Here is my code:

      Future<List<Recognition>> detectObjects2(XFile imageFile) async {
        TensorImage tensorImage = await createTensorImage(imageFile);
    
        final Interpreter interpreter =
            await Interpreter.fromAsset('mobilenet.tflite');
        List<String> labels = await FileUtil.loadLabels("assets/labelmap.txt");
    
        var outputTensors = interpreter.getOutputTensors();
    
        List<List<int>> _outputShapes = [];
        List<TfLiteType> _outputTypes = [];
    
        for (var tensor in outputTensors) {
          _outputShapes.add(tensor.shape);
          _outputTypes.add(tensor.type);
        }
        TensorBuffer outputScores = TensorBufferFloat(_outputShapes[0]);
        TensorBuffer outputLocations = TensorBufferFloat(_outputShapes[1]);
        TensorBuffer numLocations = TensorBufferFloat(_outputShapes[2]);
        TensorBuffer outputClasses = TensorBufferFloat(_outputShapes[3]);
        List<Object> inputs = [tensorImage.buffer];
    
        Map<int, Object> outputs = {
          0: outputScores.buffer,
          1: outputLocations.buffer,
          2: numLocations.buffer,
          3: outputClasses.buffer,
        };
    
        interpreter.runForMultipleInputs(inputs, outputs);
    
        int resultsCount = min(15, numLocations.getIntValue(0));
        int labelOffset = 1;
        List<Recognition> recognitions = [];
        for (int i = 0; i < resultsCount; i++) {
          // Prediction score
          var score = outputScores.getDoubleValue(i);
          // Label string
          var labelIndex = outputClasses.getIntValue(i) + labelOffset;
          var label = labels.elementAt(labelIndex);
    
          if (score > 0.4) {
            recognitions.add(
              Recognition(i, label, score),
            );
          }
        }
        return recognitions;
      }
    
      Future<TensorImage> createTensorImage(XFile imageFile) async {
        final bytes = await File(imageFile.path).readAsBytes();
        final img.Image? image = img.decodeImage(bytes);
        TensorImage _inputImage = TensorImage(TfLiteType.float32);
        _inputImage.loadImage(image!);
        int padSize = max(_inputImage.height, _inputImage.width);
        ImageProcessor imageProcessor = ImageProcessorBuilder()
            .add(ResizeWithCropOrPadOp(padSize, padSize))
            .add(ResizeOp(300, 300, ResizeMethod.BILINEAR))
            .build();
        _inputImage = imageProcessor.process(_inputImage);
        return _inputImage;
      }
    

    and console output: [log] Error AiCubit: Bad state: failed precondition (log created by me, nothing comes from library itself) Thanks for help in advance ;)

    opened by sDobrzanski 15
  • can't load my custom model

    can't load my custom model

    I am using TexMexMax's code to make detector app .. first, my dataset is only 1400 image and just one class.. I'm trained my model on yolo v5m "although the accuracy is not good enough :( " .. however, I tried to make like TexMexMax's code and tried to alter image_conversions.dart in tflite_flutter_helper 0.3.1 plugin but I get errors about this plugin .. can you help me please ? I have no much time :( I hope you can reply as soon as possible ..

    opened by programmer-huda123 13
  • Unhandled Exception: Bad state: failed precondition

    Unhandled Exception: Bad state: failed precondition

    Hello, I am trying to use the mediapipe facemesh model, which is this in tfjs format, but I can't get it to work, I have no idea what I'm doing wrong, I'd appreciate any help, thanks

    Model: https://github.com/google/mediapipe/tree/master/mediapipe/models#face-mesh File: https://github.com/google/mediapipe/blob/master/mediapipe/models/face_landmark.tflite

    Code:

    Future _loadModel() async {
        _interpreter = await Interpreter.fromAsset('models/face_landmark.tflite');
        print('Interpreter loaded successfully');
      }
    
     _onStream() async {
        final CameraDescription description =
            await ScannerUtils.getCamera(_direction);
        controller = CameraController(description, ResolutionPreset.ultraHigh,
            enableAudio: false);
        await controller.initialize();
        setState(() {});
        await controller.startImageStream((CameraImage img) async {
          if (!_isDetecting) {
            var input = img.planes.map((plane) {return plane.bytes;}).toList();
            int list0 = 0;
            var output = new Map<int, Object>.from({0: list0});
            _interpreter.runForMultipleInputs(input, output);
    
            print(output.toString());
    
            _isDetecting = false;
          }
        });
      }
    

    Error:

    2020-07-10 18:59:50.076078-0500 Runner[24953:4058491] flutter: Interpreter loaded successfully 2020-07-10 18:59:50.683677-0500 Runner[24953:4058491] [VERBOSE-2:ui_dart_state.cc(166)] Unhandled Exception: Bad state: failed precondition #0 ced (PXe:71) #1 jca.Tkd (XYe:150) #2 gca.Fkd (UYe:183) #3 _ho._cxb.<anonymous closure> (DPe:68) #4 _ho._cxb.<anonymous closure> (DPe:63) #5 am.yjb.<anonymous closure> (HOe:412) #6 _fma (tLe:1198) #7 _qc.wza (tLe:1100) #8 _qc.Bza (tLe:1005) #9 _BufferingStreamSubscription._Pya (qLe:357) #10 _Kb.Rza (qLe:611) #11 _Nb.TBa (qLe:730) #12 _Ib.RBa.<anonymous closure> (qLe:687) #13 _ema (tLe:1182) #14 _qc.vza (tLe:1093) #15 _qc.Aza (tLe:997) #16 _qc.Iza.<anonymous closure> (tLe:1037) #17 _ema (tLe:1190) #18 _qc.vza (tLe:1093) #19 _qc.Aza (tLe:997) #20 _qc.Iza.<anonymous closure> (tLe:1037) #21 _Mla (oLe:41) #22 _Nla (oLe:50)

    Outputs from model:

    [
          {
            faceInViewConfidence: 1, // The probability of a face being present.
            boundingBox: { // The bounding box surrounding the face.
              topLeft: [232.28, 145.26],
              bottomRight: [449.75, 308.36],
            },
            mesh: [ // The 3D coordinates of each facial landmark.
              [92.07, 119.49, -17.54],
              [91.97, 102.52, -30.54],
              ...
            ],
            scaledMesh: [ // The 3D coordinates of each facial landmark, normalized.
              [322.32, 297.58, -17.54],
              [322.18, 263.95, -30.54]
            ],
            annotations: { // Semantic groupings of the `scaledMesh` coordinates.
              silhouette: [
                [326.19, 124.72, -3.82],
                [351.06, 126.30, -3.00],
                ...
              ],
              ...
            }
          }
        ]
    

    Info: https://www.npmjs.com/package/@tensorflow-models/facemesh

    UPDATE

    I update my code to this:

    try {
          Interpreter interpreter =
              await Interpreter.fromAsset("models/face_detection_front.tflite");
    
          var _inputShape = interpreter.getInputTensor(0).shape;
          var _outputShape = interpreter.getOutputTensor(0).shape;
          var _outputType = interpreter.getOutputTensor(0).type;
    
          ImageProcessor imageProcessor = ImageProcessorBuilder()
              .add(ResizeOp(
                  _inputShape[1], _inputShape[2], ResizeMethod.NEAREST_NEIGHBOUR))
              .build();
          var file = File(
              (await picker.getImage(source: ImageSource.gallery, maxWidth: 560))
                  .path);
          TensorImage tensorImage = TensorImage.fromFile(file);
          tensorImage = imageProcessor.process(tensorImage);
    
          var _outputBuffer =
              TensorBuffer.createFixedSize(_outputShape, _outputType);
          print(_outputShape.toString());
          interpreter.run(tensorImage.buffer, _outputBuffer.getBuffer());
          print(_outputBuffer);
        } catch (e) {
          print(e);
        }
    

    But i always get flutter: Bad state: failed precondition

    opened by xellDart 11
  • How Do I load my model from a file instead of an asset?

    How Do I load my model from a file instead of an asset?

    I think I may have solved it. Still running tests but it looks very promising. The key (perhaps): loading the model from File rather than from the Asset bundle directly. It really seems like when you let the interpreter draw from an asset-bundle byte stream directly it's not ever letting go all the way. I hoped that by controlling the asset -> file myself and then handing off the local file to the interpreter that it might release, and it looks so far like it is.

    Leaving this open till I confirm-- if anyone has had any similar experiences to any of this, I'd love to hear about it.

    Originally posted by @espbee in https://github.com/am15h/tflite_flutter_plugin/issues/170#issuecomment-1019370216

    documentation 
    opened by jmtrutna 8
  • How to use iOS Metal Delegate (GpuDelegate)?

    How to use iOS Metal Delegate (GpuDelegate)?

    It is mentioned in the Readme, that this function is available:

    iOS Metal Delegate (GpuDelegate)

    If I use the following parameter my app is starting and working OK:

     var interpreterOptions = InterpreterOptions()..threads = 4;
    

    If I use the following parameter the app is starting, but is not working:

    final gpuDelegate = GpuDelegate(
          options: GpuDelegateOptions(true, TFLGpuDelegateWaitType.active),
        );
    var interpreterOptions = InterpreterOptions()..addDelegate(gpuDelegate);
    

    In XCode log I see the following error:

    Runner[1383:458287] flutter: Error while creating interpreter: Invalid argument(s): Failed to lookup symbol (dlsym(RTLD_DEFAULT, TFLGpuDelegateCreate): symbol not found)

    From that I assumed, that an appropriate TensorFlowLiteC.framework should be used:

    1. I tried the framework from release v0.5.0 and it is not working.
    2. I even tried to follow the steps behind this link, but ended up with this issue: https://github.com/tensorflow/tensorflow/issues/48464

    So my question is: how to let iOS Metal Delegate work? Do you have an appropriate and compiled TensorFlowLiteC.framework? Can you share it?

    opened by mspnr 8
  • Error: Failed to lookup symbol in iOS release (archive) build

    Error: Failed to lookup symbol in iOS release (archive) build

    Hello, So when i use my app in debug mode everything works completely fine, no errors and my tflite model runs properly. Then one day I get a support request from a user on the AppStore saying they can't get it to work even though i knew it worked for me. So then I realized it has to do with release mode:

    Here is the code that is causing the issue:

    Future recognize(List imageList) async { print("recognize"); debugString += "\nrunning model"; final interpreter = await tfl.Interpreter.fromAsset('v3-model.tflite'); debugString += "\n1"; var input = imageList.reshape([1,224,224,3]); debugString += "\n2"; List output = List(1*4).reshape([1,4]); debugString += "\n3"; interpreter.run(input, output); debugString += "\n4"; _recognition = output; debugString += "\n5"; interpreter.close(); debugString += "\nmodel done"; // debugString += "Error: $error";

    }

    Here is the output(release and debug respectively):

    Release Mode:

    flutter: scan 2021-03-12 10:55:59.159778-0800 Runner[54121:3778134] [VERBOSE-2:ui_dart_state.cc(186)] Unhandled Exception: Invalid argument(s): Failed to lookup symbol (dlsym(RTLD_DEFAULT, TfLiteModelCreate): symbol not found) #0 DynamicLibrary.lookup (dart:ffi-patch ffi_dynamic_library_patch.dart:31) #1 tfLiteModelCreateFromBuffer (package:tflite_flutter/src/bindings/model.dart:11) #2 new Model.fromBuffer (package:tflite_flutter/src/model.dart) #3 new Interpreter.fromBuffer (package:tflite_flutter/src/interpreter.dart:90) #4 Interpreter.fromAsset (package:tflite_flutter/src/interpreter.dart:114)

    #5 CameraState.recognize (package:filament_left/Screens/camera.dart:125)

    #6 CameraState.scanImage (package:filament_left/Screens/camera.dart:111)

    2021-03-12 10:55:59.739733-0800 Runner[54121:3778134] flutter: File Uploaded 2021-03-12 10:55:59.743840-0800 Runner[54121:3778214] BackgroundSession <2C5183FE-9D06-46CD-BC99-57D9C1492583> connection to background transfer daemon invalidated

    Debug Mode:

    flutter: scan 2021-03-12 11:36:48.821404-0800 Runner[54390:3792113] Initialized TensorFlow Lite runtime. 2021-03-12 11:36:49.571281-0800 Runner[54390:3792126] BackgroundSession connection to background transfer daemon invalidated 2021-03-12 11:36:51.313935-0800 Runner[54390:3792113] flutter: postconvert 2021-03-12 11:36:51.314804-0800 Runner[54390:3792113] flutter: coordinate(mainly height) - height than width 2021-03-12 11:36:51.315632-0800 Runner[54390:3792113] flutter: 275.81599473953247 2021-03-12 11:36:51.316580-0800 Runner[54390:3792113] flutter: 490.3395462036133 2021-03-12 11:36:51.316995-0800 Runner[54390:3792113] flutter: coordinate(mainly width) - height than width 2021-03-12 11:36:51.317061-0800 Runner[54390:3792113] flutter: 228.4491491317749 2021-03-12 11:36:51.317102-0800 Runner[54390:3792113] flutter: 406.13182067871094 2021-03-12 11:36:51.317653-0800 Runner[54390:3792113] flutter: coordinate(mainly height) - height than width 2021-03-12 11:36:51.317861-0800 Runner[54390:3792113] flutter: 564.8450231552124 2021-03-12 11:36:51.317916-0800 Runner[54390:3792113] flutter: 1004.1689300537109 2021-03-12 11:36:51.317954-0800 Runner[54390:3792113] flutter: coordinate(mainly width) - height than width 2021-03-12 11:36:51.317989-0800 Runner[54390:3792113] flutter: 514.749641418457 2021-03-12 11:36:51.318323-0800 Runner[54390:3792113] flutter: 915.1104736328125 2021-03-12 11:36:51.318956-0800 Runner[54390:3792113] flutter: 1.76099492754787 2021-03-12 11:36:51.336338-0800 Runner[54390:3792113] flutter: File Uploaded

    I believe that the error is coming from this line: Unhandled Exception: Invalid argument(s): Failed to lookup symbol (dlsym(RTLD_DEFAULT, TfLiteModelCreate): symbol not found)

    Flutter doctor:

    [✓] Flutter (Channel stable, 2.0.1, on macOS 11.2.2 20D80 darwin-x64, locale en) • Flutter version 2.0.1 at /Users/masonhorder/flutter • Framework revision c5a4b40 (8 days ago), 2021-03-04 09:47:48 -0800 • Engine revision 40441def69 • Dart version 2.12.0

    Thanks so much, Mason

    help wanted iOS 
    opened by masonhorder 8
  • Regular TensorFlow ops are not supported by this interpreter. Make sure you apply/link the Flex delegate before inference.

    Regular TensorFlow ops are not supported by this interpreter. Make sure you apply/link the Flex delegate before inference.

    Hi,

    I'm getting the following error when initializing interpreter:

    I/tflite  ( 6266): Initialized TensorFlow Lite runtime.
    E/tflite  ( 6266): Regular TensorFlow ops are not supported by this interpreter. Make sure you apply/link the Flex delegate before inference.
    E/tflite  ( 6266): Node number 0 (FlexPlaceholder) failed to prepare.
    E/flutter ( 6266): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: Bad state: failed precondition
    E/flutter ( 6266): #0      checkState (package:quiver/check.dart:73:5)
    E/flutter ( 6266): #1      Interpreter.allocateTensors (package:tflite_flutter/src/interpreter.dart:150:5)
    E/flutter ( 6266): #2      new Interpreter._ (package:tflite_flutter/src/interpreter.dart:31:5)
    E/flutter ( 6266): #3      new Interpreter._create (package:tflite_flutter/src/interpreter.dart:42:24)
    E/flutter ( 6266): #4      new Interpreter.fromBuffer (package:tflite_flutter/src/interpreter.dart:91:37)
    E/flutter ( 6266): #5      Interpreter.fromAsset (package:tflite_flutter/src/interpreter.dart:114:24)
    E/flutter ( 6266): <asynchronous suspension>
    E/flutter ( 6266): #6      _MyHomePageState.loadModel (package:text_gen_gpu/main.dart:321:20)
    E/flutter ( 6266): <asynchronous suspension>
    E/flutter ( 6266): #7      _MyHomePageState.init (package:text_gen_gpu/main.dart:299:5)
    E/flutter ( 6266): <asynchronous suspension>
    E/flutter ( 6266): #8      _MyHomePageState.initState.<anonymous closure> (package:text_gen_gpu/main.dart)
    E/flutter ( 6266): <asynchronous suspension>
    E/flutter ( 6266): 
    

    Im initializing on cpu:

    var interpreterOptions = InterpreterOptions()..threads = NUM_LITE_THREADS;
        _interpreter = await Interpreter.fromAsset(
          modelFile,
          options: interpreterOptions,
        );
    
    opened by farazk86 8
  • Unable to loading a Custom TFlite Model

    Unable to loading a Custom TFlite Model

    I follow along this Colab to train a custom model.

    Conversion process Colab

    After completing the training process I converted the .pb to .tflite and I got these files. When I loaded the model into the official Android demo I got the following error:

     java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.sd_detect/com.example.sd_detect.MainActivity}: java.lang.IllegalStateException: This model does not contain associated files, and is not a Zip file.
    

    The solution to that error is discussed in this issue

    I followed the solution:

    Installing the metadata library with:

    pip install tflite-support
    
    

    and then executing the following command into python

    >>> from tflite_support import metadata as _metadata
    >>> populator = _metadata.MetadataPopulator.with_model_file('final_model.tflite')
    >>> populator.load_associated_files(["final_model.txt"])
    >>> populator.populate() 
    

    And I got the following warning:

    /home/username/.local/lib/python3.8/site-packages/tensorflow_lite_support/metadata/python/metadata.py:342: UserWarning: File, 'final_model.txt', does not exsit in the metadata. But packing it to tflite model is still allowed.
      warnings.warn(
    

    Back to Android Studio example I was able to run the model successfully, by just modifying this information:

    private static final String TF_OD_API_MODEL_FILE = "final_model.tflite";  
    private static final boolean IS_MODEL_QUANTIZED = false;
    private static final String TF_OD_API_LABELS_FILE = "final_model.txt";  
    

    But when I bring my model to my Flutter application, I got the following exeption:

    /// Throws a [StateError] if the given [expression] is `false`.
    
    void  checkState(bool expression, {message}) {
    
    if (!expression) {
    
    throw  StateError(_resolveMessage(message, 'failed precondition'));
    
    }
    
    }
    

    The flutter project is fully working with coco_ssd_mobilenet_v1_1.0_quant_2018_06_29

    I also tried to re-run the metadata commands on my flutter application assets but still the same issue.

    What am I missing?

    Edited: In Android Studio (Android App) I set the variable IS_MODEL_QUANTIZED to false, is the issue related to this?

    opened by mlopez0 8
  • Duplicate symbols preventing launch on iOS

    Duplicate symbols preventing launch on iOS

    Hey, for days and hours I've been trying to fix this issue now, but I've run out of things to try to be honest. I try to flutter run but it gives me this output:

    Launching lib/main.dart on iPad in debug mode...
     
    Automatically signing iOS for device deployment using specified development team in Xcode project: XXXXXXX
    Running pod install...                                              5.0s
    Running Xcode build...                                                  
     └─Compiling, linking and signing...                         3.5s
    Xcode build done.                                           15.3s
    Failed to build iOS app
    Error output from Xcode build:
    ↳
        ** BUILD FAILED **
    
    
    Xcode's output:
    ↳
        7 warnings generated.
        In file included from /Users/username/Documents/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_crashlytics-0.2.1/ios/Classes/FLTFirebaseCrashlyticsPlugin.m:7:
        /Users/username/Desktop/projectgit/project_flutter/ios/Pods/Headers/Public/Firebase/Firebase.h:75:10: warning: "FirebaseAnalytics.framework is not included in your target. Please add `Firebase/Analytics` to your Podfile or add FirebaseAnalytics.framework to
        your project to ensure Firebase Messaging works as intended." [-W#warnings]
                #warning "FirebaseAnalytics.framework is not included in your target. Please add \
                 ^
        1 warning generated.
        duplicate symbol '_AnnotateRWLockDestroy' in:
            /Users/username/Desktop/projectgit/tflite_flutter_plugin/ios/TensorFlowLiteC.framework/TensorFlowLiteC(dynamic_annotations_c9bf866fe89c02b98f86dda9d34be0c4.o)
            /Users/username/Desktop/projectgit/project_flutter/build/ios/Debug-iphoneos/abseil.framework/abseil(dynamic_annotations.o)
        duplicate symbol '_ValgrindSlowdown' in:
            /Users/username/Desktop/projectgit/tflite_flutter_plugin/ios/TensorFlowLiteC.framework/TensorFlowLiteC(dynamic_annotations_c9bf866fe89c02b98f86dda9d34be0c4.o)
            /Users/username/Desktop/projectgit/project_flutter/build/ios/Debug-iphoneos/abseil.framework/abseil(dynamic_annotations.o)
        duplicate symbol '_AnnotateEnableRaceDetection' in:
            /Users/username/Desktop/projectgit/tflite_flutter_plugin/ios/TensorFlowLiteC.framework/TensorFlowLiteC(dynamic_annotations_c9bf866fe89c02b98f86dda9d34be0c4.o)
            /Users/username/Desktop/projectgit/project_flutter/build/ios/Debug-iphoneos/abseil.framework/abseil(dynamic_annotations.o)
        duplicate symbol '_AnnotateIgnoreWritesBegin' in:
            /Users/username/Desktop/projectgit/tflite_flutter_plugin/ios/TensorFlowLiteC.framework/TensorFlowLiteC(dynamic_annotations_c9bf866fe89c02b98f86dda9d34be0c4.o)
            /Users/username/Desktop/projectgit/project_flutter/build/ios/Debug-iphoneos/abseil.framework/abseil(dynamic_annotations.o)
        duplicate symbol '_AnnotateIgnoreReadsBegin' in:
            /Users/username/Desktop/projectgit/tflite_flutter_plugin/ios/TensorFlowLiteC.framework/TensorFlowLiteC(dynamic_annotations_c9bf866fe89c02b98f86dda9d34be0c4.o)
            /Users/username/Desktop/projectgit/project_flutter/build/ios/Debug-iphoneos/abseil.framework/abseil(dynamic_annotations.o)
        duplicate symbol '_AnnotateRWLockCreate' in:
            /Users/username/Desktop/projectgit/tflite_flutter_plugin/ios/TensorFlowLiteC.framework/TensorFlowLiteC(dynamic_annotations_c9bf866fe89c02b98f86dda9d34be0c4.o)
            /Users/username/Desktop/projectgit/project_flutter/build/ios/Debug-iphoneos/abseil.framework/abseil(dynamic_annotations.o)
        duplicate symbol '_AnnotateThreadName' in:
            /Users/username/Desktop/projectgit/tflite_flutter_plugin/ios/TensorFlowLiteC.framework/TensorFlowLiteC(dynamic_annotations_c9bf866fe89c02b98f86dda9d34be0c4.o)
            /Users/username/Desktop/projectgit/project_flutter/build/ios/Debug-iphoneos/abseil.framework/abseil(dynamic_annotations.o)
        duplicate symbol '_AnnotateBenignRace' in:
            /Users/username/Desktop/projectgit/tflite_flutter_plugin/ios/TensorFlowLiteC.framework/TensorFlowLiteC(dynamic_annotations_c9bf866fe89c02b98f86dda9d34be0c4.o)
            /Users/username/Desktop/projectgit/project_flutter/build/ios/Debug-iphoneos/abseil.framework/abseil(dynamic_annotations.o)
        duplicate symbol '_RunningOnValgrind' in:
            /Users/username/Desktop/projectgit/tflite_flutter_plugin/ios/TensorFlowLiteC.framework/TensorFlowLiteC(dynamic_annotations_c9bf866fe89c02b98f86dda9d34be0c4.o)
            /Users/username/Desktop/projectgit/project_flutter/build/ios/Debug-iphoneos/abseil.framework/abseil(dynamic_annotations.o)
        duplicate symbol '_AnnotateIgnoreWritesEnd' in:
            /Users/username/Desktop/projectgit/tflite_flutter_plugin/ios/TensorFlowLiteC.framework/TensorFlowLiteC(dynamic_annotations_c9bf866fe89c02b98f86dda9d34be0c4.o)
            /Users/username/Desktop/projectgit/project_flutter/build/ios/Debug-iphoneos/abseil.framework/abseil(dynamic_annotations.o)
        duplicate symbol '_AnnotateIgnoreReadsEnd' in:
            /Users/username/Desktop/projectgit/tflite_flutter_plugin/ios/TensorFlowLiteC.framework/TensorFlowLiteC(dynamic_annotations_c9bf866fe89c02b98f86dda9d34be0c4.o)
            /Users/username/Desktop/projectgit/project_flutter/build/ios/Debug-iphoneos/abseil.framework/abseil(dynamic_annotations.o)
        duplicate symbol '_AnnotateMemoryIsUninitialized' in:
            /Users/username/Desktop/projectgit/tflite_flutter_plugin/ios/TensorFlowLiteC.framework/TensorFlowLiteC(dynamic_annotations_c9bf866fe89c02b98f86dda9d34be0c4.o)
            /Users/username/Desktop/projectgit/project_flutter/build/ios/Debug-iphoneos/abseil.framework/abseil(dynamic_annotations.o)
        duplicate symbol '_AnnotateMemoryIsInitialized' in:
            /Users/username/Desktop/projectgit/tflite_flutter_plugin/ios/TensorFlowLiteC.framework/TensorFlowLiteC(dynamic_annotations_c9bf866fe89c02b98f86dda9d34be0c4.o)
            /Users/username/Desktop/projectgit/project_flutter/build/ios/Debug-iphoneos/abseil.framework/abseil(dynamic_annotations.o)
        duplicate symbol '_AnnotateBenignRaceSized' in:
            /Users/username/Desktop/projectgit/tflite_flutter_plugin/ios/TensorFlowLiteC.framework/TensorFlowLiteC(dynamic_annotations_c9bf866fe89c02b98f86dda9d34be0c4.o)
            /Users/username/Desktop/projectgit/project_flutter/build/ios/Debug-iphoneos/abseil.framework/abseil(dynamic_annotations.o)
        duplicate symbol '_AnnotateRWLockReleased' in:
            /Users/username/Desktop/projectgit/tflite_flutter_plugin/ios/TensorFlowLiteC.framework/TensorFlowLiteC(dynamic_annotations_c9bf866fe89c02b98f86dda9d34be0c4.o)
            /Users/username/Desktop/projectgit/project_flutter/build/ios/Debug-iphoneos/abseil.framework/abseil(dynamic_annotations.o)
        duplicate symbol '_AnnotateRWLockAcquired' in:
            /Users/username/Desktop/projectgit/tflite_flutter_plugin/ios/TensorFlowLiteC.framework/TensorFlowLiteC(dynamic_annotations_c9bf866fe89c02b98f86dda9d34be0c4.o)
            /Users/username/Desktop/projectgit/project_flutter/build/ios/Debug-iphoneos/abseil.framework/abseil(dynamic_annotations.o)
        ld: 16 duplicate symbols for architecture arm64
        clang: error: linker command failed with exit code 1 (use -v to see invocation)
        note: Using new build system
        note: Building targets in parallel
        note: Planning build
        note: Constructing build description
        warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99. (in target 'GoogleUtilities' from project 'Pods')
        warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99. (in target 'nanopb' from project 'Pods')
        warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99. (in target 'Reachability' from project 'Pods')
        warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99. (in target 'Protobuf' from project 'Pods')
        warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99. (in target 'PromisesObjC' from project 'Pods')
        warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99. (in target 'GoogleDataTransport' from project 'Pods')
        warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99. (in target 'webview_flutter' from project 'Pods')
        warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99. (in target 'shared_preferences' from project 'Pods')
        warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99. (in target 'rate_my_app' from project 'Pods')
        warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99. (in target 'permission_handler' from project 'Pods')
        warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99. (in target 'path_provider' from project 'Pods')
        warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99. (in target 'device_info' from project 'Pods')
        warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99. (in target 'keyboard_visibility' from project 'Pods')
        warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99. (in target 'connectivity' from project 'Pods')
        warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99. (in target 'GoogleDataTransportCCTSupport' from project 'Pods')
        warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99. (in target 'FirebaseCoreDiagnostics' from project 'Pods')
        warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99. (in target 'FirebaseCore' from project 'Pods')
        warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99. (in target 'FirebaseInstallations' from project 'Pods')
        warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99. (in target 'FirebaseInstanceID' from project 'Pods')
        warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99. (in target 'FirebaseCrashlytics' from project 'Pods')
        warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99. (in target 'FirebaseMessaging' from project 'Pods')
        warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99. (in target 'firebase_core' from project 'Pods')
        warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99. (in target 'firebase_messaging' from project 'Pods')
        warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99. (in target 'firebase_crashlytics' from project 'Pods')
        warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99. (in target 'FirebaseCoreDiagnosticsInterop' from project 'Pods')
        warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99. (in target 'FirebaseFirestore' from project 'Pods')
        warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99. (in target 'Flutter' from project 'Pods')
        warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99. (in target 'FirebaseAnalyticsInterop' from project 'Pods')
        warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99. (in target 'Firebase' from project 'Pods')
    
    Could not build the precompiled application for the device.
    
    Error launching application on iPad 
    

    My flutter doctor output:

    [✓] Flutter (Channel stable, 1.22.0, on Mac OS X 10.15.6 19G71a, locale en-GB)
        • Flutter version 1.22.0 at /Users/username/Documents/Flutter/flutter
        • Framework revision d408d302e2 (6 days ago), 2020-09-29 11:49:17 -0700
        • Engine revision 5babba6c4d
        • Dart version 2.10.0
    
    [✗] Android toolchain - develop for Android devices
        ✗ Unable to locate Android SDK.
          Install Android Studio from:
          https://developer.android.com/studio/index.html
          On first launch it will assist you in installing the Android SDK
          components.
          (or visit https://flutter.dev/docs/get-started/install/macos#android-setup
          for detailed instructions).
          If the Android SDK has been installed to a custom location, set
          ANDROID_SDK_ROOT to that location.
          You may also want to add it to your PATH environment variable.
    
    
    [✓] Xcode - develop for iOS and macOS (Xcode 12.0.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Xcode 12.0.1, Build version 12A7300
        • CocoaPods version 1.9.3
    
    [!] Android Studio (not installed)
        • Android Studio not found; download from
          https://developer.android.com/studio/index.html
          (or visit https://flutter.dev/docs/get-started/install/macos#android-setup
          for detailed instructions).
    
    [✓] Connected device (1 available)
        • iPad (mobile) • 6b98f33877e0cab838d2ffafbc6aec62c7e4b98b • ios •
          iOS 14.0
    
    ! Doctor found issues in 2 categories.
    

    I've tried literally every cleaning thing (flutter clean, pod deintegrate + pod setup, xcode clean project, ...) and nothing helped, so it doesn't seem to be corrupt build files. I also tried the solutions proposed in #18, but no luck there either.

    I'd be very grateful for any ideas on how to resolve this.

    opened by Aulig 8
  • error build ios

    error build ios

    Dear developer!!! I used tflite_flutter version 0.9.0 but got error "Invalid argument(s): Failed to lookup symbol 'TFLGpuDelegateCreate': dlsym(RTLD_DEFAULT, TFLGpuDelegateCreate): symbol not found" even though I added TensorFlowLiteC.framework IOS folder of tflite_flutter version 0.9.0 . Hope you can help me developer. Sincerely thank you.

    opened by hoangde2811 0
  • Tflite 2.11.0 ios error!

    Tflite 2.11.0 ios error!

    Hello, I built tflite 2.11.0 successfully. But I got this error while running. Please help me!

    2022-12-09 23:17:31.244139+0700 Runner[4348:262567] Created TensorFlow Lite delegate for Metal. INFO: Created TensorFlow Lite delegate for Metal. 2022-12-09 23:17:31.246144+0700 Runner[4348:262567] flutter: Error while creating interpreter: Invalid argument(s): Failed to lookup symbol 'TfLiteInterpreterOptionsCreate': dlsym(RTLD_DEFAULT, TfLiteInterpreterOptionsCreate): symbol not found 2022-12-09 23:17:31.249074+0700 Runner[4348:262567] [VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: Invalid argument(s): Failed to lookup symbol 'TfLiteInterpreterOptionsCreate': dlsym(RTLD_DEFAULT, TfLiteInterpreterOptionsCreate): symbol not found

    opened by lktinh2018 0
  • Error runing Xcode build on Flutter using TensorFlowLite

    Error runing Xcode build on Flutter using TensorFlowLite

    Hello! I'm new in TensorFlow and I'm creating a simple object detection app on Flutter using the TensorFlowLite library. After finishing all the Flutter Code, I'm trying to debug it on a iOS Simulator and I'm stuck with the following error:

    Failed to build iOS app
    Error output from Xcode build:
    ↳
        ** BUILD FAILED **
    Xcode's output:
    ↳
        Writing result bundle at path:
            /var/folders/13/q8h3_c012wvc3mxcfpzrf6fr0000gn/T/flutter_tools.8a658a/flutter_ios_build_temp_dirNlQoAO/temporary_xcresult_bundle
    /Users/chrisley/terminal-addons/flutter/.pub-cache/hosted/pub.dartlang.org/tflite-1.1.2/ios/Classes/TflitePlugin.mm:20:9: fatal error: 'TensorFlowLiteC.h' file not found
        #import "TensorFlowLiteC.h"
                ^~~~~~~~~~~~~~~~~~~
        1 error generated.
        error: the following command failed with exit code 1 but produced no further output
    CompileC /Users/chrisley/Library/Developer/Xcode/DerivedData/Runner-eguofderrkwgjseuiagmsjusmxtx/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/tflite.build/Objects-normal/arm64/TflitePlugin.o /Users/chrisley/terminal-addons/flutter/.pub-cache/hosted/pub.dartlang.org/tflite-1.1.2/ios/Classes/TflitePlugin.mm normal arm64 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'tflite' from project 'Pods')
        note: Building targets in dependency order
        /Users/chrisley/Documents/Development/Flutter/tensorflow_test/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 10.0, but the range of supported deployment target versions is 11.0 to 16.0.99. (in target 'TensorFlowLiteC' from project 'Pods')
        warning: Run script build phase 'Run Script' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'Runner' from project 'Runner')
        warning: Run script build phase 'Thin Binary' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'Runner' from project 'Runner')
        Result bundle written to path:
            /var/folders/13/q8h3_c012wvc3mxcfpzrf6fr0000gn/T/flutter_tools.8a658a/flutter_ios_build_temp_dirNlQoAO/temporary_xcresult_bundle
    Lexical or Preprocessor Issue (Xcode): 'TensorFlowLiteC.h' file not found
    /Users/chrisley/terminal-addons/flutter/.pub-cache/hosted/pub.dartlang.org/tflite-1.1.2/ios/Classes/TflitePlugin.mm:19:8
    2
    
    Could not build the application for the simulator.
    Error launching application on iPhone 14 Pro Max.
    

    I tried to solve it adding pod 'TensorFlowLiteObjC' in the Podfile but it didn't work. Also I already ran pod install in the iOS folder.

    opened by Chrisley304 1
  • Tflite Models with Embedded Metadata & Label

    Tflite Models with Embedded Metadata & Label

    Hi,

    Just wondering how do you load a tflite model which has embedded Metadata and Label. Does it work out of the box or do we need some special code to make it work?

    opened by jogiji 0
  • ffi version is not up-to-date

    ffi version is not up-to-date

    log that showing ffi version of tflite_flutter is not up-to-date to the latest version:

    Because file_picker >=5.0.0 depends on ffi ^2.0.1 and tflite_flutter 0.9.0 depends on ffi ^1.0.0, file_picker >=5.0.0 is incompatible with tflite_flutter 0.9.0.

    opened by nameaisy 1
Releases(v0.9.0)
Owner
Amish Garg
GSoC'20 & '21 @tensorflow | CS Undergrad, IIT Roorkee.
Amish Garg
Face Mask Detection with Tensorflow(Flutter)Face Mask Detection with Tensorflow(Flutter)

Face Mask Detection with Tensorflow(Flutter) Face Mask Detection With TFlite Info An app made with flutter and tensor flow lite for face mask detectio

Mohsen Mirdar 1 May 23, 2022
Flutter realtime object detection with Tensorflow Lite

Flutter realtime object detection with Tensorflow Lite Flutter realtime object d

null 0 Dec 25, 2021
Simple face recognition authentication (Sign up + Sign in) written in Flutter using Tensorflow Lite and Firebase ML vision library.

FaceNetAuthentication Simple face recognition authentication (Sign up + Sign in) written in Flutter using Tensorflow Lite and Google ML Kit library. S

Marcos Carlomagno 279 Jan 9, 2023
Face Mask Detection mobile application built with Flutter and TensorFlow lite in order to detect face masks using images and live camera.

Face Mask Detector App Face Mask Detection mobile application built with Flutter and TensorFlow lite in order to detect face masks using images and li

Yousef Shaban 3 Aug 15, 2022
Learn how to build a tensorflow model on Techable Machine and then run it on flutter app.

Ml With Flutter Learn how to build a tensorflow model on Techable Machine and then run it on flutter app. Youtube Tutorial Show Support Recommend Me O

Sanskar Tiwari 133 Jan 3, 2023
Lite version of smart_select package, zero dependencies, an easy way to provide a single or multiple choice chips.

Lite version of smart_select package, zero dependencies, an easy way to provide a single or multiple choice chips. What's New in Version 2.x.x Added p

Irfan Vigma Taufik 97 Dec 15, 2022
Lite-graphql - A light way implementation of GraphQL client in dart language

lite GraphQL client A light way implementation of GraphQL client in dart languag

Vincenzo Palazzo 3 Mar 17, 2022
Interactive command line interface Couchbase Lite REPL utility built with the Dart

Couchbase Lite Dart CLI Interactive command line interface Couchbase Lite REPL utility built with the Dart programming language. This code uses the cb

Pieter Greyling 2 Jul 20, 2022
This is just the simplyfied Flutter Plugin use for one of the popular flutter plugin for social media login.

social_media_logins Flutter Plugin to login via Social Media Accounts. Available Social Media Logins: Facebook Google Apple Getting Started To use thi

Reymark Esponilla 3 Aug 24, 2022
Permission plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to request and check permissions.

Flutter permission_handler plugin The Flutter permission_handler plugin is build following the federated plugin architecture. A detailed explanation o

Baseflow 1.7k Dec 31, 2022
Unloc customizations of the Permission plugin for Flutter. This plugin provides an API to request and check permissions.

Flutter Permission handler Plugin A permissions plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to request and check perm

Unloc 1 Nov 26, 2020
Klutter plugin makes it possible to write a Flutter plugin for both Android and iOS using Kotlin only.

The Klutter Framework makes it possible to write a Flutter plugin for both Android and iOS using Kotlin Multiplatform. Instead of writing platform spe

Gillian 33 Dec 18, 2022
A Flutter step_tracker plugin is collect information from user and display progress through a sequence of steps. this plugin also have privilege for fully customization from user side. like flipkart, amazon, myntra, meesho.

step_tracker plugin A Flutter step_tracker plugin is collect information from user and display progress through a sequence of steps. this plugin also

Roshan nahak 5 Oct 21, 2022
Boris Gautier 1 Jan 31, 2022
A Side Menu plugin for flutter and compatible with liquid ui for flutter

Liquid Shrink Side Menu A Side Menu plugin for flutter and compatible with liquid ui Side Menu Types There are 8 configuration of Liquid shrink side m

Raj Singh 18 Nov 24, 2022
FlutterBoost is a Flutter plugin which enables hybrid integration of Flutter for your existing native apps with minimum efforts

中文文档 中文介绍 Release Note v3.0-preview.17 PS: Before updating the beta version, please read the CHANGELOG to see if there are any BREAKING CHANGE Flutter

Alibaba 6.3k Dec 30, 2022
Flutter Counter is a plugin written in dart for flutter which is really simple and customizeable.

Flutter Counter (iOS & Android) Description Flutter Counter is a plugin written in dart for flutter which is really simple and customizeable. Create i

Salmaan Ahmed 15 Sep 18, 2022
Flutter simple image crop - A simple and easy to use flutter plugin to crop image on iOS and Android

Image Zoom and Cropping plugin for Flutter A simple and easy used flutter plugin to crop image on iOS and Android. Installation Add simple_image_crop

null 97 Dec 14, 2021