-
Notifications
You must be signed in to change notification settings - Fork 145
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
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Bad state: failed precondition #261
Comments
I'm facing the same problem, have you found a solution? |
Facing the same issue |
my problem was that i can't find the functions called getRed,getGreen and getBlue, so I use another way to extract the RGB, here is the code
|
I am having same issue, anybody please give me advice if you have resolved |
i needed to downgrade to image: ^3.1.3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
import 'dart:io';
import 'dart:typed_data';
import 'package:image/image.dart' as img;
import 'package:tflite_flutter/tflite_flutter.dart';
import 'package:tflite_flutter_helper/tflite_flutter_helper.dart';
class AgeEstimationModel {
static const int inputImageSize = 200;
static const double p = 116;
late Interpreter _interpreter;
late ImageProcessor _imageProcessor;
int inferenceTime = 0;
static Future create() async {
var model = AgeEstimationModel._();
await model._loadModel();
return model;
}
AgeEstimationModel._() {
_imageProcessor = ImageProcessorBuilder()
.add(ResizeOp(inputImageSize, inputImageSize, ResizeMethod.BILINEAR))
.add(NormalizeOp(0.0, 1.0))
.build();
}
Future _loadModel() async {
try {
_interpreter = await Interpreter.fromAsset('model_lite_age_q.tflite');
print('Model loaded successfully');
} catch (e) {
print('Error loading model: $e');
}
}
Future predictAge(File imageFile) async {
if (_interpreter == null) {
throw StateError('Interpreter has not been initialized');
}
}
void dispose() {
_interpreter.close();
}
}
flutter: >>>input shape: [1, 200, 200, 3], type: TfLiteType.float32
flutter: >>>output shape: [1, 1], type: TfLiteType.float32
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Bad state: failed precondition
image: ^3.0.1
tflite_flutter: ^0.9.0
tflite_flutter_helper: ^0.3.1
Please help me, Thanks !
The text was updated successfully, but these errors were encountered: