Skip to content

[Web] Yolov8 WebGl backend - Uncaught (in promise) Error: resize (packed) does not support mode: 'nearest' #19779

Open
@wimvanhenden-tool

Description

@wimvanhenden-tool

Describe the issue

Trying to run Yolov8.onnx file with WebGl backend in javascript fails.

Uncaught (in promise) Error: resize (packed) does not support mode: 'nearest'
at Tb (resize-packed.ts:81:15)
at Object.get (resize-packed.ts:28:24)
at Qn.executeProgram (inference-handler.ts:64:100)
at Qn.run (inference-handler.ts:82:36)
at Object.zi [as impl] (resize-packed.ts:24:39)
at execution-plan.ts:99:61
at zn.event (instrument.ts:337:17)
at execution-plan.ts:98:48

This is basically the code I am running to test:

const modelName = "yolov8n.onnx";
const modelInputShape = [1, 3, 640, 640];

model = await ort.InferenceSession.create(modelName, { executionProviders: ['webgl'] });
const tensor = new ort.Tensor("float32",new Float32Array(modelInputShape.reduce((a, b) => a * b)),modelInputShape);
await model.run({ images: tensor });
  1. The Yolov8n.onnx inference works fine when running in Python with Ultralytics library.
  2. Used opset is 12, higher version give will not load. Return error:
    TypeError: cannot resolve operator 'Split' with opsets: ai.onnx v17
  3. Model loads and runs fine on cpu or wasm backend.

Thank you for your help.

To reproduce

  1. Download Yolov8n onnx model here MODEL

  2. Run this HTML page in a webserver (LiveServer in Visual Studio Code fi):


<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"/>
    <title>Yolov8 test</title>

    <!-- ONNX RUNTIME -->
    <script src="https://cdn.jsdelivr.net/npm/onnxruntime-web/dist/ort.min.js"></script>
  </head>
  <body>
   <script>
    const modelName = "yolov8n.onnx";
    const modelInputShape = [1, 3, 640, 640];
    async function testModel() {
    
        let model =  await ort.InferenceSession.create(modelName, { executionProviders: ['webgl'] });
        const tensor = new ort.Tensor("float32",new Float32Array(modelInputShape.reduce((a, b) => a * b)),modelInputShape);
        await model.run({ images: tensor });
    }
    testModel();
    </script>
  </body>
</html>

Urgency

No response

ONNX Runtime Installation

Released Package

ONNX Runtime Version or Commit ID

1.17.1

Execution Provider

'webgl' (WebGL)

Metadata

Metadata

Assignees

No one assigned

    Labels

    api:Javascriptissues related to the Javascript APIplatform:webissues related to ONNX Runtime web; typically submitted using templatestaleissues that have not been addressed in a while; categorized by a bot

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions