Git Product home page Git Product logo

Comments (3)

nsthorat avatar nsthorat commented on May 18, 2024

We're not planning on supporting pytorch in the immediate future, however there is a path to use the old checkpoint loader with pytorch.

The legacy loader with the pytorch weight-dumper script can be used: https://github.com/PAIR-code/deeplearnjs-legacy-loader

The legacy loader currently depends on deeplearn, so you're going to have a dependency problem for the JS (the python will still work).

Thankfully, all of the logic lives in a single file with 1 dependency (Tensor). This means you could just copy this file into your project: https://github.com/PAIR-code/deeplearnjs-legacy-loader/blob/master/src/checkpoint_loader.ts

You can swap the import of 'deeplearn' with '@tensorflow/tfjs' or '@tensorflow/tfjs-core' and it should just work.

from tfjs.

faroit avatar faroit commented on May 18, 2024

Thanks a lot for the pointer. I will try that.

from tfjs.

slawojstanislawski avatar slawojstanislawski commented on May 18, 2024

I had a .pth file (containing a pytorch model I presume) and using the method outlined above I was able to get the output: a long list of _weight and _bias files, as well as one manifest.json file. This is in line with what's described here. Finally calling the getAllVariables() method of the legacy loader gets me the variables. However, I can't figure out the steps to move from this vars variable to a usable, tensorflowjs-importable model. Is it by writing out the model manually as it's described on the linked page (I'm not the author of the model, so it's problematic), use tfjs converter in some way, or there's a different procedure?

from tfjs.

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.