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