Changed method Updated method calls to process packet map in iOS text tasks

This commit is contained in:
Prianka Liz Kariat 2023-03-02 19:36:34 +05:30
parent 6d7f172e9f
commit 045050fc85
2 changed files with 11 additions and 9 deletions

View File

@ -83,15 +83,16 @@ static NSString *const kTaskGraphName = @"mediapipe.tasks.text.text_classifier.T
Packet packet = [MPPTextPacketCreator createWithText:text];
std::map<std::string, Packet> packetMap = {{kTextInStreamName.cppString, packet}};
absl::StatusOr<PacketMap> statusOrOutputPacketMap = [_textTaskRunner process:packetMap];
std::optional<PacketMap> outputPacketMap = [_textTaskRunner processPacketMap:packetMap
error:error];
if (![MPPCommonUtils checkCppError:statusOrOutputPacketMap.status() toError:error]) {
if (!outputPacketMap.has_value()) {
return nil;
}
return [MPPTextClassifierResult
textClassifierResultWithClassificationsPacket:statusOrOutputPacketMap.value()
[kClassificationsStreamName.cppString]];
return
[MPPTextClassifierResult textClassifierResultWithClassificationsPacket:
outputPacketMap.value()[kClassificationsStreamName.cppString]];
}
@end

View File

@ -83,14 +83,15 @@ static NSString *const kTaskGraphName = @"mediapipe.tasks.text.text_embedder.Tex
Packet packet = [MPPTextPacketCreator createWithText:text];
std::map<std::string, Packet> packetMap = {{kTextInStreamName.cppString, packet}};
absl::StatusOr<PacketMap> statusOrOutputPacketMap = [_textTaskRunner process:packetMap];
if (![MPPCommonUtils checkCppError:statusOrOutputPacketMap.status() toError:error]) {
std::optional<PacketMap> outputPacketMap = [_textTaskRunner processPacketMap:packetMap
error:error];
if (!outputPacketMap.has_value()) {
return nil;
}
return [MPPTextEmbedderResult
textEmbedderResultWithOutputPacket:statusOrOutputPacketMap
textEmbedderResultWithOutputPacket:outputPacketMap
.value()[kEmbeddingsOutStreamName.cppString]];
}