Updated MPPEmbeddingHelpers to reflect type change of quantized embeddings
This commit is contained in:
parent
cd1cb87ff6
commit
bd507b2d7b
|
@ -28,12 +28,11 @@ using EmbeddingProto = ::mediapipe::tasks::components::containers::proto::Embedd
|
||||||
NSString *displayName;
|
NSString *displayName;
|
||||||
|
|
||||||
NSMutableArray<NSNumber *> *floatEmbedding;
|
NSMutableArray<NSNumber *> *floatEmbedding;
|
||||||
NSData *quantizedEmbedding;
|
NSMutableArray<NSNumber *> *quantizedEmbedding;
|
||||||
|
|
||||||
if (embeddingProto.has_float_embedding()) {
|
if (embeddingProto.has_float_embedding()) {
|
||||||
floatEmbedding =
|
floatEmbedding =
|
||||||
[NSMutableArray arrayWithCapacity:embeddingProto.float_embedding().values_size()];
|
[NSMutableArray arrayWithCapacity:embeddingProto.float_embedding().values_size()];
|
||||||
const auto floatEmbeddingValues = embeddingProto.float_embedding().values();
|
|
||||||
|
|
||||||
for (const auto value : embeddingProto.float_embedding().values()) {
|
for (const auto value : embeddingProto.float_embedding().values()) {
|
||||||
[floatEmbedding addObject:[NSNumber numberWithFloat:value]];
|
[floatEmbedding addObject:[NSNumber numberWithFloat:value]];
|
||||||
|
@ -41,11 +40,12 @@ using EmbeddingProto = ::mediapipe::tasks::components::containers::proto::Embedd
|
||||||
}
|
}
|
||||||
|
|
||||||
if (embeddingProto.has_quantized_embedding()) {
|
if (embeddingProto.has_quantized_embedding()) {
|
||||||
const std::string &cppQuantizedEmbedding = embeddingProto.quantized_embedding().values().data();
|
const std::string &cppQuantizedEmbedding = embeddingProto.quantized_embedding().values();
|
||||||
|
quantizedEmbedding = [NSMutableArray arrayWithCapacity:cppQuantizedEmbedding.length()];
|
||||||
|
|
||||||
const char *cppQuantizedEmbeddingCString = cppQuantizedEmbedding.c_str();
|
for (char ch : cppQuantizedEmbedding) {
|
||||||
quantizedEmbedding = [NSData dataWithBytes:cppQuantizedEmbeddingCString
|
[quantizedEmbedding addObject:[NSNumber numberWithChar:ch]];
|
||||||
length:sizeof(cppQuantizedEmbeddingCString)];
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString *headName;
|
NSString *headName;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user