Setup models to hold inference results

This commit is contained in:
vishnukvmd 2023-02-08 19:06:40 +05:30
parent 1ad0d8dea6
commit 675179c265
3 changed files with 54 additions and 0 deletions

View file

@ -0,0 +1,9 @@
import "package:photos/services/object_detection/models/recognition.dart";
import "package:photos/services/object_detection/models/stats.dart";
class Predictions {
final List<Recognition> recognitions;
final Stats stats;
Predictions(this.recognitions, this.stats);
}

View file

@ -0,0 +1,18 @@
/// Represents the recognition output from the model
class Recognition {
/// Index of the result
int id;
/// Label of the result
String label;
/// Confidence [0.0, 1.0]
double score;
Recognition(this.id, this.label, this.score);
@override
String toString() {
return 'Recognition(id: $id, label: $label, score: $score)';
}
}

View file

@ -0,0 +1,27 @@
/// Bundles different elapsed times
class Stats {
/// Total time taken in the isolate where the inference runs
int totalPredictTime;
/// [totalPredictTime] + communication overhead time
/// between main isolate and another isolate
int totalElapsedTime;
/// Time for which inference runs
int inferenceTime;
/// Time taken to pre-process the image
int preProcessingTime;
Stats(
this.totalPredictTime,
this.totalElapsedTime,
this.inferenceTime,
this.preProcessingTime,
);
@override
String toString() {
return 'Stats{totalPredictTime: $totalPredictTime, totalElapsedTime: $totalElapsedTime, inferenceTime: $inferenceTime, preProcessingTime: $preProcessingTime}';
}
}