You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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;
}
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: