如何在C ++ Android中正确获取tflite模型的输出

时间:2020-11-05 18:37:57

标签: android c++ tensorflow-lite

我正在尝试在Android上的C ++中实现人体姿态估计tflite模型。我正在使用CPM模型,并基于this示例创建代码。我必须在C ++中实现它才能与另一个项目结合。我不确定如何从输出中读取数据。

我知道它会返回一个1 x 96 x 96 x 14的数组。

我首先读取张量:

TfLiteTensor* output = interpreter->tensor(interpreter->outputs()[0]);
float* output_data_flat = output->data.f;

然后将数据读入具有嵌套for循环的适当大小的数组中

int outputIndex = 0;
for(int i = 0; i < 96; i++) {
    for(int j = 0; j < 96; j++) {
        for(int k = 0; k < 14; k++) {
            output_data[0][i][j][k] = output_data_flat[outputIndex++];
        }
    }
}

在对数据进行后期处理之后(我在python中工作过),没有得到任何接近预期结果的结果。

任何帮助将不胜感激。

0 个答案:

没有答案