Giter Site home page Giter Site logo

Comments (4)

wpmed92 avatar wpmed92 commented on August 15, 2024

Hi!
I use U-2-Net on Android, which internally uses C++ and I managed to make it work.
With trace I couldn't make it work, instead I used the following mode of converting to TorchScript:

net.load_state_dict(torch.load(model_dir, map_location=torch.device('cpu')))

if torch.cuda.is_available():
net.cuda()

scripted = torch.jit.script(net)
torch.jit.save(scripted, "fod.p")

Hope this helps.

from u-2-net.

DBraun avatar DBraun commented on August 15, 2024

@wpmed92 Thanks for your suggestion. I did what you suggested, and torch.cuda.is_available() was still true. However, in C++ the model seems to stall forever on the ->forward call. No error, just taking forever.

from u-2-net.

wpmed92 avatar wpmed92 commented on August 15, 2024

Oh, I see.
Not completely related, but we found something really interesting. On Android the jit.script() saved model inference runs in about a sec, on iOS it was 30 sec, so on iOS we use the traced model, which turns out to be running at about the same speed as on Android. Internally both platforms use the same C++ library, so I'm wondering what may cause such difference.

from u-2-net.

DBraun avatar DBraun commented on August 15, 2024

Glad to have finally resolved this. I'm using TouchDesigner as my environment that loads and executes from my DLL. It turns out I needed to paste ALL the libtorch DLLs in a location that TouchDesigner itself would load them C:/Program Files/Derivative/TouchDesigner/bin, not just when my custom DLL is loaded from Documents/Derivative/Plugins

from u-2-net.

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.