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]; Packet packet = [MPPTextPacketCreator createWithText:text];
std::map<std::string, Packet> packetMap = {{kTextInStreamName.cppString, packet}}; 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 nil;
} }
return [MPPTextClassifierResult return
textClassifierResultWithClassificationsPacket:statusOrOutputPacketMap.value() [MPPTextClassifierResult textClassifierResultWithClassificationsPacket:
[kClassificationsStreamName.cppString]]; outputPacketMap.value()[kClassificationsStreamName.cppString]];
} }
@end @end

View File

@ -83,14 +83,15 @@ static NSString *const kTaskGraphName = @"mediapipe.tasks.text.text_embedder.Tex
Packet packet = [MPPTextPacketCreator createWithText:text]; Packet packet = [MPPTextPacketCreator createWithText:text];
std::map<std::string, Packet> packetMap = {{kTextInStreamName.cppString, packet}}; 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 nil;
} }
return [MPPTextEmbedderResult return [MPPTextEmbedderResult
textEmbedderResultWithOutputPacket:statusOrOutputPacketMap textEmbedderResultWithOutputPacket:outputPacketMap
.value()[kEmbeddingsOutStreamName.cppString]]; .value()[kEmbeddingsOutStreamName.cppString]];
} }