Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

187
Views
ONNX Runtime Web WebGL support when input differs from power of two

I have a custom ONNX model that takes Images of the size [batch_size, 1280, 720, 1] as inputs which I want to run with WebGL on a smartphone. The html file looks like this (I am setting the input Img to zero just for simplicity to test the model) :

<script src="https://cdn.jsdelivr.net/npm/onnxruntime-web/dist/ort.min.js"></script>
<script type="module">
var Img = new Float32Array(1280*720)
for(var i = 0; i < Img.byteLength; i++) {
    Img[i] = 0
}
const session = await ort.InferenceSession.create('./Model.onnx', { executionProviders: ['webgl'] });
const tensorImg = new ort.Tensor("float32", Img, [1, 1280, 720, 1])
const feeds = { "input_1": tensorImg }
const results = await session.run(feeds)
console.log(results)
</script>

This complains first about wrong dimensions:

WebGL: INVALID_VALUE: texImage2D: width or height out of range

and then that the input is NaN:

Uncaught TypeError: Invalid shape: NaN is not an integer
    at Function.validateDimsAndCalcSize (util.ts:730:15)

My guess is that, because the input images' dimensions are not powers of two, it cannot work on webgl. When I use "wasm" instead of "webgl" it works, but is very slow. What can I do? Is there a way to solve this without changing the network architecture?

Thanks a lot

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!