Skip to content

Commit

Permalink
Merge pull request #4830 from priankakariatyml:ios-image-segmenter-ba…
Browse files Browse the repository at this point in the history
…sic-tests

PiperOrigin-RevId: 571386542
  • Loading branch information
copybara-github committed Oct 6, 2023
2 parents 90e6a97 + b1f717e commit 830ee09
Showing 1 changed file with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,45 @@ - (void)imageSegmenter:(MPPImageSegmenter *)imageSegmenter
}
}

#pragma mark Mask No Copy Tests

- (void)testSegmentWithNoCopyConfidenceMasksAndImageModeSucceeds {
MPPImageSegmenterOptions *options =
[self imageSegmenterOptionsWithModelFileInfo:kImageSegmenterModelFileInfo];

MPPImageSegmenter *imageSegmenter = [self createImageSegmenterWithOptionsSucceeds:options];

MPPImage *image = [MPPImage imageWithFileInfo:kCatImageFileInfo];
[imageSegmenter segmentImage:image withCompletionHandler:^(MPPImageSegmenterResult *result, NSError *error) {
[self assertImageSegmenterResult:result
hasConfidenceMasksCount:
kExpectedDeeplabV3ConfidenceMaskCount
approximatelyEqualsExpectedConfidenceMaskImageWithFileInfo:kCatGoldenImageFileInfo
atIndex:8
shouldHaveCategoryMask:NO];
}];
}

- (void)testSegmentWithNoCopyConfidenceMasksAndVideoModeSucceeds {
MPPImageSegmenterOptions *options =
[self imageSegmenterOptionsWithModelFileInfo:kImageSegmenterModelFileInfo];
options.runningMode = MPPRunningModeVideo;

MPPImageSegmenter *imageSegmenter = [self createImageSegmenterWithOptionsSucceeds:options];

const NSInteger timestampInMilliseconds = 0;

MPPImage *image = [MPPImage imageWithFileInfo:kCatImageFileInfo];
[imageSegmenter segmentVideoFrame:image timestampInMilliseconds:timestampInMilliseconds withCompletionHandler:^(MPPImageSegmenterResult *result, NSError *error) {
[self assertImageSegmenterResult:result
hasConfidenceMasksCount:
kExpectedDeeplabV3ConfidenceMaskCount
approximatelyEqualsExpectedConfidenceMaskImageWithFileInfo:kCatGoldenImageFileInfo
atIndex:8
shouldHaveCategoryMask:NO];
}];
}

#pragma mark - Image Segmenter Initializers

- (MPPImageSegmenterOptions *)imageSegmenterOptionsWithModelFileInfo:(MPPFileInfo *)fileInfo {
Expand Down

0 comments on commit 830ee09

Please sign in to comment.