microsoft / onnxjs

ONNX.js: run ONNX models using JavaScript
Other
1.75k stars 130 forks source link

Error: input 'attention_mask' is missing in 'feeds'. #307

Open kshuraj opened 3 years ago

kshuraj commented 3 years ago

I would like to know if the Tensor() in onnx.js would support mask token. I am using the 'bert-base-cased' model to predict the masked text. https://huggingface.co/bert-base-cased

`const onnx = require('onnxjs-node');

async function main() { const url = "model_output/bert-base-cased.onnx";

const session = new onnx.InferenceSession();
await session.loadModel(url);

// const inputs = [new onnx.Tensor(["I", "<MASK>","to","mars"], "string"), ]  **# I would require help here of how we can provide a input.** 
const inputs = [new onnx.Tensor([])

session.run(inputs)
        .then(
            (data) => {
                console.log("+++++++++++++++ SUCCESS +++++++++++++");
                console.log(data);
                console.log(data.values.next().value);
            }
        )
        .catch(
            (error) => {
                console.log("---------------- ERROR --------------");
                console.log(error);
            }
        );

}

main(); ` Any help would be greatly appreciated. Thanks in advance.

fs-eire commented 2 years ago

Thanks for your feedback!

For running ONNX model inferencing in Node.js, onnxjs-node is replaced by ONNX Runtime Node.js binding. This uses the up-to-date ONNXRuntime backend (v1.8), while onnxjs-node uses ONNXRuntime v1.4

please check it out to see if it resolves the issue.