Skip to content

Commit 1e9e188

Browse files
committed
Fixed Tests
1 parent 21d9a4e commit 1e9e188

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tensorflow_lite_support/ios/test/task/vision/image_classifier/TFLImageClassifierTests.m

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ - (void)testSuccessfullImageInferenceOnMLImageWithUIImage {
5555
TFLImageClassifier *imageClassifier =
5656
[TFLImageClassifier imageClassifierWithOptions:imageClassifierOptions error:nil];
5757
XCTAssertNotNil(imageClassifier);
58-
GMLImage *gmlImage = [self imageFromBundleWithName:@"burger_crop" ofType:@"jpg"];
58+
GMLImage *gmlImage = [self imageFromBundleWithName:@"burger-224" ofType:@"png"];
5959

6060
TFLClassificationResult *classificationResults = [imageClassifier classifyWithGMLImage:gmlImage
6161
error:nil];
@@ -64,6 +64,7 @@ - (void)testSuccessfullImageInferenceOnMLImageWithUIImage {
6464

6565
TFLCategory *category = classificationResults.classifications[0].categories[0];
6666
XCTAssertTrue([category.label isEqual:@"cheeseburger"]);
67+
XCTAssertGreaterThanOrEqual(category.score, 0.70);
6768
}
6869

6970
- (void)testModelOptionsWithMaxResults {
@@ -76,15 +77,16 @@ - (void)testModelOptionsWithMaxResults {
7677
[TFLImageClassifier imageClassifierWithOptions:imageClassifierOptions error:nil];
7778
XCTAssertNotNil(imageClassifier);
7879

79-
GMLImage *gmlImage = [self imageFromBundleWithName:@"burger_crop" ofType:@"jpg"];
80+
GMLImage *gmlImage = [self imageFromBundleWithName:@"burger-224" ofType:@"png"];
8081

8182
TFLClassificationResult *classificationResults = [imageClassifier classifyWithGMLImage:gmlImage
8283
error:nil];
8384
XCTAssertTrue([classificationResults.classifications count] > 0);
84-
XCTAssertTrue([classificationResults.classifications[0].categories count] > 0);
85+
XCTAssertLessThanOrEqual([classificationResults.classifications[0].categories count], maxResults);
8586

8687
TFLCategory *category = classificationResults.classifications[0].categories[0];
8788
XCTAssertTrue([category.label isEqual:@"cheeseburger"]);
89+
XCTAssertGreaterThanOrEqual(category.score, 0.70);
8890
}
8991

9092
- (void)testInferenceWithBoundingBox {
@@ -97,7 +99,7 @@ - (void)testInferenceWithBoundingBox {
9799
[TFLImageClassifier imageClassifierWithOptions:imageClassifierOptions error:nil];
98100
XCTAssertNotNil(imageClassifier);
99101

100-
GMLImage *gmlImage = [self imageFromBundleWithName:@"burger_crop" ofType:@"jpg"];
102+
GMLImage *gmlImage = [self imageFromBundleWithName:@"burger-224" ofType:@"png"];
101103

102104
CGRect roi = CGRectMake(20, 20, 200, 200);
103105
TFLClassificationResult *classificationResults = [imageClassifier classifyWithGMLImage:gmlImage
@@ -108,6 +110,7 @@ - (void)testInferenceWithBoundingBox {
108110

109111
TFLCategory *category = classificationResults.classifications[0].categories[0];
110112
XCTAssertTrue([category.label isEqual:@"cheeseburger"]);
113+
XCTAssertGreaterThanOrEqual(category.score, 0.90);
111114
}
112115

113116
- (void)testInferenceWithRGBAImage {
@@ -128,6 +131,7 @@ - (void)testInferenceWithRGBAImage {
128131

129132
TFLCategory *category = classificationResults.classifications[0].categories[0];
130133
XCTAssertTrue([category.label isEqual:@"junco"]);
134+
XCTAssertGreaterThanOrEqual(category.score, 0.25);
131135
}
132136

133137
@end

0 commit comments

Comments
 (0)