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