迁移 Flutter 端与训练脚本,模型/训练产物移出 git(遵循纯代码约定)
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:observer/detection/detection_result.dart';
|
||||
import 'package:observer/detection/nms.dart';
|
||||
|
||||
DetectionResult box(double l, double t, double r, double b, double score,
|
||||
{String label = 'x'}) =>
|
||||
DetectionResult(
|
||||
label: label, score: score, left: l, top: t, right: r, bottom: b);
|
||||
|
||||
void main() {
|
||||
test('overlappingBoxes_keepHighestScore', () {
|
||||
final a = box(0.1, 0.1, 0.5, 0.5, 0.8);
|
||||
final b = box(0.12, 0.12, 0.52, 0.52, 0.6);
|
||||
final result = nms([a, b], 0.45);
|
||||
expect(result.length, 1);
|
||||
expect(result[0].score, closeTo(0.8, 1e-6));
|
||||
});
|
||||
|
||||
test('separateBoxes_bothKept', () {
|
||||
final a = box(0.1, 0.1, 0.3, 0.3, 0.8);
|
||||
final b = box(0.7, 0.7, 0.9, 0.9, 0.6);
|
||||
expect(nms([a, b], 0.45).length, 2);
|
||||
});
|
||||
|
||||
test('lowScoreBox_suppressedByHigherScore', () {
|
||||
final a = box(0.1, 0.1, 0.5, 0.5, 0.9);
|
||||
final b = box(0.1, 0.1, 0.5, 0.5, 0.5);
|
||||
final result = nms([b, a], 0.45);
|
||||
expect(result.length, 1);
|
||||
expect(result[0].score, greaterThan(0.5));
|
||||
});
|
||||
|
||||
test('iou_nonOverlapping_isZero', () {
|
||||
final a = box(0.0, 0.0, 0.2, 0.2, 1);
|
||||
final b = box(0.8, 0.8, 1.0, 1.0, 1);
|
||||
expect(iou(a, b), closeTo(0, 1e-6));
|
||||
});
|
||||
|
||||
test('iou_identicalBoxes_isOne', () {
|
||||
final a = box(0.1, 0.1, 0.5, 0.5, 1);
|
||||
expect(iou(a, a), closeTo(1, 1e-6));
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user