Giter VIP home page Giter VIP logo

Comments (4)

lindapaiste avatar lindapaiste commented on August 26, 2024

I think that all we need is an await tf.ready() statement in neuralNetwork init method. #105 (comment)

The ml5.setBackend function is an oddball because it initializes an asynchronous change but doesn't wait for it (tf.setBackend is async). So we need to wait for TF to be fully set up before using it.

from ml5-next-gen.

ziyuan-linn avatar ziyuan-linn commented on August 26, 2024

Adding await tf.ready() seems to work! However, a new error occurred now that we are using webgpu backend:

Error: WebGPU readSync is only available for CPU-resident tensors.
    at ms.readSync (pose-detection.esm.js:17:87509)
    at Engine.readSync (engine.js:943:1)
    at Tensor.dataSync (tensor.js:297:1)
    at Tensor.arraySync (tensor.js:228:29)
    at NeuralNetworkData.js:509:1
    at engine.js:328:1
    at Engine.scopedRun (engine.js:338:1)
    at Engine.tidy (engine.js:327:1)
    at Module.tidy (globals.js:175:18)
    at NeuralNetworkData.createOneHotEncodings (NeuralNetworkData.js:494:12)

I will try to investigate this further.

from ml5-next-gen.

lindapaiste avatar lindapaiste commented on August 26, 2024

Over the long term I think that the ideal thing would be to avoid synchronous operations and use .array() instead of .arraySync(). However this function is called way deep in a chain so there's a lot of methods that would need to be converted to async for that to work.

It seems like the error has been fixed by TFJS, not sure what version it was released in. It might be that we need to bump our dependencies.
Fix PR: tensorflow/tfjs#7576
Issue: tensorflow/tfjs#5468

from ml5-next-gen.

ziyuan-linn avatar ziyuan-linn commented on August 26, 2024

Thank you @lindapaiste! I will try to bump the dependencies and see what happens. I agree that switching to async would be ideal over the long term.

from ml5-next-gen.

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.