Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tflite version error #20

Open
sourav-singh-rawat opened this issue Feb 2, 2020 · 13 comments
Open

tflite version error #20

sourav-singh-rawat opened this issue Feb 2, 2020 · 13 comments

Comments

@sourav-singh-rawat
Copy link

sourav-singh-rawat commented Feb 2, 2020

Note: /home/irotech/Desktop/flutter_linux_v1.7.8+hotfix.4-stable/flutter/.pub-cache/hosted/pub.dartlang.org/tflite-1.0.4/android/src/main/java/sq/flutter/tflite/TflitePlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

I am continuously getting this error and i have tried all the version of Tflite till 1.0.1, but still getting the same error.

@techno-disaster
Copy link
Contributor

this looks like a warning? are u sure the build process ends after this?

@sourav-singh-rawat
Copy link
Author

No Build Process doesn't end on this, but i am not able to use tflite feature in my app.
Simply it just starting camera, maybe because app is not supporting tflite.

@techno-disaster
Copy link
Contributor

did you load the correct model?

@sourav-singh-rawat
Copy link
Author

Thanks, I got it, now it's running fine

@sourav-singh-rawat
Copy link
Author

sourav-singh-rawat commented Feb 4, 2020

But I Need Your Little Bit Help, I Am Getting A new error

