Переглянути джерело

Setup models to hold inference results

vishnukvmd 2 роки тому
батько
коміт
675179c265

+ 9 - 0
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<Recognition> recognitions;
+  final Stats stats;
+
+  Predictions(this.recognitions, this.stats);
+}

+ 18 - 0
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)';
+  }
+}

+ 27 - 0
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}';
+  }
+}