Giter VIP home page Giter VIP logo

Comments (18)

JonathanSum avatar JonathanSum commented on August 28, 2024 7

Mine is solved. Not very difficult to solve. The problem is related to ONNX.

Solution1(It should solve most people's problem, but I didn't use it):
One of the issues and solutions is ONNX does not support all the features of a Pytorch. Sometimes you have to degrade the version of ONNX to the older one to have certain features. On the other hand, you may find out the older version doesn't support another important feature. But trust me, you will find a better way to solve it, which is what I did when I was using on ReactJs.

Solution2
It was my solution that was about digging into ONNX itself. Thus, I suggest you talk to the ONNX coder to solve your issue.

Not that difficult to solve. Here is mine which is solved and runs perfectly🤣
output

If you have an interesting project. feel free to contact me. Maybe there is a possibility that I can solve it if I have free time on that day if it is running in Tensorflow, Kernes(TF2), or Pytorch.

from onnxjs.

EJShim avatar EJShim commented on August 28, 2024 6

Can this be solved or not?

I am having same error using below code, which worked fine in onnxruntime python and CPP.

 <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/onnx.min.js"></script>
    <!-- Code that consume ONNX.js -->
    <script>
      // create a session
      const myOnnxSession = new onnx.InferenceSession();
      // load the ONNX model file
      myOnnxSession.loadModel("./200_0.19.onnx").then(() => {
        // generate model input
        // const inferenceInputs = getInputs();

        // console.log(inferenceInputs)
        // execute the model
        // myOnnxSession.run(inferenceInputs).then((output) => {
        //   // consume the output
        //   const outputTensor = output.values().next().value;
        //   console.log(`model output tensor: ${outputTensor.data}.`);
        // });
      });
    </script>

I built onnxjs using master branch of this repository, but still getting same error.

from onnxjs.

codingdudecom avatar codingdudecom commented on August 28, 2024 4

what the heck guys, "I solved this" then no more details, or "Here's 2 solutions: one, I don't know if it works, and second one is talk the ONNX coder"

I was hoping for an actual solution to this...

from onnxjs.

kbrose avatar kbrose commented on August 28, 2024 2

Repeating what I said above, the Shape operation was added after the latest version (v0.1.8) was released. We won't be able to use the Shape operation until a new version is released.

You can verify this by downloading the snapshot of the code for the release and see that it does not contain the file lib/ops/Shape.ts

from onnxjs.

kbrose avatar kbrose commented on August 28, 2024 1

I still see this error using version 0.1.8.

from onnxjs.

fs-eire avatar fs-eire commented on August 28, 2024

onnxjs-node cannot work in browser environments. it does not work with worker-loader either, as the latter is specifically targeting running in webworker.

supporting Shape is a known issue as referenced in #84

from onnxjs.

28Smiles avatar 28Smiles commented on August 28, 2024

The operator Shape is now available in version 0.1.8.

from onnxjs.

kbrose avatar kbrose commented on August 28, 2024

The shape.ts file hit the master branch on Sep 1 but 0.1.8 was released on August 28, so maybe it just missed the cut to make it into 0.1.8?

from onnxjs.

JonathanSum avatar JonathanSum commented on August 28, 2024

image
Mine is 0.1.8 too! I am not using a nodejs, but Reactjs.

from onnxjs.

28Smiles avatar 28Smiles commented on August 28, 2024

What backend are u using?
It's only implemented in the cpu backend.

from onnxjs.

JonathanSum avatar JonathanSum commented on August 28, 2024

It was all backend failed. The problem is solved.

from onnxjs.

28Smiles avatar 28Smiles commented on August 28, 2024

I do not understand your message, but good thing if it works.

from onnxjs.

Andredance avatar Andredance commented on August 28, 2024

Hi, I am using backendHint="cpu" with onnxjs 0.1.8 but got the same error

TypeError: cannot resolve operator 'Shape' with opsets: ai.onnx v9
    at Object.e.resolveOperator (onnx.min.js:1)
    at t.resolve (onnx.min.js:14)
    at e.initializeOps (onnx.min.js:14)
    at onnx.min.js:14
    at t.event (onnx.min.js:1)
    at e.initialize (onnx.min.js:14)
    at e.<anonymous> (onnx.min.js:14)
    at onnx.min.js:14
    at Object.next (onnx.min.js:14)
    at a (onnx.min.js:14)

@JonathanSum how did you solve the problem?
@28Smiles maybe any advices how to solve it?

from onnxjs.

dhirajnitk avatar dhirajnitk commented on August 28, 2024

Uncaught (in promise) TypeError: cannot resolve operator 'SVMClassifier' with opsets: ai.onnx v9, ai.onnx.ml v

Built onnxjs with master branch & it seems that SVMClassifier is not supported ops for wasm.
(list of supported functions are mentioned)

from onnxjs.

AiueoABC avatar AiueoABC commented on August 28, 2024

I also have same issue saying "Uncaught (in promise) TypeError: cannot resolve operator 'Shape' with opsets: ai.onnx v9".
Should I modify a model I using not to pass "shape" things???
I feel it will be ok if I can rewrite "Shape" to "ReShape" in the onnx model, but is this possible?
If not, I should retrain things right?

from onnxjs.

dhirajnitk avatar dhirajnitk commented on August 28, 2024

@JonathanSum
Congratulations.
Is there any ported SVMClassifier ops that can be easily integrated with wasm_ops

from onnxjs.

braindotai avatar braindotai commented on August 28, 2024

This is not necessarily a webpack issue (as far as I know)... there are multiple reasons why this error might occur. The most common reason is using really custom reshaping operation in your PyTorch's model definition in python... like x.view(-1, x.size(0)), or x.reshape(x.shape[0], ...) ....

What solved the issue for me is by making sure that your python code is saying explicit numbers (1, 2, 256, 512, ...)... not x.size(0)

For this, you might need to log every reshaping step and print the shapes, and then use those values to make reshaping explicit and convert the model again to onnx format.

Hope this finally helps 😪

from onnxjs.

hyperparameters avatar hyperparameters commented on August 28, 2024

getting the TypeError: cannot resolve operator 'Shape' with opsets: ai.onnx v10
with a mobilenet model from onnx model zoo?

https://github.com/onnx/models/blob/master/vision/classification/mobilenet/model/mobilenetv2-7.onnx

using [email protected]

from onnxjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.