I/flutter ( 9450): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter ( 9450): The following NoSuchMethodError was thrown building HomePage(dirty, dependencies: [MediaQuery],
I/flutter ( 9450): state: _HomePageState#0269d):
I/flutter ( 9450): The getter 'height' was called on null.
I/flutter ( 9450): Receiver: null
I/flutter ( 9450): Tried calling: height
I/flutter ( 9450):
I/flutter ( 9450): The relevant error-causing widget was:
I/flutter ( 9450): HomePage file:///home/irotech/Desktop/flutterProjects/shop_by_image/lib/main.dart:25:13
I/flutter ( 9450):
I/flutter ( 9450): When the exception was thrown, this was the stack:
I/flutter ( 9450): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
I/flutter ( 9450): #1 _HomePageState.build (package:shop_by_image/HomePage.dart:127:33)
I/flutter ( 9450): #2 StatefulElement.build (package:flutter/src/widgets/framework.dart:4334:27)
I/flutter ( 9450): #3 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4223:15)
I/flutter ( 9450): #4 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
I/flutter ( 9450): #5 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5)
I/flutter ( 9450): #6 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4381:11)
I/flutter ( 9450): #7 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
I/flutter ( 9450): #8 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
I/flutter ( 9450): #9 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
I/flutter ( 9450): #10 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
I/flutter ( 9450): #11 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
I/flutter ( 9450): #12 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
I/flutter ( 9450): #13 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
I/flutter ( 9450): #14 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
I/flutter ( 9450): #15 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5)
I/flutter ( 9450): #16 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
I/flutter ( 9450): #17 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
I/flutter ( 9450): #18 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
I/flutter ( 9450): #19 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
I/flutter ( 9450): #20 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
I/flutter ( 9450): #21 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
I/flutter ( 9450): #22 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
I/flutter ( 9450): #23 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
I/flutter ( 9450): #24 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
I/flutter ( 9450): #25 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
....
...
..
.
I/flutter ( 9450): #314 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
I/flutter ( 9450): #315 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
I/flutter ( 9450): #316 RenderObjectToWidgetElement._rebuild (package:flutter/src/widgets/binding.dart:1028:16)
I/flutter ( 9450): #317 RenderObjectToWidgetElement.mount (package:flutter/src/widgets/binding.dart:999:5)
I/flutter ( 9450): #318 RenderObjectToWidgetAdapter.attachToRenderTree. (package:flutter/src/widgets/binding.dart:942:17)
I/flutter ( 9450): #319 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2412:19)
I/flutter ( 9450): #320 RenderObjectToWidgetAdapter.attachToRenderTree (package:flutter/src/widgets/binding.dart:941:13)
I/flutter ( 9450): #321 WidgetsBinding.attachRootWidget (package:flutter/src/widgets/binding.dart:819:7)
I/flutter ( 9450): #322 WidgetsBinding.scheduleAttachRootWidget. (package:flutter/src/widgets/binding.dart:804:7)
I/flutter ( 9450): #331 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:384:19)
I/flutter ( 9450): #332 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:418:5)
I/flutter ( 9450): #333 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12)
I/flutter ( 9450): (elided 8 frames from package dart:async and package dart:async-patch)
I/flutter ( 9450):
I/flutter ( 9450): ════════════════════════════════════════════════════════════════════════════════════════════════════

@sourav-singh-rawat
Copy link
Author

I Try To print the Recognition what i am getting from the frame.
"Object Detect on Frame Failure"

@techno-disaster
Copy link
Contributor

this is a flutter error, not a tflite module error try to clean start the app

@techno-disaster
Copy link
Contributor

did u clean start it?

@sourav-singh-rawat
Copy link
Author

Yes, getting same error

@sourav-singh-rawat
Copy link
Author

`String _model="YOLO";
int _imageHeight=0;
int _imageWidth=0;
List _recognition;

CameraController controller;
deviceRatio(context) => MediaQuery.of(context).size.width / MediaQuery.of(context).size.height;
bool isDetecting=false;

@OverRide
void initState(){
super.initState();
loadModel();
if(widget.cameras==null || widget.cameras.length<1){
print("No Camera is Found");
}else{
controller=new CameraController(widget.cameras[0], ResolutionPreset.medium);
controller.initialize().then((_){
if(!mounted){
return;
}
setState(() {});

    controller.startImageStream((CameraImage img) async{
      // print("Enter1");
      if(!isDetecting){
        isDetecting=true;
        // int startTime = DateTime.now().millisecondsSinceEpoch;
        if(_model=="YOLO"){
          // print("Enter3");
          try{
          var recognation= await Tflite.detectObjectOnFrame(
              bytesList:img.planes.map((plane){
                return plane.bytes;
              }).toList(),
              model: _model,
              imageHeight:img.height,
              imageWidth:img.width,
              imageMean:0,
              imageStd:255.0,
              numResultsPerClass:1,
              threshold:0.2,
            );
            print(recognation);
            setState(() {
              _recognition=recognation;
              _imageHeight=img.height;
              _imageWidth=img.width;
            });  
          }on PlatformException {
            print("Object Detect on Frame Failure");
          }
        }
      }
    });
  });
}

}

@OverRide
void dispose(){
controller?.dispose();
super.dispose();
}

loadModel() async{
try{
await Tflite.close();
String modelRespo;
if(_model=="YOLO"){
modelRespo= await Tflite.loadModel(
model: "assets/tflite/yolov2_tiny.tflite",
labels: "assets/tflite/yolov2_tiny.txt",
);
}
print(modelRespo);
}on PlatformException {
print("Failed to load the model");
}
}

// setRecognition(recognition,imageHeight,imageWidth){
// setState(() {
// _recognition=recognition;
// _imageHeight=imageHeight;
// _imageWidth=imageWidth;
// });
// }

@OverRide
Widget build(BuildContext context) {
Size screen=MediaQuery.of(context).size;

var tmp = MediaQuery.of(context).size;
var screenH = math.max(tmp.height, tmp.width);
var screenW = math.min(tmp.height, tmp.width);
tmp = controller.value.previewSize;
var previewH = math.max(tmp.height, tmp.width);
var previewW = math.min(tmp.height, tmp.width);
var screenRatio = screenH / screenW;
var previewRatio = previewH / previewW;

return Stack(
  children: <Widget>[
    !controller.value.isInitialized?Center(
      child:CircularProgressIndicator(),
    ):OverflowBox(
      maxHeight:
          screenRatio > previewRatio ? screenH : screenW / previewW * previewH,
      maxWidth:
          screenRatio > previewRatio ? screenH / previewH * previewW : screenW,
      child: CameraPreview(controller),
    ),
    BoundedBox(
      _recognition==null ?[]:_recognition,
      math.max(_imageHeight,_imageWidth),
      math.min(_imageHeight, _imageWidth),
      screen.height,
      screen.width,
      _model
    )
  ],
);

}
}`

@sourav-singh-rawat
Copy link
Author

Actually I am Not Getting this error, what does it mean?
The first few lines only i am not able to understand!

@techno-disaster
Copy link
Contributor

@bunny1999 please stop mentioning your error in literally all the issues.

@techno-disaster
Copy link
Contributor

as for the error try checking what your tmp variable is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants