fixing pre-processing pipeline
This commit is contained in:
@@ -30,7 +30,6 @@ class Classifier {
|
|||||||
late List<String> _labels;
|
late List<String> _labels;
|
||||||
int classifierCreationStart = -1;
|
int classifierCreationStart = -1;
|
||||||
|
|
||||||
|
|
||||||
Classifier({
|
Classifier({
|
||||||
Interpreter? interpreter,
|
Interpreter? interpreter,
|
||||||
List<String>? labels,
|
List<String>? labels,
|
||||||
@@ -78,6 +77,7 @@ class Classifier {
|
|||||||
imageProcessor ??= ImageProcessorBuilder()
|
imageProcessor ??= ImageProcessorBuilder()
|
||||||
.add(ResizeWithCropOrPadOp(224, 224))
|
.add(ResizeWithCropOrPadOp(224, 224))
|
||||||
.add(ResizeOp(inputSize, inputSize, ResizeMethod.BILINEAR))
|
.add(ResizeOp(inputSize, inputSize, ResizeMethod.BILINEAR))
|
||||||
|
.add(NormalizeOp(0, 1))
|
||||||
// .add(NormalizeOp(127.5, 127.5))
|
// .add(NormalizeOp(127.5, 127.5))
|
||||||
.build();
|
.build();
|
||||||
return imageProcessor?.process(inputImage);
|
return imageProcessor?.process(inputImage);
|
||||||
@@ -93,9 +93,9 @@ class Classifier {
|
|||||||
var inferenceStart = DateTime.now().millisecondsSinceEpoch;
|
var inferenceStart = DateTime.now().millisecondsSinceEpoch;
|
||||||
_interpreter.run(_inputImage.buffer, _outputBuffer.getBuffer());
|
_interpreter.run(_inputImage.buffer, _outputBuffer.getBuffer());
|
||||||
var postProcStart = DateTime.now().millisecondsSinceEpoch;
|
var postProcStart = DateTime.now().millisecondsSinceEpoch;
|
||||||
Map<String, double> labeledProb = TensorLabel.fromList(
|
Map<String, double> labeledProb =
|
||||||
labels, _outputProcessor.process(_outputBuffer))
|
TensorLabel.fromList(labels, _outputProcessor.process(_outputBuffer))
|
||||||
.getMapWithFloatValue();
|
.getMapWithFloatValue();
|
||||||
final predictions = getTopProbabilities(labeledProb, number: 5)
|
final predictions = getTopProbabilities(labeledProb, number: 5)
|
||||||
.mapIndexed(
|
.mapIndexed(
|
||||||
(index, element) => Recognition(index, element.key, element.value))
|
(index, element) => Recognition(index, element.key, element.value))
|
||||||
@@ -111,6 +111,7 @@ class Classifier {
|
|||||||
),
|
),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the interpreter instance
|
/// Gets the interpreter instance
|
||||||
Interpreter get interpreter => _interpreter;
|
Interpreter get interpreter => _interpreter;
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import 'package:tensordex_mobile/tflite/classifier.dart';
|
|||||||
import 'package:tflite_flutter/tflite_flutter.dart';
|
import 'package:tflite_flutter/tflite_flutter.dart';
|
||||||
|
|
||||||
import '../utils/image_utils.dart';
|
import '../utils/image_utils.dart';
|
||||||
import '../utils/logger.dart';
|
|
||||||
|
|
||||||
class IsolateBase {
|
class IsolateBase {
|
||||||
final ReceivePort _receivePort = ReceivePort();
|
final ReceivePort _receivePort = ReceivePort();
|
||||||
|
|||||||
Reference in New Issue
Block a user