Tensorflow提供了他们的姿势估计模型:multi_person_mobilenet_v1_075_float.tflite
。 hosted_models
我发现此模型的输出已连接。生成的热图中的数字似乎是随机的。有人成功运行了吗?
我关注了博客:browser-with-tensorflow
我在下面附加了我的代码:
for(int i = 0; i < keyPointsNum; i ++) {
for(int x = 0; x < outputW; x++){
for(int y = 0; y < outputH; y++){
heatMapArray[0][x][y][i] = (float)(1.0 / ( Math.exp(heatMapArray[0][x][y][i] * -1) + 1));
}
}
}
// 2. argmax2d
int[][] keyPointsRaw = new int[keyPointsNum][2];
float[] scores = new float[keyPointsNum];
for(int i=0; i<keyPointsNum; i++){
float maxScore = -10000f;
for(int y = 0; y < outputW; y++){
for(int x = 0; x < outputH; x++){
if(maxScore < heatMapArray[0][y][x][i]){
maxScore = heatMapArray[0][y][x][i];
keyPointsRaw[i][X] = x;
keyPointsRaw[i][Y] = y;
scores[i] = maxScore;
}
}
}
}
// 3. keypoint
float[][] keyPoints = new float[keyPointsNum][2];
for(int k=0; k<keyPointsNum; k++){
float[] offsetVector = {offsets[0][keyPointsRaw[k][1]][keyPointsRaw[k][0]][k], offsets[0][keyPointsRaw[k][1]][keyPointsRaw[k][0]][k+17]};
keyPoints[k][X] = keyPointsRaw[k][X] * 16 + offsetVector[X];
keyPoints[k][Y] = keyPointsRaw[k][Y] * 16 + offsetVector[Y];
}