webonnx / wonnx

A WebGPU-accelerated ONNX inference run-time written 100% in Rust, ready for native and the web
Other
1.65k stars 60 forks source link

Fix image loading with non-224x224 images #108

Closed SludgePhD closed 2 years ago

pixelspark commented 2 years ago

Good idea to make this more generic. Should we perhaps make the shape ((1,3,w,h), (3,w,h), (3,h,w) etc.) configurable? I am not sure what shape your model is using vs. what SqueezeNet (which this was written for) expect, it might differ between models.

SludgePhD commented 2 years ago

ONNX only works with NCHW, so only supporting (1, 3, h, w) should suffice (tf2onnx will however insert a Transpose node after the input to make the model accept NHWC inputs, unless --inputs-as-nchw is passed).

What should probably be made configurable is the expected input value range, since the MediaPipe networks don't require per-channel mean and stddev correction (and it needs values to be in range [-1.0, 1.0]). But this PR is sufficient to reproduce my issue in #109, so this isn't required for now.