Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Cannot resolve operator "Shape" with opset: ai.onnx v9 #265

Open
weingaunity opened this issue Feb 19, 2021 · 3 comments
Open

Cannot resolve operator "Shape" with opset: ai.onnx v9 #265

weingaunity opened this issue Feb 19, 2021 · 3 comments

Comments

@weingaunity
Copy link

Hi, i try to load a onnx model of mobilenet v3 which i have exportet with pytorch.

When i try to load the model in the browser using following exception is thrown:

Uncaught (in promise) TypeError: cannot resolve operator 'Shape' with opsets: ai.onnx v9

According to the documentation it should be supported starting from version 1+.

Which backend is used by onnx.min.js?

Here the onnx creation process:

from mobilenetv3 import mobilenetv3_large, mobilenetv3_small

net_large = mobilenetv3_large()
net_small = mobilenetv3_small()

net_large.load_state_dict(torch.load('pretrained/mobilenetv3-large-1cd25616.pth'))
net_small.load_state_dict(torch.load('pretrained/mobilenetv3-small-55df8e1f.pth'))

net_large.classifier=net_large.classifier[:-1]
net_small.classifier=net_small.classifier[:-1]

x = torch.randn(1, 3, 224, 224)
torch.onnx.export(
    net_small,
    x,
    "../01_WebApp/mobilenetv3_small.onnx",
    export_params=True,
    input_names=['input'],
    output_names=['output'],
    #opset_version=10,
)
@31b41a59l26u53
Copy link

Similar here. Why is this not in the WebGl operator set?

@weingaunity
Copy link
Author

Despite the fact, that in my case webgl seems not to work, i worked around the missing shape function issue by changing the network structure.

But at the end i used tensorflow to inference. So i converted the onnx model to a tensorflow model and exported to tensorflow.js. This works very well and supports webgl.

@smilemakc
Copy link

Uncaught (in promise) TypeError: cannot resolve operator 'Shape' with opsets: ai.onnx v9

You need replace code in places such as x.view(x.size(0), -1) on explicit value instead of x.size(0)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants