Для декодирования raw_outputs/box_encodings
вам также необходимо anchors
, поскольку box_encodings кодируются относительно якорей.
Ниже приведена моя реализация декодирования raw_outputs/box_encodings
:
private float[][][] decodeBoxEncodings(final float[][][] boxEncoding, final float[][] anchor, final int numBoxes) {
final float[][][] decodedBoxes = new float[1][numBoxes][4];
for (int i = 0; i < numBoxes; ++i) {
final double ycenter = boxEncoding[0][i][0] / y_scale * anchor[i][2] + anchor[i][0];
final double xcenter = boxEncoding[0][i][1] / x_scale * anchor[i][3] + anchor[i][1];
final double half_h = 0.5 * Math.exp((boxEncoding[0][i][2] / h_scale)) * anchor[i][2];
final double half_w = 0.5 * Math.exp((boxEncoding[0][i][3] / w_scale)) * anchor[i][3];
decodedBoxes[0][i][0] = (float)(ycenter - half_h); //ymin
decodedBoxes[0][i][1] = (float)(xcenter - half_w); //xmin
decodedBoxes[0][i][2] = (float)(ycenter + half_h); //ymax
decodedBoxes[0][i][3] = (float)(xcenter + half_w); //xmax
}
return decodedBoxes;
}
Этот метод декодирования взят из TFLite обнаружение_процесса * операция 1010 *.
Редактирование: значения шкалы:
float y_scale = 10.0f;
float x_scale = 10.0f;
float h_scale = 5.0f;
float w_scale = 5.0f;