3

Hello everyone i am using an ONNX object detection model for detecting items in a picture. I implemented the code by following steps on ONNX js Github repository (https://github.com/microsoft/onnxjs).

The code is working superb but i don't know how to process the ONNX model output to read the Bounding Box cordinates and probability.

There are plenty of examples online about how to process the output in python but there is no resource online about how to do it in javascript for ONNX js.

If anybody knows please help.

This is the output i am getting from ONNX model :

enter image description here

This is the code i am using to run model in browser :

 // Creat the session and load the pre-trained model
    const session = new onnx.InferenceSession({
        backendHint: 'webgl'
    });

    await session.loadModel("./model.onnx");

    // Run model with Tensor inputs and get the result.

        // Load image.
        const imageLoader = new ImageLoader(imageSize, imageSize);
        const imageData = await imageLoader.getImageData('./box.jpg');

        // Preprocess the image data to match input dimension requirement
        const width = imageSize;
        const height = imageSize;
        const preprocessedData = preprocess(imageData.data, width, height);

        const inputTensor = new onnx.Tensor(preprocessedData, 'float32', [1, 3, width, height]);
        const outputMap = await session.run([inputTensor]);
        const outputData = outputMap.values().next().value;
        var x = outputData.toString();

        console.log(outputData);
Aakash Bhadana
  • 302
  • 2
  • 17

0 Answers0