Minor updates to MediaPipe graph documentation: use Graph/CalculatorGraphConfig instead of GraphConfig and mention that node can be a subgraph.
PiperOrigin-RevId: 508517281
This commit is contained in:
parent
fd764dae0a
commit
2163920ee8
|
@ -12,26 +12,25 @@ nav_order: 2
|
||||||
{:toc}
|
{:toc}
|
||||||
---
|
---
|
||||||
|
|
||||||
## GraphConfig
|
## Graph
|
||||||
|
|
||||||
A `GraphConfig` is a specification that describes the topology and functionality
|
A `CalculatorGraphConfig` proto specifies the topology and functionality of a
|
||||||
of a MediaPipe graph. In the specification, a node in the graph represents an
|
MediaPipe graph. Each `node` in the graph represents a particular calculator or
|
||||||
instance of a particular calculator. All the necessary configurations of the
|
subgraph, and specifies necessary configurations, such as registered
|
||||||
node, such its type, inputs and outputs must be described in the specification.
|
calculator/subgraph type, inputs, outputs and optional fields, such as
|
||||||
Description of the node can also include several optional fields, such as
|
|
||||||
node-specific options, input policy and executor, discussed in
|
node-specific options, input policy and executor, discussed in
|
||||||
[Synchronization](synchronization.md).
|
[Synchronization](synchronization.md).
|
||||||
|
|
||||||
`GraphConfig` has several other fields to configure the global graph-level
|
`CalculatorGraphConfig` has several other fields to configure global graph-level
|
||||||
settings, eg, graph executor configs, number of threads, and maximum queue size
|
settings, e.g. graph executor configs, number of threads, and maximum queue size
|
||||||
of input streams. Several graph-level settings are useful for tuning the
|
of input streams. Several graph-level settings are useful for tuning the
|
||||||
performance of the graph on different platforms (eg, desktop v.s. mobile). For
|
performance of the graph on different platforms (e.g., desktop v.s. mobile). For
|
||||||
instance, on mobile, attaching a heavy model-inference calculator to a separate
|
instance, on mobile, attaching a heavy model-inference calculator to a separate
|
||||||
executor can improve the performance of a real-time application since this
|
executor can improve the performance of a real-time application since this
|
||||||
enables thread locality.
|
enables thread locality.
|
||||||
|
|
||||||
Below is a trivial `GraphConfig` example where we have series of passthrough
|
Below is a trivial `CalculatorGraphConfig` example where we have series of
|
||||||
calculators :
|
passthrough calculators :
|
||||||
|
|
||||||
```proto
|
```proto
|
||||||
# This graph named main_pass_throughcals_nosubgraph.pbtxt contains 4
|
# This graph named main_pass_throughcals_nosubgraph.pbtxt contains 4
|
||||||
|
@ -65,7 +64,7 @@ To modularize a `CalculatorGraphConfig` into sub-modules and assist with re-use
|
||||||
of perception solutions, a MediaPipe graph can be defined as a `Subgraph`. The
|
of perception solutions, a MediaPipe graph can be defined as a `Subgraph`. The
|
||||||
public interface of a subgraph consists of a set of input and output streams
|
public interface of a subgraph consists of a set of input and output streams
|
||||||
similar to a calculator's public interface. The subgraph can then be included in
|
similar to a calculator's public interface. The subgraph can then be included in
|
||||||
an `CalculatorGraphConfig` as if it were a calculator. When a MediaPipe graph is
|
a `CalculatorGraphConfig` as if it were a calculator. When a MediaPipe graph is
|
||||||
loaded from a `CalculatorGraphConfig`, each subgraph node is replaced by the
|
loaded from a `CalculatorGraphConfig`, each subgraph node is replaced by the
|
||||||
corresponding graph of calculators. As a result, the semantics and performance
|
corresponding graph of calculators. As a result, the semantics and performance
|
||||||
of the subgraph is identical to the corresponding graph of calculators.
|
of the subgraph is identical to the corresponding graph of calculators.
|
||||||
|
@ -151,7 +150,7 @@ protobuf specified for a MediaPipe calculator. These "graph options" can be
|
||||||
specified where a graph is invoked, and used to populate calculator options and
|
specified where a graph is invoked, and used to populate calculator options and
|
||||||
subgraph options within the graph.
|
subgraph options within the graph.
|
||||||
|
|
||||||
In a CalculatorGraphConfig, graph options can be specified for a subgraph
|
In a `CalculatorGraphConfig`, graph options can be specified for a subgraph
|
||||||
exactly like calculator options, as shown below:
|
exactly like calculator options, as shown below:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -178,7 +177,7 @@ node {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
In a CalculatorGraphConfig, graph options can be accepted and used to populate
|
In a `CalculatorGraphConfig`, graph options can be accepted and used to populate
|
||||||
calculator options, as shown below:
|
calculator options, as shown below:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -188,7 +187,7 @@ graph_options: {
|
||||||
|
|
||||||
node: {
|
node: {
|
||||||
calculator: "ImageToTensorCalculator"
|
calculator: "ImageToTensorCalculator"
|
||||||
input_stream: "IMAGE:multi_backend_image"
|
input_stream: "IMAGE:image"
|
||||||
node_options: {
|
node_options: {
|
||||||
[type.googleapis.com/mediapipe.ImageToTensorCalculatorOptions] {
|
[type.googleapis.com/mediapipe.ImageToTensorCalculatorOptions] {
|
||||||
keep_aspect_ratio: true
|
keep_aspect_ratio: true
|
||||||
|
@ -247,9 +246,9 @@ NOTE: The current approach is experimental and subject to change. We welcome
|
||||||
your feedback.
|
your feedback.
|
||||||
|
|
||||||
Please use the `CalculatorGraphTest.Cycle` unit test in
|
Please use the `CalculatorGraphTest.Cycle` unit test in
|
||||||
`mediapipe/framework/calculator_graph_test.cc` as sample code. Shown
|
`mediapipe/framework/calculator_graph_test.cc` as sample code. Shown below is
|
||||||
below is the cyclic graph in the test. The `sum` output of the adder is the sum
|
the cyclic graph in the test. The `sum` output of the adder is the sum of the
|
||||||
of the integers generated by the integer source calculator.
|
integers generated by the integer source calculator.
|
||||||
|
|
||||||
![a cyclic graph that adds a stream of integers](https://mediapipe.dev/images/cyclic_integer_sum_graph.svg "A cyclic graph")
|
![a cyclic graph that adds a stream of integers](https://mediapipe.dev/images/cyclic_integer_sum_graph.svg "A cyclic graph")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user