Notice the if statement is referencing options.tensorFormat, when it should be referencing options.inputFormat
To reproduce
When loading from image:
import { Tensor,TensorFactory, InferenceSession } from "onnxruntime-web";
((Tensor as any) as TensorFactory).fromImage(image, {tensorFormat:'RGB'}).then((tensor)=>{
console.log('tensor',newTensor);
}).catch((err)=>{
console.log('err',err);
});
Results in the following error:
Error: Image input config format must be RGBA for HTMLImageElement
Urgency
Without this, the library always loads tensors as RGBA when using fromImage. It will require the manual formatting of the image to create the tensor manually without the aid of the library.
Describe the issue
The functionality of Tensor.fromImage does not allow the tensorFormat option to function as expected due to a bug in the code.
https://github.com/microsoft/onnxruntime/blob/ef6f4a4aa1dbf9278379e630055a3075e5cda60e/js/common/lib/tensor-factory-impl.ts#L133C1-L137C10
Notice the if statement is referencing options.tensorFormat, when it should be referencing options.inputFormat
To reproduce
When loading from image:
Results in the following error:
Urgency
Without this, the library always loads tensors as RGBA when using fromImage. It will require the manual formatting of the image to create the tensor manually without the aid of the library.
ONNX Runtime Installation
Released Package
ONNX Runtime Version or Commit ID
1.15.1
Execution Provider
'wasm'/'cpu' (WebAssembly CPU)