question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ionic Capacitor - loadFromUri

See original GitHub issue

After i changed from a ionic cordova to capacitor build i experience issues loading the models. On my PWA everything is working and the models are placed in the www/assests/models folder. But when i try to run the native android build i get this error message

Error: Uncaught (in promise): Error: Based on the provided shape, [1,1,512,512], the tensor should have 262144 values but has 216607
    Error: Based on the provided shape, [1,1,512,512], the tensor should have 262144 values but has 216607
        at d (http://localhost/vendor.js:100321:4453)
        at dn (http://localhost/vendor.js:100321:71403)
        at fn (http://localhost/vendor.js:100321:70965)
        at o (http://localhost/vendor.js:100321:444184)
        at _c (http://localhost/vendor.js:100321:444219)
        at http://localhost/vendor.js:100321:463380
        at Array.forEach (<anonymous>)
        at http://localhost/vendor.js:100321:463354
        at Array.forEach (<anonymous>)
        at http://localhost/vendor.js:100321:463142

In my previous build for the native android app with cordova the models where located at assets/www/assets/models now with capacitor the folder structure changed to assets/public/assets/models.

I load ssd with await faceapi.nets.ssdMobilenetv1.loadFromUri('assets/models');

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

5reactions
esmircmcommented, Sep 6, 2019

After i changed from a ionic cordova to capacitor build i experience issues loading the models. On my PWA everything is working and the models are placed in the www/assests/models folder. But when i try to run the native android build i get this error message

Error: Uncaught (in promise): Error: Based on the provided shape, [1,1,512,512], the tensor should have 262144 values but has 216607
    Error: Based on the provided shape, [1,1,512,512], the tensor should have 262144 values but has 216607
        at d (http://localhost/vendor.js:100321:4453)
        at dn (http://localhost/vendor.js:100321:71403)
        at fn (http://localhost/vendor.js:100321:70965)
        at o (http://localhost/vendor.js:100321:444184)
        at _c (http://localhost/vendor.js:100321:444219)
        at http://localhost/vendor.js:100321:463380
        at Array.forEach (<anonymous>)
        at http://localhost/vendor.js:100321:463354
        at Array.forEach (<anonymous>)
        at http://localhost/vendor.js:100321:463142

In my previous build for the native android app with cordova the models where located at assets/www/assets/models now with capacitor the folder structure changed to assets/public/assets/models.

I load ssd with await faceapi.nets.ssdMobilenetv1.loadFromUri('assets/models');

I use ionic with capacitor and load the models in this way:

await faceapi.loadSsdMobilenetv1Model('/assets/models'); await faceapi.loadFaceLandmarkModel('/assets/models');

The extension of the models changed them to bin

Captura de pantalla 2019-09-07 a las 1 13 13

Similarly in the .json files

Captura de pantalla 2019-09-07 a las 1 15 36

Running on android and ios 🎉🎉

0reactions
jairforerocommented, Nov 16, 2020

Hi I rename models to .bin and change this in json but say error in android

2020-11-16 15:35:27.015 24121-24121/systemsweb.net E/Capacitor/Console: File: http://localhost/vendor-es2015.js - Line 41309 - Msg: ERROR Error: Uncaught (in promise): Error: SsdMobilenetv1 - load model before inference Error: SsdMobilenetv1 - load model before inference at SsdMobilenetv1.push…/node_modules/face-api.js/build/es6/ssdMobilenetv1/SsdMobilenetv1.js.SsdMobilenetv1.forwardInput (http://localhost/tab3-tab3-module-es2015.js:13925:19) at SsdMobilenetv1.<anonymous> (http://localhost/tab3-tab3-module-es2015.js:13959:35) at step (http://localhost/vendor-es2015.js:123912:23) at Object.next (http://localhost/vendor-es2015.js:123893:53) at fulfilled (http://localhost/vendor-es2015.js:123883:58) at ZoneDelegate.invoke (http://localhost/polyfills-es2015.js:3470:30) at Object.onInvoke (http://localhost/vendor-es2015.js:73011:33) at ZoneDelegate.invoke (http://localhost/polyfills-es2015.js:3469:36) at Zone.run (http://localhost/polyfills-es2015.js:3229:47) at http://localhost/polyfills-es2015.js:3963:40

Read more comments on GitHub >

github_iconTop Results From Across the Web

App Capacitor Plugin API
The App API handles high level App state and events.For example, this API emits events when the app enters and leaves the foreground,...
Read more >
Ionic Capacitor - loadFromUri - face-api.js - GitAnswer
Ionic Capacitor - loadFromUri - face-api.js. After i changed from a ionic cordova to capacitor build i experience issues loading the models.
Read more >
Ionic/Capacitor iOS App does not load script from a third party ...
I am currently working on an ionic/react app using capacitor to "compile" it into android and iOS Apps. Right now the app itself...
Read more >
Develop 99% of your Ionic app in the browser with Capacitor
One of the guiding design goals of Capacitor, Ionic's new native web app container project that runs your web app natively on iOS,...
Read more >
Announcing Capacitor 1.0.0 Alpha - Ionic Blog
Capacitor aims to build a better Native runtime for the future of Ionic apps running everywhere: iOS, Android, Electron, and on the web...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found