I am using YOLOv8 for object detection in a React app, and I'm having trouble interpreting the output of the model. I have taken the official "yolov8n.pt" model from Ultralytics and converted it to a web model in python like this:
model = YOLO("yolov8n.pt") # load an official model
model.export(format="tfjs") # Export the model
I have added the resulting model.json to my public folder in my React app. Then, I preprocess an image and make a prediction using the model like this:
const imagePrediction = async () => {
const model = await loadGraphModel('/yolon-model/model.json');
const image = document.getElementsByClassName('catImage')[0]
const tfimg = tf.browser.fromPixels(image).toInt();
const tfimg_res = tf.image.resizeBilinear(tfimg, [640, 640]);
const expandedimg = tfimg_res.transpose([0, 1, 2]).expandDims();
const predictions = await model.executeAsync(expandedimg);
console.log(predictions)
}
The output tensor is of shape 1x84x8400, and there are 80 classes in the official yolov8n model. I'm not sure how to interpret this output and how to extract the bounding boxes and their corresponding classes. Can someone please help me with this? Thank you!