How to predict the YOLO-obb model?

#18
by lvpeng12138 - opened

public void SetObbInput()
{
centersToCorners = new Tensor(new TensorShape(4, 4),
new float[]
{
1, 0, 1, 0,
0, 1, 0, 1,
-0.5f, 0, 0.5f, 0,
0, -0.5f, 0, 0.5f,
});
//Here we transform the output of the model1 by feeding it through a Non-Max-Suppression layer.
var graph = new FunctionalGraph();
var inputs = graph.AddInputs(model);
var modelOutput = Functional.Forward(model, inputs)[0]; //shape=(1,84,8400)
var boxCoords = modelOutput[0, 0..4, ..].Transpose(0, 1); //shape=(8400,4)
var allScores = modelOutput[0, 4..5];
var angle = modelOutput[0, 5.., ..]; //shape=(80,8400)
var scores = Functional.ReduceMax(allScores, 0); //shape=(8400)
var classIDs = Functional.ArgMax(allScores, 0); //shape=(8400)

    var boxCorners = Functional.MatMul(boxCoords, Functional.Constant(centersToCorners));   //shape=(8400,4)
    var indices = Functional.NMS(boxCorners, scores, iouThreshold, scoreThreshold); //shape=(N)
    var coords = Functional.IndexSelect(boxCoords, 0, indices);                     //shape=(N,4)
    var labelIDs = Functional.IndexSelect(classIDs, 0, indices);                    //shape=(N)
    var conf = Functional.IndexSelect(scores, 0, indices);
    var rotation = Functional.IndexSelect(angle, 0, indices);

    //Create worker to run model
    worker = new Worker(graph.Compile(coords, rotation, labelIDs, conf), backend);

}

How to obtain the rotation angle in the vector?

Sign up or log in to comment