Git Product home page Git Product logo

Comments (5)

chrisklaiber avatar chrisklaiber commented on July 23, 2024

Hi @JohnZcp - I'd first ensure the model file exists and is non-zero, and second that the relative require() path is correct. These are the two things that usually trip me up here.

Given that you're loading require('../models/mobilenet_v3_small.ptl'); from within /Users/ziyuanzhou/Desktop/signdectection/signdetection/src/screens/CameraScreenTest.js I would expect it to resolve to /Users/ziyuanzhou/Desktop/signdectection/signdetection/src/models/mobilenet_v3_small.ptl and so:

ls -lh /Users/ziyuanzhou/Desktop/signdectection/signdetection/src/models/mobilenet_v3_small.ptl

My guess is that you need another ../ in the relative require() path, since in the default project template, models/ is at the same level as src/.

from playtorch.

JohnZcp avatar JohnZcp commented on July 23, 2024

models/ and screens/ are at the same level, they are in the src/. I tried to enter the path layer by layer, and it seems like my project just doesn't recognize this .ptl type file.
Screen Shot 2022-01-19 at 10 21 53 PM

from playtorch.

chrisklaiber avatar chrisklaiber commented on July 23, 2024

I don't know what backs the autocomplete in your editor, but the asset loading is handled by Metro, and that is driven by the metro.config.js at the project root. To support the model files, the .ptl extension is added to resolver.assetExts.

From your error message, it almost seems like Metro is trying a regex (for the given extensions) and that .ptl is not present. I don't know why that would be.

Did the default project template work for you? At what point did model loading break?

Hmm, looking at the Metro documentation, I see there is assetExts as well as sourceExts: https://facebook.github.io/metro/docs/configuration/#resolver-options

I wonder if sourceExts is used for files below the src/ directory, and assetExts elsewhere. Can you try moving models/ up a level to be a peer to src/?

from playtorch.

JohnZcp avatar JohnZcp commented on July 23, 2024

Thanks for your help. I just figure out the problem. All I need is to do is adding the .ptl extension in sourceExts in metro.config.js, and be sure the model file is placed under src/ .

from playtorch.

chrisklaiber avatar chrisklaiber commented on July 23, 2024

I'm glad to hear that you found a solution, @JohnZcp!

One more thing you might want to check is to ensure that this works in the release build. Metro handles file loading differently in dev mode and release mode, and it may have an impact on your approach here.

For example, if you normally build in dev mode with yarn android, try out release mode with yarn android --variant=release.

from playtorch.

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.