microsoft / microsoft/onnxruntime
[Web] TypeError: Cannot read properties of undefined (reading 'inputs')
- Dominant language
- C++
- Stars
- 21.9k
- Forks
- 4.2k
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 184
Description
### Describe the issue
I've converted my PyTorch model into ONNX so that I can run inference in the browser. When trying to just create an ort.InferenceSession with this onnx file, I get the following error.
```
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'inputs')
at graph.ts:644:35
at Array.forEach ()
at p.finalizeGraph (graph.ts:643:29)
at p.transformGraph (graph.ts:576:10)
at new p (graph.ts:155:10)
at Object.from (graph.ts:83:7)
at e.Model.loadFromOnnxFormat (model.ts:44:25)
at e.Model.load (model.ts:22:14)
at session.ts:93:19
at e.Profiler.event (instrument.ts:337:17)
```
### To reproduce
To trace the PyTorch model:
```python
with torch.no_grad():
pytorch_out = model(input_tensor)
jit_model = torch.jit.trace(model, input_tensor)
```
To export the model to ONNX
I saw a semi-similar issue that made it seem as if I had to turn on `keep_initializers_as_inputs`, so I tried setting that to True (where it was false before). Neither worked.
```python
torch.onnx.export(
model,
dummy_tensor,
output_file,
export_params=True,
keep_initializers_as_inputs=True,
opset_version=12,
input_names=['input'],
output_names=['output'])
```
To run the model in Javascript:
```javascript
const options = { executionProviders: ['webgl'], graphOptimizationLevel: 'all' };
const session = await ort.InferenceSession.create('model.onnx', options);
```
Model found here: https://file.io/fW3WXwt9ecKp
### Urgency
Urgent to make progress on our product
### ONNX Runtime Installation
Released Package
### ONNX Runtime Version or Commit ID
1.14.0
### Execution Provider
WebGL
Contributor guide
Assessment
This issue has not been assessed yet.