Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

188
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda