Updated formatting
This commit is contained in:
parent
ffc9f1d47e
commit
69809e2181
|
@ -19,7 +19,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
@interface MPPEmbedding (Helpers)
|
||||
|
||||
+ (MPPEmbedding *)embeddingWithProto:(const ::mediapipe::tasks::components::containers::proto::Embedding &)embeddingProto;
|
||||
+ (MPPEmbedding *)embeddingWithProto:
|
||||
(const ::mediapipe::tasks::components::containers::proto::Embedding &)embeddingProto;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -31,7 +31,8 @@ using EmbeddingProto = ::mediapipe::tasks::components::containers::proto::Embedd
|
|||
NSData *quantizedEmbedding;
|
||||
|
||||
if (embeddingProto.has_float_embedding()) {
|
||||
floatEmbedding = [NSMutableArray arrayWithCapacity:embeddingProto.float_embedding().values_size()];
|
||||
floatEmbedding =
|
||||
[NSMutableArray arrayWithCapacity:embeddingProto.float_embedding().values_size()];
|
||||
const auto floatEmbeddingValues = embeddingProto.float_embedding().values();
|
||||
|
||||
for (const auto value : embeddingProto.float_embedding().values()) {
|
||||
|
@ -40,11 +41,11 @@ using EmbeddingProto = ::mediapipe::tasks::components::containers::proto::Embedd
|
|||
}
|
||||
|
||||
if (embeddingProto.has_quantized_embedding()) {
|
||||
const std::string& cppQuantizedEmbedding =
|
||||
embeddingProto.quantized_embedding().values().data();
|
||||
const std::string &cppQuantizedEmbedding = embeddingProto.quantized_embedding().values().data();
|
||||
|
||||
const char *cppQuantizedEmbeddingCString = cppQuantizedEmbedding.c_str();
|
||||
quantizedEmbedding = [NSData dataWithBytes:cppQuantizedEmbeddingCString length:sizeof(cppQuantizedEmbeddingCString)];
|
||||
quantizedEmbedding = [NSData dataWithBytes:cppQuantizedEmbeddingCString
|
||||
length:sizeof(cppQuantizedEmbeddingCString)];
|
||||
}
|
||||
|
||||
NSString *headName;
|
||||
|
@ -54,9 +55,9 @@ using EmbeddingProto = ::mediapipe::tasks::components::containers::proto::Embedd
|
|||
}
|
||||
|
||||
return [[MPPEmbedding alloc] initWithFloatEmbedding:floatEmbedding
|
||||
quantizedEmbedding:quantizedEmbedding
|
||||
headIndex:embeddingProto.head_index()
|
||||
headName:headName];
|
||||
quantizedEmbedding:quantizedEmbedding
|
||||
headIndex:embeddingProto.head_index()
|
||||
headName:headName];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -19,7 +19,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
@interface MPPEmbeddingResult (Helpers)
|
||||
|
||||
+ (MPPEmbeddingResult *)embeddingResultWithProto:(const ::mediapipe::tasks::components::containers::proto::EmbeddingResult &)embeddingResultProto;
|
||||
+ (MPPEmbeddingResult *)embeddingResultWithProto:
|
||||
(const ::mediapipe::tasks::components::containers::proto::EmbeddingResult &)
|
||||
embeddingResultProto;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -23,9 +23,10 @@ using EmbeddingResultProto = ::mediapipe::tasks::components::containers::proto::
|
|||
|
||||
@implementation MPPEmbeddingResult (Helpers)
|
||||
|
||||
+ (MPPEmbeddingResult *)embeddingResultWithProto:(const EmbeddingResultProto &)embeddingResultProto {
|
||||
NSMutableArray *embeddings = [NSMutableArray
|
||||
arrayWithCapacity:(NSUInteger)embeddingResultProto.embeddings_size()];
|
||||
+ (MPPEmbeddingResult *)embeddingResultWithProto:
|
||||
(const EmbeddingResultProto &)embeddingResultProto {
|
||||
NSMutableArray *embeddings =
|
||||
[NSMutableArray arrayWithCapacity:(NSUInteger)embeddingResultProto.embeddings_size()];
|
||||
for (const auto &embeddingProto : embeddingResultProto.embeddings()) {
|
||||
[embeddings addObject:[MPPEmbedding embeddingWithProto:embeddingProto]];
|
||||
}
|
||||
|
@ -35,8 +36,7 @@ using EmbeddingResultProto = ::mediapipe::tasks::components::containers::proto::
|
|||
timestampMs = (NSInteger)embeddingResultProto.timestamp_ms();
|
||||
}
|
||||
|
||||
return [[MPPEmbeddingResult alloc] initWithEmbeddings:embeddings
|
||||
timestampMs:timestampMs];
|
||||
return [[MPPEmbeddingResult alloc] initWithEmbeddings:embeddings timestampMs:timestampMs];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in New Issue
Block a user