Skip to content

Commit

Permalink
feat: implement HolisticLandmarker
Browse files Browse the repository at this point in the history
  • Loading branch information
homuler committed Jan 19, 2025
1 parent fe23974 commit e7aeec9
Show file tree
Hide file tree
Showing 9 changed files with 682 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,7 @@ public CalculatorGraphConfig GenerateGraphConfig(bool enableFlowLimiting = false
return new CalculatorGraphConfig()
{
Node = {
new CalculatorGraphConfig.Types.Node()
{
Calculator = taskGraph,
Options = taskOptions.ToCalculatorOptions(),
InputStream = { inputStreams },
OutputStream = { outputStreams },
},
BuildConfigNode(taskGraph, taskOptions, inputStreams, outputStreams),
},
InputStream = { inputStreams },
OutputStream = { outputStreams },
Expand Down Expand Up @@ -80,13 +74,7 @@ public CalculatorGraphConfig GenerateGraphConfig(bool enableFlowLimiting = false
OutputStream = { throttledInputStreams.Select(Tool.ParseNameFromStream) },
Options = flowLimiterOptions,
},
new CalculatorGraphConfig.Types.Node()
{
Calculator = taskGraph,
InputStream = { throttledInputStreams },
OutputStream = { outputStreams },
Options = taskOptions.ToCalculatorOptions(),
},
BuildConfigNode(taskGraph, taskOptions, throttledInputStreams, outputStreams),
},
InputStream = { inputStreams },
OutputStream = { outputStreams },
Expand All @@ -98,5 +86,30 @@ private static string AddStreamNamePrefix(string tagIndexName)
Tool.ParseTagAndName(tagIndexName, out var tag, out var name);
return $"{tag}:throttled_{name}";
}

private static CalculatorGraphConfig.Types.Node BuildConfigNode(string calculator, T taskOptions, IEnumerable<string> inputStreams, IEnumerable<string> outputStreams)
{
var node = new CalculatorGraphConfig.Types.Node()
{
Calculator = calculator,
InputStream = { inputStreams },
OutputStream = { outputStreams },
};

var calculatorOptions = taskOptions.ToCalculatorOptions();
if (calculatorOptions != null)
{
node.Options = calculatorOptions;
return node;
}
var anyOptions = taskOptions.ToAnyOptions();
if (anyOptions != null)
{
node.NodeOptions.Add(anyOptions);
return node;
}

throw new NotSupportedException($"{typeof(T)} cannot be converted to Calculator's options");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ namespace Mediapipe.Tasks.Core
{
internal interface ITaskOptions
{
CalculatorOptions ToCalculatorOptions();
CalculatorOptions ToCalculatorOptions() => null;

Google.Protobuf.WellKnownTypes.Any ToAnyOptions() => null;
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e7aeec9

Please sign in to comment.