我正在尝试在 Unity 的项目中使用 Tensorflowsharp。
我面临的问题是,对于转换,您通常使用第二个 Graph 将输入转换为张量。Android 不支持使用的函数 DecodeJpg 和 DecodePng 那么如何将该输入转换为张量?
private static void ConstructGraphToNormalizeImage(out TFGraph graph, out TFOutput input, out TFOutput output, TFDataType destinationDataType = TFDataType.Float)
{
const int W = 224;
const int H = 224;
const float Mean = 117;
const float Scale = 1;
graph = new TFGraph();
input = graph.Placeholder(TFDataType.String);
output = graph.Cast(graph.Div(
x: graph.Sub(
x: graph.ResizeBilinear(
images: graph.ExpandDims(
input: graph.Cast(
graph.DecodeJpeg(contents: input, channels: 3), DstT: TFDataType.Float),
dim: graph.Const(0, "make_batch")),
size: graph.Const(new int[] { …Run Code Online (Sandbox Code Playgroud)