Added iOS Image Segmenter Result
This commit is contained in:
parent
a8899da45a
commit
7fe365489d
28
mediapipe/tasks/ios/vision/image_segmenter/BUILD
Normal file
28
mediapipe/tasks/ios/vision/image_segmenter/BUILD
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
# Copyright 2023 The MediaPipe Authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
package(default_visibility = ["//mediapipe/tasks:internal"])
|
||||||
|
|
||||||
|
licenses(["notice"])
|
||||||
|
|
||||||
|
objc_library(
|
||||||
|
name = "MPPImageSegmenterResult",
|
||||||
|
srcs = ["sources/MPPImageSegmenterResult.m"],
|
||||||
|
hdrs = ["sources/MPPImageSegmenterResult.h"],
|
||||||
|
deps = [
|
||||||
|
"//mediapipe/tasks/ios/vision/core:MPPMask",
|
||||||
|
"//mediapipe/tasks/ios/core:MPPTaskResult",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
// Copyright 2023 The MediaPipe Authors.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import "mediapipe/tasks/ios/core/sources/MPPTaskResult.h"
|
||||||
|
#import "mediapipe/tasks/ios/vision/core/sources/MPPMask.h"
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
/** Represents the segmentation results generated by `MPPImageSegmenter`. */
|
||||||
|
NS_SWIFT_NAME(ImageSegmenterResult)
|
||||||
|
@interface MPPImageSegmenterResult : MPPTaskResult
|
||||||
|
|
||||||
|
/** An optional array of `MPPMask` objects. Each `MPPMask` in the array holds a 32 bit float array
|
||||||
|
* of size `image width` * `image height` which represents the confidence mask for each category.
|
||||||
|
* Each element of the float array represents the confidence with which the model predicted that the
|
||||||
|
* corresponding pixel belongs to the category that the mask represents, usually in the range [0,
|
||||||
|
* 1]. */
|
||||||
|
@property(nonatomic, readonly, nullable) NSArray<MPPMask *> *confidenceMasks;
|
||||||
|
|
||||||
|
/** An optional `MPPMask` that holds a`UInt8` array of size `image width` * `image height`. Each
|
||||||
|
* element of this array represents the class to which the pixel in the original image was predicted
|
||||||
|
* to belong to. */
|
||||||
|
@property(nonatomic, readonly, nullable) MPPMask *categoryMask;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The quality scores of the result masks, in the range of [0, 1]. Defaults
|
||||||
|
* to `1` if the model doesn't output quality scores. Each element corresponds to the score of
|
||||||
|
* the category in the model outputs.
|
||||||
|
*/
|
||||||
|
@property(nonatomic, readonly, nullable) NSArray<NSNumber *> *qualityScores;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes a new `MPPImageSegmenterResult` with the given array of confidence masks, category
|
||||||
|
* mask, quality scores and timestamp (in milliseconds).
|
||||||
|
*
|
||||||
|
* @param confidenceMasks An optional array of `MPPMask` objects. Each `MPPMask` in the array must
|
||||||
|
* be of type `MPPMaskDataTypeFloat32`.
|
||||||
|
* @param categoryMask An optional `MPMask` object of type `MPPMaskDataTypeUInt8`.
|
||||||
|
* @param qualityScores The quality scores of the result masks of type NSArray<NSNumber *> *. Each
|
||||||
|
* `NSNumber` in the array holds a `float`.
|
||||||
|
* @param timestampInMilliseconds The timestamp (in milliseconds) for this result.
|
||||||
|
*
|
||||||
|
* @return An instance of `MPPImageSegmenterResult` initialized with the given array of confidence
|
||||||
|
* masks, category mask, quality scores and timestamp (in milliseconds).
|
||||||
|
*/
|
||||||
|
- (instancetype)initWithConfidenceMasks:(nullable NSArray<MPPMask *> *)confidenceMasks
|
||||||
|
categoryMasks:(nullable MPPMask *)categoryMask
|
||||||
|
qualityScores:(nullable NSArray<NSNumber *> *)qualityScores
|
||||||
|
timestampInMilliseconds:(NSInteger)timestampInMilliseconds;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
|
@ -0,0 +1,32 @@
|
||||||
|
// Copyright 2023 The MediaPipe Authors.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
#import "mediapipe/tasks/ios/vision/image_segmenter/sources/MPPImageSegmenterResult.h"
|
||||||
|
|
||||||
|
@implementation MPPImageSegmenterResult
|
||||||
|
|
||||||
|
- (instancetype)initWithConfidenceMasks:(NSArray<MPPMask *> *)confidenceMasks
|
||||||
|
categoryMask:(MPPMask *)categoryMask
|
||||||
|
qualityScores:(NSArray<NSNumber *> *)qualityScores
|
||||||
|
timestampInMilliseconds:(NSInteger)timestampInMilliseconds {
|
||||||
|
self = [super initWithTimestampInMilliseconds:timestampInMilliseconds];
|
||||||
|
if (self) {
|
||||||
|
_confidenceMasks = confidenceMasks;
|
||||||
|
_categoryMask = categoryMask;
|
||||||
|
_qualityScores = qualityScores;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
Loading…
Reference in New Issue
Block a user