Setup models to hold inference results
This commit is contained in:
parent
1ad0d8dea6
commit
675179c265
3 changed files with 54 additions and 0 deletions
9
lib/services/object_detection/models/predictions.dart
Normal file
9
lib/services/object_detection/models/predictions.dart
Normal 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);
|
||||
}
|
18
lib/services/object_detection/models/recognition.dart
Normal file
18
lib/services/object_detection/models/recognition.dart
Normal 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)';
|
||||
}
|
||||
}
|
27
lib/services/object_detection/models/stats.dart
Normal file
27
lib/services/object_detection/models/stats.dart
Normal 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}';
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue