Project import generated by Copybara.
GitOrigin-RevId: 1138530ad1578c5d6615b3e3d041775c75d310c4
This commit is contained in:
@@ -39,17 +39,17 @@ namespace mediapipe {
|
||||
)");
|
||||
|
||||
CalculatorGraph graph;
|
||||
RETURN_IF_ERROR(graph.Initialize(config));
|
||||
MP_RETURN_IF_ERROR(graph.Initialize(config));
|
||||
ASSIGN_OR_RETURN(OutputStreamPoller poller,
|
||||
graph.AddOutputStreamPoller("out"));
|
||||
RETURN_IF_ERROR(graph.StartRun({}));
|
||||
MP_RETURN_IF_ERROR(graph.StartRun({}));
|
||||
// Give 10 input packets that contains the same std::string "Hello World!".
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
RETURN_IF_ERROR(graph.AddPacketToInputStream(
|
||||
MP_RETURN_IF_ERROR(graph.AddPacketToInputStream(
|
||||
"in", MakePacket<std::string>("Hello World!").At(Timestamp(i))));
|
||||
}
|
||||
// Close the input stream "in".
|
||||
RETURN_IF_ERROR(graph.CloseInputStream("in"));
|
||||
MP_RETURN_IF_ERROR(graph.CloseInputStream("in"));
|
||||
mediapipe::Packet packet;
|
||||
// Get the output packets std::string.
|
||||
while (poller.Next(&packet)) {
|
||||
|
||||
@@ -39,7 +39,7 @@ DEFINE_string(output_side_packets, "",
|
||||
|
||||
::mediapipe::Status RunMPPGraph() {
|
||||
std::string calculator_graph_config_contents;
|
||||
RETURN_IF_ERROR(mediapipe::file::GetContents(
|
||||
MP_RETURN_IF_ERROR(mediapipe::file::GetContents(
|
||||
FLAGS_calculator_graph_config_file, &calculator_graph_config_contents));
|
||||
LOG(INFO) << "Get calculator graph config contents: "
|
||||
<< calculator_graph_config_contents;
|
||||
@@ -54,16 +54,16 @@ DEFINE_string(output_side_packets, "",
|
||||
RET_CHECK(name_and_value.size() == 2);
|
||||
RET_CHECK(!::mediapipe::ContainsKey(input_side_packets, name_and_value[0]));
|
||||
std::string input_side_packet_contents;
|
||||
RETURN_IF_ERROR(mediapipe::file::GetContents(name_and_value[1],
|
||||
&input_side_packet_contents));
|
||||
MP_RETURN_IF_ERROR(mediapipe::file::GetContents(
|
||||
name_and_value[1], &input_side_packet_contents));
|
||||
input_side_packets[name_and_value[0]] =
|
||||
::mediapipe::MakePacket<std::string>(input_side_packet_contents);
|
||||
}
|
||||
LOG(INFO) << "Initialize the calculator graph.";
|
||||
mediapipe::CalculatorGraph graph;
|
||||
RETURN_IF_ERROR(graph.Initialize(config, input_side_packets));
|
||||
MP_RETURN_IF_ERROR(graph.Initialize(config, input_side_packets));
|
||||
LOG(INFO) << "Start running the calculator graph.";
|
||||
RETURN_IF_ERROR(graph.Run());
|
||||
MP_RETURN_IF_ERROR(graph.Run());
|
||||
LOG(INFO) << "Gathering output side packets.";
|
||||
kv_pairs = absl::StrSplit(FLAGS_output_side_packets, ',');
|
||||
for (const std::string& kv_pair : kv_pairs) {
|
||||
@@ -75,7 +75,7 @@ DEFINE_string(output_side_packets, "",
|
||||
<< "Packet " << name_and_value[0] << " was not available.";
|
||||
const std::string& serialized_string =
|
||||
output_packet.ValueOrDie().Get<std::string>();
|
||||
RETURN_IF_ERROR(
|
||||
MP_RETURN_IF_ERROR(
|
||||
mediapipe::file::SetContents(name_and_value[1], serialized_string));
|
||||
}
|
||||
return ::mediapipe::OkStatus();
|
||||
|
||||
@@ -33,7 +33,7 @@ DEFINE_string(input_side_packets, "",
|
||||
|
||||
::mediapipe::Status RunMPPGraph() {
|
||||
std::string calculator_graph_config_contents;
|
||||
RETURN_IF_ERROR(mediapipe::file::GetContents(
|
||||
MP_RETURN_IF_ERROR(mediapipe::file::GetContents(
|
||||
FLAGS_calculator_graph_config_file, &calculator_graph_config_contents));
|
||||
LOG(INFO) << "Get calculator graph config contents: "
|
||||
<< calculator_graph_config_contents;
|
||||
@@ -52,7 +52,7 @@ DEFINE_string(input_side_packets, "",
|
||||
}
|
||||
LOG(INFO) << "Initialize the calculator graph.";
|
||||
mediapipe::CalculatorGraph graph;
|
||||
RETURN_IF_ERROR(graph.Initialize(config, input_side_packets));
|
||||
MP_RETURN_IF_ERROR(graph.Initialize(config, input_side_packets));
|
||||
LOG(INFO) << "Start running the calculator graph.";
|
||||
return graph.Run();
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
--define MEDIAPIPE_DISABLE_GPU=1 --define no_aws_support=true \
|
||||
mediapipe/examples/desktop/youtube8m:extract_yt8m_features
|
||||
|
||||
./bazel-bin/mediapipe/examples/desktop/youtube8m/extract_yt8m_features
|
||||
./bazel-bin/mediapipe/examples/desktop/youtube8m/extract_yt8m_features \
|
||||
--calculator_graph_config_file=mediapipe/graphs/youtube8m/feature_extraction.pbtxt \
|
||||
--input_side_packets=input_sequence_example=/tmp/mediapipe/metadata.tfrecord \
|
||||
--output_side_packets=output_sequence_example=/tmp/mediapipe/output.tfrecord
|
||||
|
||||
@@ -40,7 +40,7 @@ DEFINE_string(output_side_packets, "",
|
||||
|
||||
::mediapipe::Status RunMPPGraph() {
|
||||
std::string calculator_graph_config_contents;
|
||||
RETURN_IF_ERROR(mediapipe::file::GetContents(
|
||||
MP_RETURN_IF_ERROR(mediapipe::file::GetContents(
|
||||
FLAGS_calculator_graph_config_file, &calculator_graph_config_contents));
|
||||
LOG(INFO) << "Get calculator graph config contents: "
|
||||
<< calculator_graph_config_contents;
|
||||
@@ -55,8 +55,8 @@ DEFINE_string(output_side_packets, "",
|
||||
RET_CHECK(name_and_value.size() == 2);
|
||||
RET_CHECK(!::mediapipe::ContainsKey(input_side_packets, name_and_value[0]));
|
||||
std::string input_side_packet_contents;
|
||||
RETURN_IF_ERROR(mediapipe::file::GetContents(name_and_value[1],
|
||||
&input_side_packet_contents));
|
||||
MP_RETURN_IF_ERROR(mediapipe::file::GetContents(
|
||||
name_and_value[1], &input_side_packet_contents));
|
||||
input_side_packets[name_and_value[0]] =
|
||||
::mediapipe::MakePacket<std::string>(input_side_packet_contents);
|
||||
}
|
||||
@@ -68,7 +68,7 @@ DEFINE_string(output_side_packets, "",
|
||||
vggish_pca_mean_matrix, vggish_pca_projection_matrix;
|
||||
|
||||
std::string content;
|
||||
RETURN_IF_ERROR(mediapipe::file::GetContents(
|
||||
MP_RETURN_IF_ERROR(mediapipe::file::GetContents(
|
||||
"/tmp/mediapipe/inception3_mean_matrix_data.pb", &content));
|
||||
inc3_pca_mean_matrix_data.ParseFromString(content);
|
||||
mediapipe::MatrixFromMatrixDataProto(inc3_pca_mean_matrix_data,
|
||||
@@ -76,7 +76,7 @@ DEFINE_string(output_side_packets, "",
|
||||
input_side_packets["inception3_pca_mean_matrix"] =
|
||||
::mediapipe::MakePacket<mediapipe::Matrix>(inc3_pca_mean_matrix);
|
||||
|
||||
RETURN_IF_ERROR(mediapipe::file::GetContents(
|
||||
MP_RETURN_IF_ERROR(mediapipe::file::GetContents(
|
||||
"/tmp/mediapipe/inception3_projection_matrix_data.pb", &content));
|
||||
inc3_pca_projection_matrix_data.ParseFromString(content);
|
||||
mediapipe::MatrixFromMatrixDataProto(inc3_pca_projection_matrix_data,
|
||||
@@ -84,7 +84,7 @@ DEFINE_string(output_side_packets, "",
|
||||
input_side_packets["inception3_pca_projection_matrix"] =
|
||||
::mediapipe::MakePacket<mediapipe::Matrix>(inc3_pca_projection_matrix);
|
||||
|
||||
RETURN_IF_ERROR(mediapipe::file::GetContents(
|
||||
MP_RETURN_IF_ERROR(mediapipe::file::GetContents(
|
||||
"/tmp/mediapipe/vggish_mean_matrix_data.pb", &content));
|
||||
vggish_pca_mean_matrix_data.ParseFromString(content);
|
||||
mediapipe::MatrixFromMatrixDataProto(vggish_pca_mean_matrix_data,
|
||||
@@ -92,7 +92,7 @@ DEFINE_string(output_side_packets, "",
|
||||
input_side_packets["vggish_pca_mean_matrix"] =
|
||||
::mediapipe::MakePacket<mediapipe::Matrix>(vggish_pca_mean_matrix);
|
||||
|
||||
RETURN_IF_ERROR(mediapipe::file::GetContents(
|
||||
MP_RETURN_IF_ERROR(mediapipe::file::GetContents(
|
||||
"/tmp/mediapipe/vggish_projection_matrix_data.pb", &content));
|
||||
vggish_pca_projection_matrix_data.ParseFromString(content);
|
||||
mediapipe::MatrixFromMatrixDataProto(vggish_pca_projection_matrix_data,
|
||||
@@ -102,9 +102,9 @@ DEFINE_string(output_side_packets, "",
|
||||
|
||||
LOG(INFO) << "Initialize the calculator graph.";
|
||||
mediapipe::CalculatorGraph graph;
|
||||
RETURN_IF_ERROR(graph.Initialize(config, input_side_packets));
|
||||
MP_RETURN_IF_ERROR(graph.Initialize(config, input_side_packets));
|
||||
LOG(INFO) << "Start running the calculator graph.";
|
||||
RETURN_IF_ERROR(graph.Run());
|
||||
MP_RETURN_IF_ERROR(graph.Run());
|
||||
LOG(INFO) << "Gathering output side packets.";
|
||||
kv_pairs = absl::StrSplit(FLAGS_output_side_packets, ',');
|
||||
for (const std::string& kv_pair : kv_pairs) {
|
||||
@@ -116,7 +116,7 @@ DEFINE_string(output_side_packets, "",
|
||||
<< "Packet " << name_and_value[0] << " was not available.";
|
||||
const std::string& serialized_string =
|
||||
output_packet.ValueOrDie().Get<std::string>();
|
||||
RETURN_IF_ERROR(
|
||||
MP_RETURN_IF_ERROR(
|
||||
mediapipe::file::SetContents(name_and_value[1], serialized_string));
|
||||
}
|
||||
return ::mediapipe::OkStatus();
|
||||
|
||||
Reference in New Issue
Block a user