diff --git a/lib/services/object_detection/models/predictions.dart b/lib/services/object_detection/models/predictions.dart new file mode 100644 index 000000000..80c41a58c --- /dev/null +++ b/lib/services/object_detection/models/predictions.dart @@ -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 recognitions; + final Stats stats; + + Predictions(this.recognitions, this.stats); +} diff --git a/lib/services/object_detection/models/recognition.dart b/lib/services/object_detection/models/recognition.dart new file mode 100644 index 000000000..469326265 --- /dev/null +++ b/lib/services/object_detection/models/recognition.dart @@ -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)'; + } +} diff --git a/lib/services/object_detection/models/stats.dart b/lib/services/object_detection/models/stats.dart new file mode 100644 index 000000000..487f1f6a0 --- /dev/null +++ b/lib/services/object_detection/models/stats.dart @@ -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}'; + } +}